`lsp-eslint` does not work in many projects without setting `lsp-eslint-working-directories`
Thank you for the bug report
- [X] I am using the latest version of
lsp-moderelated packages. - [X] I checked FAQ and Troubleshooting sections
- [ ] You may also try reproduce the issue using clean environment using the following command:
M-x lsp-start-plain
Bug description
Somehow lsp-mode when using eslint does not work correctly in many projects unless you set lsp-eslint-working-directories. I have a project with multiple sub-projects, one of which is web, containing a t3(https://t3.gg/) app. yarn eslint . in that directory works as intended, yet lsp does not show any messages from eslint.
Naturally, people setting lsp-eslint-working-directories manually for every project is not a workable fix. It seems (pattern "./*") works.
I have also tried to ensure that my projectile project root is set to the web subproject, but that does not change anything.
Steps to reproduce
- Create a new directory
- Inside that directory, create a new t3 app
- Open any file with eslint errors.
- Nothing is shown by lsp eslint.
Expected behavior
Errors are shown.
Which Language Server did you use?
eslint
OS
Linux
Error callstack
No response
Anything else?
No response
To me, this sounds like a specific behavior of eslint language server. What is the expected fix from lsp-mode side?
Is there a convenient way to debug this against my project structure? I too am using a mono repo with many projects, only some of which need eslint but as far as I can tell my lsp project dir should be the subrepo.
Hi, I can confirm this, and in my case using * wildcard doesn't work.
In my case I have a monorepo like:
.eslintrc.js
packages/
-- module-1
---- tsconfig.json
---- src/
-- module-2
---- tsconfig.json
---- src/
If I set lsp-eslint-working-directories to the project's root directory, it doesn't work, eslint doesn't do anything. In the log buffer I can see the requests but all the responses came empty.
In order to get it to work for the files in src of module-1 i have to add root/packages/module-1 to lsp-eslint-working-directories, but that only works for module-1, if I visit a file in module-2 it doesn't work. Also if I add both paths to lsp-eslint-working-directories it only works with the module that I visit first, so with both paths, if I visit a file in module-2 it works, but if I visit another in module-1 it doesn't.
Is there a way to get the logs or outputs of the interaction between eslintServer.js and eslint?
If I do npx eslint packages/module-1/src/file.ts I get Parsing error: Cannot read file 'tsconfig.json' doing the same inside module-1 (where tsconfig.json is) works fine.
I guest a possible solution could be to set a hook that goes up in the directory structure until it finds a tsconfig.json, then replace lsp-eslint-working-directories and restart eslintServer maybe?
In ms vscode it works fine.