【发布时间】:2021-12-07 09:37:00
【问题描述】:
我遇到了以下两个错误
.../src/index.ts
0:0 error Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser.
The file does not match your project config: src/index.ts.
The file must be included in at least one of the projects provided
.../src/loaders/index.ts
0:0 error Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser.
The file does not match your project config: src/loaders/index.ts.
The file must be included in at least one of the projects provided
我的项目应该用作库,包含一个 src 和一个测试文件夹。
src/index.ts 是我的入口文件,src/loaders/index.ts 是通过节点样式模块解析导入的,即import * from './loaders'。
这是我的.eslintrc
{
"parser": "@typescript-eslint/parser",
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:jest/style",
"plugin:jest/recommended",
"prettier"
],
"plugins": ["@typescript-eslint"],
"parserOptions": {
"project": "./tsconfig.eslint.json"
},
"root": true,
"rules": {
...
}
}
这是我的 tsconfigs
tsconfig.json
{
"compilerOptions": {
"target": "es2020",
"module": "commonjs",
"allowJs": true,
"checkJs": true,
"sourceMap": true,
"outDir": "./dist",
"strict": true,
"noImplicitAny": true,
"moduleResolution": "node",
"isolatedModules": true,
"baseUrl": ".",
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true
},
"include": ["src/**/*"]
}
和tsconfig.eslint.json
{
"extends": "./tsconfig.json",
"include": [
"tests/**/*"
]
}
【问题讨论】:
-
我目前的临时修复是添加一个包含语句
"include": [ "tests/**/*", "**/index.ts" ]
标签: typescript eslint typescript-eslint