import-js / import-js/eslint-plugin-import
Proposal: `default-import-match-filename`
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 5.9k
- Forks
- 1.5k
- PR merge metrics
- No merged PRs in 30d
Description
I often see things such as:
import parseDate from './types/date';
import float from './types/parseFloat';
The disparity between the default import name (parseDate) and file name (date) often indicates that one or the other is named inappropriately. In the first case, thats the file name. In the second case, thats the local variable name.
Valid code:
import parseFloat from './types/parseFloat';
import parseDate from './types/parseDate';
Invalid code:
import parseDate from './types/date';
import float from './types/parseFloat';
There is no way to enforce a right name, e.g. user could just as well end up with:
import date from './types/date';
import float from './types/float';
However, I would argue that these issues are easy to notice in the code. Having this rule would prevent lazy developers from using a better variable name in a local file and ignore the need to rename the file and other references.
Furthermore, this enables easier code inspection (because it is easy to recognise what a variable represents when it is being used consistently between many files).
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 payload names no files, tests, or entry points. Start by reviewing existing eslint-plugin-import rule patterns and the 20-comment discussion, then define the supported default-import and filename cases from the examples; done means the rule consistently identifies mismatches without claiming one naming choice is universally correct.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- eslint, javascript
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100