为什么 eslint 不允许 @typescript-eslint/consistent-type-imports 规则选项?

huangapple go评论68阅读模式
英文:

Why doesn't eslint allow the rule option @typescript-eslint/consistent-type-imports?

问题

I applied the eslint rule as follows.

module.exports = {
  rules: {
    "@typescript-eslint/consistent-type-imports": [
      "error",
      {
        fixStyle: "inline-type-imports"
      }
    ]
  }
}

After that, I tried to run the fix option using eslint.

eslint --fix --ext js,ts,tsx .

But get error

Oops! Something went wrong! :(

ESLint: 8.26.0

Error: .eslintrc.js:
  Configuration for rule "@typescript-eslint/consistent-type-imports" is invalid:
  Value {"fixStyle":"inline-type-imports"} should NOT have additional properties.

at ConfigValidator.validateRuleOptions (.../node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2027:23)
at .../node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2082:18

It's an option that's also in the actual official document, why doesn't it apply?

my package.json

{
  "devDependencies": {
    "typescript": "4.8.4",
    "eslint": "^8.26.0"
  }
}
英文:

I applied the eslint rule as follows.

module.exports = {
rules: {
 "@typescript-eslint/consistent-type-imports": [
            "error",
            {
                fixStyle: "inline-type-imports"
            }
        ],
}
}

After that, I tried to run the fix option using eslint.

eslint --fix --ext js,ts,tsx .

But get error

Oops! Something went wrong! :(

ESLint: 8.26.0

Error: .eslintrc.js:
        Configuration for rule "@typescript-eslint/consistent-type-imports" is invalid:
        Value {"fixStyle":"inline-type-imports"} should NOT have additional properties.

    at ConfigValidator.validateRuleOptions (.../node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2027:23)
    at .../node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2082:18

It's an option that's also in the actual official document, why doesn't it apply?

my package.json

{
"devDependencies": {
"typescript": "4.8.4"
"eslint": "^8.26.0",
}
}

答案1

得分: 2

这是除了我在问题中提到的软件包版本问题之外的另一个版本问题。

我的解决方案是升级版本 5.41.0 => 5.59.9

{
 "@typescript-eslint/eslint-plugin": "^5.59.9", 
 "@typescript-eslint/parser": "^5.59.9",
}
英文:

This was a version issue of something other than the version issue of the packages I presented in the question.

My solution is upgrade version 5.41.0 => 5.59.9

{
 "@typescript-eslint/eslint-plugin": "^5.59.9", 
 "@typescript-eslint/parser": "^5.59.9",
}

huangapple
  • 本文由 发表于 2023年6月9日 09:43:58
  • 转载请务必保留本文链接:https://go.coder-hub.com/76436690.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定