Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] order: Recognize pathGroup config for first group #1719

Merged

Conversation

forivall
Copy link
Contributor

@forivall forivall commented Apr 4, 2020

With the config

  'import/order': [
    'warn',
    {
      groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'],
      alphabetize: {
        order: 'asc',
      },
      pathGroups: [{ pattern: 'react', group: 'builtin' }],
      pathGroupsExcludedImportTypes: ['builtin'],
    },
  ],

, react wasn't being recognized as a part of the "builtin" group, since the rank would end up being 0, which is a falsy value. The fix here, is to check for undefined instead.

My current workaround is to define

      pathGroups: [{ pattern: 'react', group: 'builtin', position: 'before' }],

instead, (which results in a rank -0.1, so it's not falsy).

Co-authored-by: Emily Marigold Klassen <forivall@gmail.com>
Co-authored-by: Vitaly Gordon <rocket.mind@gmail.com>
@forivall

This comment has been minimized.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 97.797% when pulling 2171443 on forivall:fix/first-path-group-setting-ignored into 71ca88f on benmosher:master.

4 similar comments
@coveralls
Copy link

Coverage Status

Coverage remained the same at 97.797% when pulling 2171443 on forivall:fix/first-path-group-setting-ignored into 71ca88f on benmosher:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 97.797% when pulling 2171443 on forivall:fix/first-path-group-setting-ignored into 71ca88f on benmosher:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 97.797% when pulling 2171443 on forivall:fix/first-path-group-setting-ignored into 71ca88f on benmosher:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 97.797% when pulling 2171443 on forivall:fix/first-path-group-setting-ignored into 71ca88f on benmosher:master.

Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Combined this and the test from #1724. Thanks!

@ljharb
Copy link
Member

ljharb commented Apr 11, 2020

Because I pushed this to two PRs, two appveyor builds ran. The second failed (https://ci.appveyor.com/project/benmosher/eslint-plugin-import/builds/32116513), but the first succeeded (https://ci.appveyor.com/project/benmosher/eslint-plugin-import/builds/32116512), so I'm going to merge through the failure.

@ljharb ljharb merged commit fe6cea9 into import-js:master Apr 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants