“parserOptions.project 已为 @typescript-eslint/parser 设置”错误 — 如何修复?
你好!我是 TypeScript 新手,正在尝试在我的项目中配置 ESLint。我使用了 @typescript-eslint/parser 和 @typescript-eslint/eslint-plugin。但在运行 ESLint 时遇到了一个奇怪的错误:
```
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.
```
这是我的 .eslintrc.json:
```json
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json"
},
"plugins": ["@typescript-eslint"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
]
}
```
以及 tsconfig.json:
```json
{
"compilerOptions": {
"target": "ES2020",
"module": "commonjs",
"strict": true,
"esModuleInterop": true,
"outDir": "./dist"
},
"include": ["src/**/*"],
"exclude": ["node_modules"]
}
```
文件 src/index.ts 存在且包含