whenever I try to run eslint with lint-staged on commit I get the following error regarding the parserOptions.project:
I have the following project structure for a simple Node JS backend + React Frontend. Each module has its own eslint+tsconfig and they all extend the base one. The project is set in each, unlike what the error implies. When I run eslint normally it behaves as expected.
tsconfig-base.json
{
"extends": "@tsconfig/node16/tsconfig.json",
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"moduleResolution": "node",
"sourceMap": true,
"experimentalDecorators": true,
"strict": false,
"noImplicitAny": true,
"noEmit": true
},
"baseUrl": ".",
"rootDir": ".",
"types": ["jest", "node", "jest-extended"],
"compileOnSave": true,
"exclude": ["node_modules"]
}
.eslintrc-base.js
module.exports = {
...
parser: '@typescript-eslint/parser',
... // Various typescript related extend/plugins
}
.eslintrc.js within server, client, shared
module.exports = {
extends: '../../.eslintrc-base.js',
parserOptions: {
tsconfigRootDir: __dirname,
project: ['./tsconfig.json'],
},
};
tsconfig.json within server, client, shared looks somewhat like this
{
"extends": "../../tsconfig-base.json",
"compilerOptions": {
"outDir": "../../dist/shared"
},
"baseUrl": ".",
"include": ["./src/**/*", ".eslintrc.js"]
}
package.json
{
...
"lint-staged": {
"**/*.{ts,js,tsx,jsx}": ["eslint --fix --cache", "prettier --write"]
}
...
}
Does anyone have any idea what could be causing this? Any help would be much appreciated! Please let me know there's any information missing. I'm also open to better ways of doing things.
I've tried running a different lint-stage command for each module, specifying the specific eslintrc.js to no avail.
Thank you very much