-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
[no-duplicates] Bad auto fix for typescript #2697
Comments
@latin-1 Thanks for the issue! Yes, it doesn't look like it is performing correctly. Both the type and inline type specifiers for an import statement are not allowed. Looking at this and a few other issues today. If
If it is false or not specified, it should stay the same.
source of error - https://github.com/import-js/eslint-plugin-import/pull/2475/files#r1089976521 |
Furthermore, I wonder if instead we should make our best effort to collapse. prefer-inline false
or depending on the order of the original
The easier case to handle is prefer-inline true. However, if false, this isn’t terribly hard to handle as well. The above example shows that we could pull all inline types and type imports from other Type/InlineType ImportDeclarations to the first Type ImportDeclaration and leave the Value ImportDeclarations to their own import statement. The flexibility here is important esp when considering many (>2) duplicate import statements in any order - maybe the value import is first, maybe the type import is first. |
@ljharb Hi Jordan. So basically I have a POC to fix this issue but also make the process of collapsing ‘type’ duplicates more flexible. The original solution I did was entirely inflexible :). I was hoping to either get alignment for the previous comment code block, whether you wanted more explanation, or if you felt it should go elsewhere. |
Yes, I think it would be ideal to maximally collapse, preserving order as best as can be ( |
Possibly related: #2792 |
Regardless of the
prefer-inline
option.Input
Output
cc @snewcomer
The text was updated successfully, but these errors were encountered: