我想使用ignoreParameters选项设置为false的this rule。我的eslint是使用.eslintrc.json文件配置的,我无法找到如何在此文件中为规则设置选项。我已经查看了文档和谷歌,我查看了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
}
]
}
}谢谢你的帮助。
发布于 2020-01-15 17:42:43
因此,我尝试的所有内容实际上都使用了正确的语法(我仍然会让这个问题继续存在,因为我没有找到带有选项的.eslinrc.json文件示例的清晰资源,这导致我在错误的位置搜索问题)。
我的问题是我试图更改规则no-inferrable-types,并且我在我的.eslintrc.json文件no-inferable-types中编写了规则(少了一个"r“)。
因此,我的(工作) .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,
"@typescript-eslint/no-inferrable-types": [
2,
{
"ignoreParameters": true
}
]
}
}https://stackoverflow.com/questions/59737848
复制相似问题