gpt4 book ai didi

typescript - 已为@typescript-eslint/parser 设置了 "parserOptions.project"

转载 作者:行者123 更新时间:2023-12-03 16:55:25 26 4
gpt4 key购买 nike

我用 --template typescript 创建了一个新的 React Native 项目
我删除了 template作为样板的一部分出现的目录。
然后我继续添加 ESLint:

module.exports = {
parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint"],
extends: ["airbnb-typescript-prettier"]
};
但是,当我打开 babel.config.js ,我收到这个错误

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必须检查的文件的键。
.eslint.js :

// ...
parserOptions: {
// ...
project: "./tsconfig.eslint.json",
// ...
},
// ...
tsconfig.eslint.json :
{
"extends": "./tsconfig.json",
"include": [
// ...
"babel.config.js"
]
}

或者如果你想忽略它,你可以把它放进 .eslintignore .
.eslintignore :
// ...
babel.config.js

关于typescript - 已为@typescript-eslint/parser 设置了 "parserOptions.project",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58510287/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com