eslint-plugin-import icon indicating copy to clipboard operation
eslint-plugin-import copied to clipboard

[Fix] `no-duplicates` now removes duplicate import specifiers and sorts specifiers alphabetically #1812 #1956

Open fingerartur opened this issue 3 years ago • 5 comments

Fixes #1812. Fixes #1956.

fingerartur avatar Oct 21 '21 05:10 fingerartur

Linking to issues #1812 & #1956

nickofthyme avatar Oct 21 '21 13:10 nickofthyme

I made sure that existing tests are passing. In order to achieve this I had to exclude a corner case - imports which contain inline comments. So now an import such as import { useState /* My favorite hook */ } from 'react' will not get an auto-fix.

fingerartur avatar Oct 26 '21 20:10 fingerartur

@ljharb hi, this MR is ready for review. How should I deal with the fact that I'm getting blocked by eslint check, but the eslint errors are in files completely unrelated to my changes?

fingerartur avatar Oct 28 '21 08:10 fingerartur

I have a feeling this MR may not get merged due to it's lack of support for inline comments inside import statements. For anybody who prefers no-duplicates to remove duplicate import specifiers and sort them alphabetically and does not need support for comments inside import statements, you may use my fork:

yarn add -D fingerartur/eslint-plugin-import

fingerartur avatar Dec 18 '21 11:12 fingerartur

@fingerartur it doesn’t have to support autofixing inline comments, but it definitely can’t incorrectly autofix them. An easy path to getting this P R merged (there’s no such thing as an MR except on gitlab) would be to skip the autofixer whenever a comment is present - then it only autofixes in the safe cases.

Is that a change you’re willing to make?

ljharb avatar Dec 18 '21 16:12 ljharb