microsoft / vscode-eslint

VSCode extension to integrate eslint into VSCode
MIT License
1.73k stars 334 forks source link

How to configure eslint for a mono repo ? #1934

Open SummySumanth opened 1 day ago

SummySumanth commented 1 day ago

I have a mono repo, having both frontend and backend in same repository, I want to specify eslint config in respective folders and have those apply in their directory itself (backend config in backend and frontend config in frontend), but eslint plugin in vscode keeps picking .eslintrc.json file instead of eslint.config.js, how to fix this ?

my project structure is as following

/.vscode
  └── settings.json
/app
  └── .vite
/backend
  └── eslint.config.js
  └── (files)
/frontend
  └── eslint.config.js
  └── (files)

./vscode/settings.json

  {
    "eslint.workingDirectories": [
        {
            "directory": "../frontend",
            "changeProcessCWD": true,
            "overrideConfigFile": "./../frontend/eslint.config.js"
        },
        {
            "directory": "../backend",
            "changeProcessCWD": true,
            "overrideConfigFile": "./../backend/eslint.config.js"
        }
    ],
}

Error in vscode plugin output

  [Error - 02:13:46] Request textDocument/diagnostic failed.
  Message: Request textDocument/diagnostic failed with message: Cannot read config file: /project/backend/.eslintrc.json
Error: ENOENT: no such file or directory, open '/project/backend/.eslintrc.json'
  Code: -32603 

Originally posted by @SummySumanth in https://github.com/eslint/eslint/discussions/18958

dbaeumer commented 2 hours ago

"overrideConfigFile" can't be specified on a working directory.

From how I understand your setup a working directory configuration like ["./frontend", "./backend"] should work

If not please provide me with a GitHub repository I can clone with a minimal setup that demos what you are seeing.