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

Remove duplicates names in no-duplicates autofix #2437

Closed
remcohaszing opened this issue Apr 14, 2022 · 1 comment · Fixed by #2577
Closed

Remove duplicates names in no-duplicates autofix #2437

remcohaszing opened this issue Apr 14, 2022 · 1 comment · Fixed by #2577

Comments

@remcohaszing
Copy link
Contributor

Let’s say we have the following content:

import { a, b } from 'module'
import { a, c } from 'module'

The import/no-duplicates rule will report this, then perform the following autofix:

import { a, b, a, c } from 'module'

I would expect it to remove duplicates, so the output would be:

import { a, b, c } from 'module'

In my experience this is common when resolving merge conflicts if two branches added a new member to the import statement. It’s easy to Accept both changes, then let ESLint autofix resolve any issues with the imports. However, afterwards one has to remove the duplicates manually.

@ljharb
Copy link
Member

ljharb commented Apr 14, 2022

That seems like a good approach. One could be renamed ofc, in which case both would need to be kept, but when neither has a rename, or when they both have the same one, the autofix should be collapsing them.

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

Successfully merging a pull request may close this issue.

2 participants