eslint-plugin-import
eslint-plugin-import copied to clipboard
[Fix] `no-duplicates` now removes duplicate import specifiers and sorts specifiers alphabetically #1812 #1956
Fixes #1812. Fixes #1956.
Linking to issues #1812 & #1956
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.
@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?
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 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?