sublimelsp / LSP-eslint

ESLint support for Sublime LSP plugin
MIT License
36 stars 5 forks source link

ESLint Config With `parserOptions.project` Reads From Wrong Directory #70

Closed JaceHensley closed 3 months ago

JaceHensley commented 4 months ago

I have a mono repo and each package has their own .eslintrc.js file with a parseOptions.project set to a relative path. I get an error saying that the project cann't be read because no file exists at that path. But it's starting the path at the root of the monorepo rather than relative to the .eslintrc.js. I have this "workingDirectories": [{ "mode": "auto" }] set for my LSP-eslint setting.

This setup works with VSCode's eslint package with the same workingDirectories setting.

I'd be happy to dig into this more or provide more details, just lmk what's needed.

My monorepo is setup like this:

package
  package.json
  packages
    /package-1
      .eslintrc.js
      tsconfig.eslint.json
    /package-2
      .eslintrc.js
      tsconfig.eslint.json

And the eslint file looks like this:

module.exports = {
  extends: [/* base config package */],
  parserOptions: {
    project: './tsconfig.eslint.json',
  },
}

And I get an error saying "Parsing error: Cannot read file '/path/to/repo/package/tsconfig.eslint.json'. eslint"

rchl commented 4 months ago

The behavior of LSP-eslint should be equivalent to what you see in VSCode. Unless we are maybe using slightly outdated version of the underlaying LSP server and we need to update it.

Do you have a project that could be used to test this issue?

JaceHensley commented 4 months ago

For sure, here's a sample project that has auto fixes in VS Code but the error mentioned above in Sublime

https://github.com/JaceHensley/eslint-test

after checking out the repo just a yarn at the root is needed

image image

Thanks for the response!

predragnikolic commented 3 months ago

Hello @JaceHensley.

I tried your example https://github.com/JaceHensley/eslint-test. The good thing is that it works on my side.

My LSP-eslint.sublime-settings file looks like:

// Settings in here override those in "LSP-eslint/LSP-eslint.sublime-settings"

{
    "settings": {
        "workingDirectories": [
            {
                "mode": "auto"
            }
        ]
    }
}
Screenshot 2024-06-24 at 19 52 15

Without the workingDirectories setting, I will get the "Parsing error: Cannot read file '/path/to/repo/package/tsconfig.eslint.json'. eslint", so my guess is that you just put the setting in the wrong place.

Fell free to reopen this if you still have any issues.

tbremer commented 3 months ago

Had this same issue and your settings resolved it for me, thank you!

JaceHensley commented 3 months ago

Ahhh I didn't have it nested in a "settings", thank you for rubber ducking with me!