【发布时间】:2020-01-15 17:42:42
【问题描述】:
我想使用 this rule 并将 ignoreParameters 选项设置为 false。我的 eslint 配置了 .eslintrc.json 文件,我无法找到如何在此文件中设置规则的选项。我查看了文档并在 Google 上搜索,并查看了 this question,但我找不到如何使用 eslint 和 .eslintrc.json 文件为规则设置选项的示例。
在我尝试添加此规则之前,这是我的.eslintrc.json 文件(已应用该规则,但使用默认选项而不是我想要的选项):
{
"parser": "@typescript-eslint/parser",
"extends": [
"react-app",
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier/@typescript-eslint",
"plugin:prettier/recommended"
],
"rules": {
"@typescript-eslint/explicit-function-return-type": 0,
"@typescript-eslint/no-explicit-any": 0,
"no-return-await": 2,
"curly": 2
}
}
这是我尝试过的,总是导致规则不再被应用(错误Definition for rule '@typescript-eslint/no-inferable-types' was not found @typescript-eslint/no-inferable-types):
{
"parser": "@typescript-eslint/parser",
"extends": [
"react-app",
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier/@typescript-eslint",
"plugin:prettier/recommended"
],
"rules": {
"@typescript-eslint/explicit-function-return-type": 0,
"@typescript-eslint/no-explicit-any": 0,
"no-return-await": 2,
"curly": 2,
"@typescript-eslint/no-inferable-types": [
"error",
{
"ignoreParameters": true
}
]
}
}
或:
{
"parser": "@typescript-eslint/parser",
"extends": [
"react-app",
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier/@typescript-eslint",
"plugin:prettier/recommended"
],
"rules": {
"@typescript-eslint/explicit-function-return-type": 0,
"@typescript-eslint/no-explicit-any": 0,
"no-return-await": 2,
"curly": 2,
"@typescript-eslint/no-inferable-types": [
2,
{
"ignoreParameters": true,
"ignoreProperties": false
}
]
}
}
感谢您的帮助。
【问题讨论】:
标签: typescript tslint