VSCode中TypeScript ESLint解析错误:Linux Mint下相对路径配置失效
TypeScript ESLint解析错误:TSConfig未包含当前文件(Linux Mint环境)
在Linux Mint 21.1 Cinnamon系统的VSCode中使用TypeScript ESLint时,遭遇解析错误,提示配置的TSConfig未包含当前文件。已安装Prettier Eslint、ESLint插件,通过NVM安装了Node.js v18.17.0。尝试过Stack Overflow上的多种解决方案,但均无效果。当前eslintrc的parserOptions.project配置为相对路径./tsconfig.json,但只有使用绝对路径(如/home/ijash/company/apps/appName/tsconfig.json)时才生效,而相同配置在Windows系统中可正常运行。
相关配置文件
eslintrc中的parserOptions配置
"parserOptions": { "ecmaVersion": "latest", "project": ["./tsconfig.json"], "sourceType": "module", "tsconfigRootDir": "." },
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 } }
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" ] } }
package.json相关依赖
{ "@typescript-eslint/eslint-plugin": "~5.59.5", "@typescript-eslint/parser": "5.59", "typescript": "~4.9.5" }
内容的提问来源于stack exchange,提问作者Jastria Rahmat
相关产品推荐
相关产品推荐

