“ parserOptions.project”已为@ typescript-eslint / parser设置
我用-template typescript
我删除了 template
目录,它是样板的一部分。
I deleted the template
directory which came as part of the boilerplate.
然后我继续添加ESLint:
I then proceeded to add ESLint:
module.exports = {
parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint"],
extends: ["airbnb-typescript-prettier"]
};
但是,当我打开 babel.config.js
时,我出现此错误
However, when I open babel.config.js
, I get this error
解析错误: parserOptions.project已为@ typescript-eslint / parser设置。
文件与您的项目配置不匹配:/Users/Dan/site/babel.config.js
。
该文件必须至少包含在所提供的至少一个项目中。eslint
Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser. The file does not match your project config:
/Users/Dan/site/babel.config.js
. The file must be included in at least one of the projects provided.eslint
您可以创建一个单独的TypeScript配置文件( tsconfig.eslint.json
),用于 eslint
配置。该文件扩展了 tsconfig
的配置,并为必须删除的文件设置了 include
键。
You can create a separate TypeScript config file (tsconfig.eslint.json
) intended for eslint
configuration. That file extends tsconfig
configuration and setups include
key for files that have to be linted.
.eslint.js
:
// ...
parserOptions: {
// ...
project: "./tsconfig.eslint.json",
// ...
},
// ...
tsconfig.eslint.json
:
{
"extends": "./tsconfig.json",
"include": [
// ...
"babel.config.js"
]
}
或者如果要忽略它,可以将其放入 .eslintignore
。
Or if you want to ignore it, you can put it into .eslintignore
.
.eslintignore
:
// ...
babel.config.js