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

Exclude package main files by default from no-unused-modules #1327

Closed
ehmicky opened this issue Apr 14, 2019 · 5 comments
Closed

Exclude package main files by default from no-unused-modules #1327

ehmicky opened this issue Apr 14, 2019 · 5 comments

Comments

@ehmicky
Copy link

ehmicky commented Apr 14, 2019

unusedExports: true with the no-unused-modules rule should never report files that are exported as the main file (main, browser or bin fields in package.json). What do you think?

@ehmicky ehmicky changed the title [ENHANCEMENT] Exclude package.json main file by default from no-unused-modules [ENHANCEMENT] Exclude package main files by default from no-unused-modules Apr 14, 2019
@ehmicky ehmicky changed the title [ENHANCEMENT] Exclude package main files by default from no-unused-modules Exclude package main files by default from no-unused-modules Apr 14, 2019
@ljharb
Copy link
Member

ljharb commented Apr 14, 2019

That sounds like a good enhancement, no need for it to be behind an option, even.

@rfermann
Copy link
Contributor

What package.json should be used for this purpose?

  • the package.json from the working directory,
  • the package.json from the folder specified as src in the rule options (if existing) or
  • the package.json closest to the file currently being linted (if existing and not the same as in the working directory)?

@ljharb
Copy link
Member

ljharb commented Jun 12, 2019

For a given file, the closest package.json to it, that has a main, does not have private true, and points to it, marks it as used.

ljharb pushed a commit to rfermann/eslint-plugin-import that referenced this issue Jul 17, 2019
ljharb pushed a commit to rfermann/eslint-plugin-import that referenced this issue Jul 17, 2019
@ljharb ljharb closed this as completed in 1caa402 Jul 17, 2019
@ehmicky
Copy link
Author

ehmicky commented Jul 18, 2019

Thanks for implementing this @ljharb! 🎉

@ljharb
Copy link
Member

ljharb commented Jul 18, 2019

Thank @rfermann :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants