SublimeLinter: Wrong working directory on nested local eslint installs (breaks eslint@6)
In my mono-repository setup I have the following structure:
bar
- .eslintrc
- package.json < installs eslint, eslint-plugin-mocha
- foo.js < file to be linted
package.json < parent package.json, in mono-repository setup
Linting via SublimeLinter-eslint uses the project root as the working directory despite the fact that eslint is located in the sub-directory. Because of that eslint fails to locate plug-ins, installed in the sub-directory, next to the eslint installation:
SublimeLinter: #11 linter.py:1478 Running ...
{{DIR}} (working dir)
$ cat bar/foo.js | {{DIR}}/bar/node_modules/.bin/eslint --format json --stdin --stdin-filename {{DIR}}/bar/foo.js
SublimeLinter: #11 linter.py:49 ERROR:
Oops! Something went wrong! :(
ESLint: 6.0.1.
ESLint couldn't find the plugin "eslint-plugin-mocha".
(The package "eslint-plugin-mocha" was not found when loaded as a Node module from the directory "{{DIR}}".)
Expected Behavior
The directory into which eslint is installed (locally) is used as a cwd when running the command.
Reproduce
I’ve created a example setup that shows the issue. To reproduce, clone and install it
git clone git@github.com:nikku/sublime-eslint-test.git
(cd sublime-eslint-test/bar && npm install
Then open sublime-eslint-test in Sublime Text, navigate to sublime-eslint-test/bar/foo.js in Sublime Text.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 6
- Comments: 22 (14 by maintainers)
Commits related to this issue
- wip: update tests to cover #1626 — committed to HusamElbashir/SublimeLinter by HusamElbashir 5 years ago
- Redo executable lookup in `NodeLinter` We now traverse up (usually coming from the dir of the current filename) looking for 'package.json' files. Whenever, we find one, we look into it and see if the... — committed to HusamElbashir/SublimeLinter by HusamElbashir 5 years ago
- Redo executable lookup in `NodeLinter` We now traverse up (usually coming from the dir of the current filename) looking for 'package.json' files. Whenever, we find one, we look into it and see if the... — committed to HusamElbashir/SublimeLinter by HusamElbashir 5 years ago
@HusamIbrahim did an amazing job here 👏
Unfortunately I found myself unable to build a fix. I’m not an profound python developer, that may be part of the problem 😟. Is there any python developers in the userbase that uses eslint (and JavaScript) that can help?
Why is this an issue? The project root from eslint’s perspective is the directory in which eslint is installed. That makes total sense. The project root from SublimeLinters perspective is what exactly? Given my structure with multiple package jsons SublimeLinter will deduce that the outermost directory with a package JSON is the project root. I believe that is not the right assumption.