import-js/eslint-plugin-import

import/no-unresolved errors if package omits `.js` extension in `main`

Open

#617 opened on Oct 9, 2016

View on GitHub
 (2 comments) (1 reaction) (0 assignees)JavaScript (4,946 stars) (1,540 forks)batch import
bughelp wanted

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:

// 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