Skip to content

Order bug: pathGroup overrides type group #2159

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

Closed
atav32 opened this issue Jul 19, 2021 · 1 comment
Closed

Order bug: pathGroup overrides type group #2159

atav32 opened this issue Jul 19, 2021 · 1 comment

Comments

@atav32
Copy link

atav32 commented Jul 19, 2021

Given the imports

import c from 'Bar';
import a from 'foo';

import b from 'dirA/bar';

import index from './';

import type { C } from 'dirA/Bar';
import type { A } from 'foo';

and ESLint config

'import/order': [
  error: {
    alphabetize: { order: 'asc' },
    groups: ['external', 'internal', 'index', 'type'],
    pathGroups: [
      {
        pattern: 'dirA/**',
        group: 'internal',
      },
    ],
    'newlines-between': 'always',
    pathGroupsExcludedImportTypes: [],
  },
],

The rules engine currently requires grouping the paths that match the pathGroup pattern together, even if one of the imports is a type import, creating this unintuitive order:

import c from 'Bar';
import a from 'foo';

import type { C } from 'dirA/Bar';
import b from 'dirA/bar';

import index from './';

import type { A } from 'foo';
@atav32
Copy link
Author

atav32 commented Jul 19, 2021

Ah nvm, even though I read #2088, I made a typo and had pathGroupsExcludedImportTypes: ['types'], which is why I though it was broken.

I didn't understand how pathGroupsExcludedImportTypes worked until I played with the computeRank().

@ljharb ljharb closed this as completed in 95e6011 Jul 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant