Closed hudochenkov closed 7 years ago
Currently, I set up project-specific settings override as a workaround for this issue:
{
"folders":
[
{
"path": "."
}
],
"settings": {
"ESLint-Formatter": {
"eslint_path": {
"osx": "/Users/aleks/project/node_modules/.bin/eslint"
}
}
}
}
@ramiel, how should this be handled?
I'll look at this tomorrow. We should stop at the project root instead of the first package.json probably.
The problem can be a bit complex. At the moment we go up, starting from the current directory, and we stop at the first package.json we find. Then we suppose that is the point were eslint is installed. Setup like the one from @hudochenkov show that this is not always the case. We have so two possibilities.
The latter is not affordable because eslint allow to have more than one file and do not enforce you to put "root": true
in the top one.
Reading the content of the package.json file instead is heavy, considering that the plugin has no cache system and that this operation is performed everytime a file if linted (easily at every save).
It looks to me that using a per-project configuration for cases like this is the most viable solution.
@TheSavior have you any other idea?
Another idea is to look for the first path where is present node_modules/eslint
. This rely on the structure of the node_modules folder itself, which should be reliable until npm change it again or another fancy package manager is used. But it's fast. I'll propose a PR and we continue to discuss there
I have a monorepo project (inside project multiple sub-project each with own package.json). ESLint is set up in the project root directory, and not in sub-directories with own package.json. With this change introduced in 2.3.0 ESLint-Formatter looking in the closest package.json, but if there is no ESLint, it won't look into project root, and go straight to globally installed ESLint.