Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no-missing-require: support package.json exports field #244

Open
kevinoid opened this issue Sep 9, 2020 · 2 comments
Open

no-missing-require: support package.json exports field #244

kevinoid opened this issue Sep 9, 2020 · 2 comments

Comments

@kevinoid
Copy link
Contributor

kevinoid commented Sep 9, 2020

If a script requires a name exported using the package.json "exports" field, it causes the node/no-missing-require rule to fail. For example:

npm install yargs eslint eslint-plugin-node
echo '{"extends":["plugin:node/recommended"]}' > .eslintrc.json
echo "const Yargs = require('yargs/yargs');" > index.js
./node_modules/.bin/eslint index.js

will print

/tmp/path/index.js
  1:23  error  "yargs/yargs" is not found  node/no-missing-require

✖ 1 problem (1 error, 0 warnings)

even though ./yargs is declared in the "exports" field of yargs/package.json and index.js executes without error.

Thanks for considering,
Kevin

@cdoublev
Copy link

cdoublev commented Mar 7, 2021

If it can save someone's time who would have wished to fix this...

@david-bojnansky
Copy link

There can be also imports field in package.json which can be used for mappings.

"imports": {
    "#abc/*": "./abc/out/*"
  }
require('#abc/file')

brettz9 pushed a commit to brettz9/eslint-plugin-node that referenced this issue Jul 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants