import-js/eslint-plugin-import

Rule `import/no-unresolved` raise false positive when there is no `main` field in the `package.json`

Open

#2,132 opened on 2021年6月19日

GitHub で見る
 (40 comments) (20 reactions) (0 assignees)JavaScript (1,540 forks)batch import
bughelp wanted

Repository metrics

Stars
 (4,946 stars)
PR merge metrics
 (平均マージ 138d 22h) (30d で 3 merged PRs)

説明

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

import GBAEmulator, { GbaContext } from 'react-gbajs'

Full code

./node_modules/.bin/eslint .

What did you expect to happen? Should raise no error. This package is present in the node_modules.

An important note: Since it's only for the browser, it has the field browser instead of main in its package.json (link). I made it following the NPM documentation. Despite that, I noticed that by adding the field main in its package.json, the error suppress - but it doesn't look correct.

What actually happened? Please copy-paste the actual, raw output from ESLint.

/Users/macabeus/ApenasMeu/klo-gba.js/brush/src/components/Emulator/index.js
  2:41  error  Unable to resolve path to module 'react-gbajs'  import/no-unresolved

/Users/macabeus/ApenasMeu/klo-gba.js/brush/src/components/KloGbaSidebar/Hacks/index.js
  7:28  error  Unable to resolve path to module 'react-gbajs'  import/no-unresolved

/Users/macabeus/ApenasMeu/klo-gba.js/brush/src/hooks/useGbaSaveRestoreState.js
  2:28  error  Unable to resolve path to module 'react-gbajs'  import/no-unresolved

/Users/macabeus/ApenasMeu/klo-gba.js/brush/src/index.js
  8:29  error  Unable to resolve path to module 'react-gbajs'  import/no-unresolved

/Users/macabeus/ApenasMeu/klo-gba.js/brush/src/providers/VisionProvider.js
  4:28  error  Unable to resolve path to module 'react-gbajs'  import/no-unresolved

✖ 5 problems (5 errors, 0 warnings)

✨  Done in 4.73s.

Steps to reproduce this issue:

  1. Clone this repository: https://github.com/macabeus/klo-gba.js
  2. Run yarn on its root
  3. cd brush
  4. yarn run lint

コントリビューターガイド