import-js / import-js/eslint-plugin-import
Wrong file chosen when comparing case sensitivity for import/no-unresolved
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 5.9k
- Forks
- 1.5k
- PR merge metrics
- No merged PRs in 30d
Description
I came across a situation where a file named "OWNERS" and a file named "Owners.jsx" in the same directory caused the "import/no-unresolved" rule to report a case mismatch when another module imported "Owners". Removing or renaming the file named "OWNERS" prevents the error. This behavior can be reproduced with the following minimal example:
Setup
Given the following files in a directory:
package.json:
{
"devDependencies": {
"eslint": "^8.5.0",
"eslint-plugin-import": "^2.25.3"
}
}
.eslintrc.yml:
parserOptions:
ecmaVersion: 2015
sourceType: module
plugins:
- import
rules:
import/no-unresolved: 2
src/Foo.js:
export default function Foo() {
}
src/Bar.js:
import Foo from "./Foo";
export default function Bar() {
return Foo();
}
src/FOO:
(contents are irrelevant)
Action
Run in a shell:
yarn install
yarn run eslint src
Expected behavior
No errors should be reported.
Actual behavior
An error is reported:
/path/to/example/src/Bar.js
1:17 error Casing of ./Foo does not match the underlying filesystem import/no-unresolved
✖ 1 problem (1 error, 0 warnings)
Additional info
- As mentioned at the top of the issue, if the file at
src/FOOis removed from the example setup, runningyarn run eslintreports no errors, as expected. - The problem is reproducible on macOS 10.15.7 on a case-insensitive APFS volume, but not on Linux on a case-sensitive volume. This suggests file system case sensitivity is a necessary condition for the problem.
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
Reproduce the issue with src/Foo.js, src/Bar.js, and src/FOO using the provided package.json and .eslintrc.yml, then run yarn run eslint src on macOS or another case-insensitive filesystem. Trace how import/no-unresolved selects the matching file; done means ./Foo resolves without a casing error while both similarly named files remain present.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- eslint, javascript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100