import-js / import-js/eslint-plugin-import
Rule proposal: no-duplicate-named
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 5.9k
- Forks
- 1.5k
- PR merge metrics
- No merged PRs in 30d
Description
I just noticed the the following is considered to be valid syntax by both espree and babel-eslint.
import {a, a, b as a, c as a} from 'foo';
We should add a rule that forbids:
- Importing a named export twice:
{a, a} - Importing a named export and naming it after another imported named export:
{a, b as a} - Importing a named export and naming it after the name of another renamed imported named export:
{b as a, c as a}
To discuss:
- Importing a named export and naming it the original name of an other renamed imported named export:
{b as a, c as b}
I'm pretty sure we had a rule to forbid import {b as a} from 'foo' when a is also a named export of that module, but I don't remember which one. If we don't, let me know, and I'll create an issue, because that sounds like a nice style issue to have. That might fill the role of the last to discuss item?
I propose the name no-duplicate-named, but I'm open to better names :)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names no files, tests, or entry points. First resolve the proposed rule's name and the disputed {b as a, c as b} behavior, then identify the existing import-rule implementation and tests; done means duplicate named imports are consistently rejected according to the agreed cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- eslint, javascript
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100