Nested npm projects select wrong tools with flycheck and lsp
- Dominant language
- Emacs Lisp
- Stars
- 22.7k
- Forks
- 3.1k
- Avg merge
- 10h 46m
- Merged PRs (30d)
- 4
Description
### I confirm that...
- [X] I have searched the [issue tracker](https://github.com/doomemacs/doomemacs/issues), [documentation](https://docs.doomemacs.org), [FAQ](https://docs.doomemacs.org/-/faq), [Discourse](https://discourse.doomemacs.org), and [Google](https://google.com), in case this issue has already been reported/resolved.
- [X] I have read "[How to Debug Issues](https://doomemacs.org/d/how2debug)", and will use it to provide as much information about this issue as possible.
- [X] The issue can be reproduced on the **latest** available commit of Doom.
- [X] The issue can be reproduced on a stable release of Emacs, such as 27, 28, or 29. *(Unstable versions end in .50, .60, or .9x)*
### Expected behavior
I primarily work on a project with nested npm packages.
When opening a file that is inside a subpackage, flycheck should find `eslint` in the `node_modules` directory of the subpackage ie. `/package-a/node_modules/.bin/eslint`.
### Current behavior
Currently, flycheck uses `eslint` from the root directory.
This is because the function `+javascript-add-npm-path-h` uses projectile to find the root dir and adds `node_modules/bin` to the path.
### Steps to reproduce
# Package Structure
1. Create project :: `mkdir bug-repro`
2. Initialize npm :: `npm init -y`
3. install eslint :: `npm i eslint`
4. Create an eslint config :: `echo '{"rules": { "no-unused-vars": "error"}}` > .eslintrc`
5. Create a file w/ violation :: `echo 'const x = 10;' > index.js`
6. Create subpackage :: `mkdir subpackage`
7. `cd subpackage`
8. Initialize new npm project :: `npm init -y`
9. Install eslint :: `npm i eslint`
10. Create slightly different eslint config :: `echo '{"rules": { "no-unused-vars": "warn"}}` > .eslintrc`
11. Create a file w/ violation :: `echo 'const x = 10' > index.js`
# Checking
use `flycheck-verify-setup` to see that in both cases the eslint binary is the binary from the root.
### System Information
https://gist.github.com/bolivier/af0ab99120f44c4d52a85f2330de7c45
Contributor guide
Assessment
This issue has not been assessed yet.