I got this error on Eslint Typescript in VSCode.
I have installed
- Prettier Eslint
- ESLint
- nodejs v18.17.0 using NVM
My current OS is Linux Mint 21.1 Cinnamon
.
I have followed several answers on stack overflow such as in this question, but have no luck.
this is my parserOptions.project
in eslintrc
:
"parserOptions": {
"ecmaVersion": "latest",
"project": ["./tsconfig.json"],
"sourceType": "module",
"tsconfigRootDir": "."
},
and this is my tsconfig.json
:
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"rootDir": ".",
"baseUrl": ".",
"strict": true,
"alwaysStrict": true,
},
"ts-node": {
"swc": true
},
"include": [
"src/**/*.ts",
"./**/*.ts",
"**/__tests__/*",
"**/*.test*",
"**/*.spec*",
".eslintrc"
],
"ignorePatterns": [".eslintrc"],
}
tsconfig.base.json
:
{
"compilerOptions": {
"allowJs": true,
"allowSyntheticDefaultImports": true,
"alwaysStrict": true,
"baseUrl": ".",
"emitDecoratorMetadata": true,
"esModuleInterop": true,
"exactOptionalPropertyTypes": false,
"experimentalDecorators": true,
"forceConsistentCasingInFileNames": true,
"importHelpers": false,
"lib": [
"ES5",
"ES6",
"ESNext",
"ES2022",
"DOM"
],
"module": "ESNext",
"moduleResolution": "Node",
"newLine": "LF",
"noEmit": false,
"noEmitHelpers": true,
"noEmitOnError": true,
"noFallthroughCasesInSwitch": true,
"noImplicitAny": false,
"noImplicitThis": false,
"outDir": "dist/",
"pretty": false,
"removeComments": true,
"resolveJsonModule": true,
"rootDir": ".",
"sourceMap": false,
"strict": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"strictPropertyInitialization": false,
"target": "ESNext",
"useUnknownInCatchVariables": false
},
"exclude": [
"dist",
"node_modules",
"tests",
"**/__tests__/*",
"**/*.test*",
"**/*.spec*",
"**/*deprecate*",
"**/*ignored*"
],
"extends": "./tsconfig.path.json",
"include": [
"src"
],
"ts-node": {
"swc": true
}
}
and tsconfig.path.json
:
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@app/*": [
"src/*"
],
"@common/*": [
"src/core/common/helpers/*"
],
"@config/*": [
"src/config/*"
],
"@core/*": [
"src/core/*"
],
"@dependency/*": [
"src/dependency/*"
],
"@infra/*": [
"src/infra/*"
],
"@rootPath/*": [
"./*"
],
"@ui/*": [
"src/ui/*"
]
},
"rootDir": ".",
"typeRoots": [
"./@types",
"../node_modules/@types"
]
}
}
and in package.json
i installed
{
"@typescript-eslint/eslint-plugin": "~5.59.5",
"@typescript-eslint/parser": "5.59",
"typescript": "~4.9.5
}
What confuses me is:
- This configuration works out of the box in windows. what's wrong?
- it works if it uses absolute path such as
"project": "/home/ijash/company/apps/appName/tsconfig.json"