You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 7, 2023. It is now read-only.
When I enter into a package directory and run yarn run lint, everything is great. If I run lerna run lint from the root of the repo, everything is also great (because under the hood, lerna will cd into each package directory). However, if I open any source file in Atom, I get this error:
The package.json file could not be found. (import/no-extraneous-dependencies)
For each of my packages, I have the following defined in the local .eslintrc.json file:
This tells eslint to look at the local package.json (the one in the package directory) and the one in the root of the repo, since we define our dependencies in both places. The fact that Atom is reporting this error suggests to me that the context (current working directory) is wrong somehow. For a lerna repo, the current working directory should be the package directory, not the root of the repo. Is there a way for linter-eslint to do the right thing here and use the package directory as the current working directory?
Bug Checklist
Restart Atom
Verify the eslint CLI gives the proper result, while linter-eslint does not
Paste the output of the Linter Eslint: Debug command from the Command Palette below
This is an interesting one. Do you happen to have a minimal reproducing repo that we could try out and experiment with? Also, out of curiosity, what happens if, from the main root of your project, you run yarn eslint packages/package1/<any_file.js>?
If I do that, I get the same errors being reported in Atom, so that makes me feel a little bit better that it's reproducible on the command line. But this isn't how a lerna repo works; you have to be in the directory of the package to run the scripts/tools.
(Similarly, if I open the package directory in Atom, then all the linting errors go away, because the working directory is correct. But this is kind of an annoying workflow since I can't "see" all my packages at once.)
After you yarn install, you'll notice that you can lint from the root (which runs lerna):
$ yarn run lint
yarn run v1.17.3
$ lerna run lint
lerna notice cli v3.16.4
lerna info versioning independent
lerna info Executing command in 1 package: "yarn run lint"
lerna info run Ran npm script 'lint' in 'foo' in 3.2s:
$ eslint --max-warnings 0 *.js
lerna success run Ran npm script 'lint' in 1 package in 3.2s:
lerna success - foo
Done in 4.69s.
Or you can lint from within the package:
$ cd packages/foo/
$ yarn run lint
yarn run v1.17.3
warning package.json: No license field
$ eslint --max-warnings 0 *.js
Done in 1.58s.
But trying to lint a package file from the root doesn't work:
$ yarn eslint packages/foo/rollup.config.js
yarn run v1.17.3
$ eslint-issue/node_modules/.bin/eslint packages/foo/rollup.config.js
eslint-issue/packages/foo/rollup.config.js
0:1 error The package.json file could not be found
import/no-extraneous-dependencies
1:1 error 'rollup-plugin-commonjs' should be listed in the project's dependencies. Run 'npm i -S rollup-plugin-commo
njs' to add it import/no-extraneous-dependencies
2:1 error 'rollup-plugin-node-resolve' should be listed in the project's dependencies. Run 'npm i -S rollup-plugin-n
ode-resolve' to add it import/no-extraneous-dependencies
✖ 3 problems (3 errors, 0 warnings)
Issue Type
Question
Issue Description
I have a lerna repo configured in a pretty standard way:
When I enter into a package directory and run
yarn run lint
, everything is great. If I runlerna run lint
from the root of the repo, everything is also great (because under the hood, lerna willcd
into each package directory). However, if I open any source file in Atom, I get this error:For each of my packages, I have the following defined in the local
.eslintrc.json
file:This tells eslint to look at the local
package.json
(the one in the package directory) and the one in the root of the repo, since we define our dependencies in both places. The fact that Atom is reporting this error suggests to me that the context (current working directory) is wrong somehow. For a lerna repo, the current working directory should be the package directory, not the root of the repo. Is there a way for linter-eslint to do the right thing here and use the package directory as the current working directory?Bug Checklist
eslint
CLI gives the proper result, whilelinter-eslint
does notLinter Eslint: Debug
command from the Command Palette belowThe text was updated successfully, but these errors were encountered: