Use file location for `.eslintrc.js` resolution
See original GitHub issueIt seems that when using multiple .eslintrc.js
files throughout the workspace (of which some may use root: true
), vscode-eslint doesn’t follow the same resolution algorithm that eslint itself uses.
It seems that eslint.workingDirectories
could be a (very inelegant and manual) solution to this problem, by specifying every directory, that has an .eslintrc.js
file as a working directory.
Is there no way for vscode-eslint to “just” follow the same resolution logic that eslint uses? Am I doing something wrong?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:12 (3 by maintainers)
Top Results From Across the Web
Configuration Files - ESLint - Pluggable JavaScript Linter
The configuration cascade works based on the location of the file being linted. If there is a .eslintrc file in the same directory...
Read more >webpack - How to manually add a path to be resolved in eslintrc
Then ESLint resolve from src directory. You can require src/hoge/moge.js by writing const moge = require('hoge/moge'); and ESLint knows it.
Read more >How to set up scanning to my files eslintrc. js - Sonar Community
I've a JavaScript project which I want to scan it using Sonar Scanner but Files under the project root directory are not scanned...
Read more >ESLint | IntelliJ IDEA Documentation - JetBrains
With ESLint, you can also use JavaScript Standard Style as well as ... is found in the current file folder, IntelliJ IDEA will...
Read more >specify a path to the 'eslint' package - You.com | The AI Search ...
You can set the ESLint module import resolution by adding this snippet to your .eslintrc.json configuration file: { ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think most issues can be traced back to an incorrect
process.cwd()
.I have a shareable config that looks up the package name from the
package.json
of the project, to configureimport-helper/order-imports
. It basically does this:I have a monorepo with a
package.json
at the root of the repository, that basically looks like this:And then in the package where I use my shareable
import-helper/order-imports
config, I basically got thispackage.json
:And this
.eslintrc.js
:When I run
yarn lint:js
somewhere inside thesome-app
package (can even be a subdirectory ofsome-app
), theprocess.cwd()
is./packages/some-app
.The
require()
shown in the first code snippet thus works like this:When
vscode-eslint
runs the litner for this any file inside thesome-app
, package, theprocess.cwd()
is./
(the repo root).The
require()
shown in the first code snippet thus works like this:I think
vscode-eslint
should do two things:When a file is linted, traverse up the directory hierarchy and read all
package.json
files on the way. Once apackage.json
that listseslint
as a dependency is found, use it’s directory as theprocess.cwd()
and also resolveeslint
relative to this directory. As an added bonus, this allows using different versions ofeslint
in a monorepo, even though I would generally consider this to be an anti-pattern.This would basically be an “automated”
eslint.workingDirectories
.Whoops, didn’t mean to close this issue. GitHub did this for me, since I referenced this as
Fixes
in a PR in a private repo.If any of the other participants feel that this should be reopened, I can do so. But at least for me, the issue is solved for now.