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

[import/order] Regression in type behavior with parent and sibling #2683

Open
erunion opened this issue Jan 18, 2023 · 7 comments
Open

[import/order] Regression in type behavior with parent and sibling #2683

erunion opened this issue Jan 18, 2023 · 7 comments

Comments

@erunion
Copy link

erunion commented Jan 18, 2023

We have a complex import/order config and are seeing some new behavior with our type imports on v2.27.5 where previously sorted parent → sibling type imports want to now be sorted as sibling → parent.

'import/order': [
  'error',
  {
    'alphabetize': {
      order: 'asc',
      caseInsensitive: true,
    },
    'groups': ['type', 'builtin', 'external', 'internal', 'parent', 'sibling', 'index', 'object'],
    'newlines-between': 'always',
    'warnOnUnassignedImports': true,
  },
],

Before

import type { CommandOptions } from '../lib/baseCommand';
import type { Options } from './openapi/validate';

import Command from '../lib/baseCommand';
import isHidden from '../lib/decorators/isHidden';

import OpenAPIValidateCommand from './openapi/validate';

After

import type { Options } from './openapi/validate';
import type { CommandOptions } from '../lib/baseCommand'; <-- this line was moved 

import Command from '../lib/baseCommand';
import isHidden from '../lib/decorators/isHidden';

import OpenAPIValidateCommand from './openapi/validate';
@ljharb
Copy link
Member

ljharb commented Jan 18, 2023

I think this is a duplicate of #2682?

@erunion
Copy link
Author

erunion commented Jan 18, 2023

@ljharb I'm not sure because the non-type imports are fine here, it's just import type that's affected.

@ljharb
Copy link
Member

ljharb commented Jan 18, 2023

cc @Pearce-Ropion in case this is related, but if not, it'd still be great to tackle it in the same PR

@Pearce-Ropion
Copy link
Contributor

Pearce-Ropion commented Jan 18, 2023

Hmm, this is caused by the same alphabetical sorting issue but cannot be fixed in the same way unless we add groups for types.

@ljharb
Copy link
Member

ljharb commented Jan 18, 2023

types is already its own group, and its contents should have the top-level groups sorting, minus types, applied.

@Pearce-Ropion
Copy link
Contributor

Quick progress update, I have a fix for this working locally. I'm working on adding a few more unit test cases to maintain code coverage. I should have a PR up by the end of the week.

@Pearce-Ropion
Copy link
Contributor

I've put up #2721. I think it needs more unit testing but figured I'd get the PR out there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants