import-js / import-js/eslint-plugin-import
import/no-unresolved errors if package omits `.js` extension in `main`
- Dominant language
- JavaScript
- Stars
- 5.9k
- Forks
- 1.5k
- PR merge metrics
- No merged PRs in 30d
Description
If a dependency (for instance, a package in `node_modules`) omits an extension in the `main` field of its `package.json`, the `import/no-unresolved` rule will fail.
For example:
``` javascript
// node_modules/foo/package.json
{
name: "foo",
version: "1.0.0",
main: "index"
}
// node_modules/foo/index.js
const message = 'It is legal to omit a .js on "main" in package.json';
export default message;
// index.js
import foo from 'foo'; // This triggers the import/no-unresolved rule
console.log(foo);
```
I imagine this should be a simple fix.
Contributor guide
Research direction
Reproduce the example with node_modules/foo/package.json, its extensionless main value, index.js, and the import/no-unresolved rule. Trace how the resolver handles package main entries, then add coverage for this package shape and confirm the rule no longer reports the valid import.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100