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

Cannot run eslint in a subdirectory of a project #255

Closed
jfx2006 opened this issue Sep 26, 2024 · 0 comments
Closed

Cannot run eslint in a subdirectory of a project #255

jfx2006 opened this issue Sep 26, 2024 · 0 comments

Comments

@jfx2006
Copy link
Contributor

jfx2006 commented Sep 26, 2024

Short version: If you run eslint from a subdirectory of a project, when the no-unsanitized plugin loads, it fails because of the readFileSync("./package.json") line in index.js.

This caused a problem for Thunderbird which always runs mach eslint in the comm/ subdirectory so it uses the right eslint configuration.

STR:

  • In a mozilla-central clone, run ../mach eslint base/content/*.js from the browser/ directory.

Fails with:
Error: Failed to load plugin 'no-unsanitized' declared in '../.eslintrc.js » plugin:mozilla/recommended': ENOENT: no such file or directory, open './package.json'

I was able to minimally reproduce with a small js project with eslint and no-unsantized as well.

I suspect the intent was to read the package.json from this package to fill in the plugin metadata version?

Bug 1921150 filed with workaround fix for Thunderbird. Workaround is to create an empty package.json prior to running eslint and then remove it.

jfx2006 added a commit to jfx2006/eslint-plugin-no-unsanitized that referenced this issue Sep 26, 2024
Standard8 added a commit that referenced this issue Sep 26, 2024
Read package.json from this package, not current directory. Fixes #255.
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

1 participant