-
-
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
[import/no-duplicates] {"prefer-inline": true}
does not work
#2715
Comments
I agree this should be autofixed - as well as warned on. cc @snewcomer |
Ok perfect. Been working on and throwing away solutions for a few weeks now here and there. Will try to put up my progress today. |
Related issue here, when running ESLint from the terminal I get the error
even though I used the exact same options as in the docs. |
The issue lies in the creation of the various import maps in the rule. In the case of the following: import { type Foo } from '.';
import { foo } from '.'; Line 1 will be sorted into If I wrap this block in a import { foo , type Foo } from '.'; I need to dig more though as I'm not yet sure which is the correct description of the problem:
It's likely that the full spectrum of cases needs to be first enumerated. Like what happens in the following situation with and without import type { Foo } from '.';
import { foo, type bar } from '.';
import { bar } from '.'; Given the existence of
|
@merrywhether Could you try and symlink this PR? I still have to run it against a few repos to see if it works but it would be good to get some early signal! |
Have you updated the eslint-plugin-import to a version that it is supported. We had an issue where the docs were published before the feature was released. In any case, I would avoid upgrading anyways. I made a mistake with the original PR where I still had the typescript-eslint repo linked where I did the bundled work so got a false positive that the amalgamation of PRs worked :(. |
That's not entirely accurate; docs are always landed on main prior to being released - users need to check the tagged docs (on every repo on github, not just this one) |
Oh, it can very well be that I did not upgrade, I didn't know it was a new feature. But in that case the error message is very confusing, I think it should say something like |
@guillaumebrunerie you'd need to ask eslint about that; we have no control over that error message. In this case, the rule was known, but that schema option was not. |
I think this is similar to #2675 |
Having this issue too. It only detects an error when an existing import already has types, like this one: import { AValue, type AType } from './mama-mia'
import type { BType } from './mama-mia' Gets fixed into this: import { type AType, AValue, type BType } from "./mama-mia" However, if first import doesn't have a type import already, like this: import { AValue } from './mama-mia'
import type { BType } from './mama-mia' It doesn't work on that case. |
Fixed by #2835? |
In particular, glad to have import-js/eslint-plugin-import#2715 resolved. It caught one unnecessary redundancy already, auto-fixed here!
In particular, glad to have import-js/eslint-plugin-import#2715 resolved. It caught one unnecessary redundancy already, auto-fixed here!
related? #2792 |
version
2.27.5
https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-duplicates.md#inline-type-imports
The documentation states that adding
{"prefer-inline": true}
as shown below will cause errors and autofixes if there are duplicate imports. However, this was not possible in my environment.It should look like the following, but there is no error or anything.
Is this currently being corrected?
The text was updated successfully, but these errors were encountered: