gpt4 book ai didi

typescript - 在 typescript 中使用 eslint 解析错误,lint 没有得到 parserOptions 配置

转载 作者:行者123 更新时间:2023-12-04 09:35:32 26 4
gpt4 key购买 nike

我不知道为什么我会收到这个错误

You have used a rule which requires parserServices to be generated. You must therefore provide a value for the "parserOptions.project"
这是我的配置
配置文件
{
"compilerOptions": {
"target": "es6",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"jsx": "react",
"rootDir": "src",
"baseUrl": "src",
"paths": {
"@/*": [
"*"
]
},
"allowJs": true,
"resolveJsonModule": true
},
"include": [
"src"
],
"exclude": [
"src/main/test/cypress"
]
}
.eslintrc.json
{
"extends": "standard-with-typescript",
"parserOptions": {
"projects": "./tsconfig.json"
},
"rules": {
"@typescript-eslint/consistent-type-definitons": "off",
"@typescript-eslint/strict-boolean-expressions": "off"
}
}
我也有这个 AccountModel 类
export type AccountModel = {
accessToken: string
}
哪个 vscode 指出一个错误,说“解析错误:类型预期”我缺少什么?

最佳答案

转到您的 eslintrc.json 并尝试以下配置:

{
"extends": [
"standard-with-typescript",
"plugin:@typescript-eslint/recommended"
],
"parserOptions": {
"project": "./tsconfig.json",
"ecmaVersion": 12,
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
],
"rules": {
"import/extensions": 1,
"import/no-named-as-default": 0,
"@typescript-eslint/strict-boolean-expressions": 0,
"@typescript-eslint/explicit-module-boundary-types": 0
}
}

关于typescript - 在 typescript 中使用 eslint 解析错误,lint 没有得到 parserOptions 配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62612742/

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