1

添加

"@typescript-eslint/strict-boolean-expressions": [
    2,
    {
        "ignoreRhs": true,
        "allow-boolean-or-undefined": true
    }
],

我的 eslintrc.json 给了我以下错误错误:.eslintrc.json:规则“@typescript-eslint/strict-boolean-expressions”的配置无效:值 {“ignoreRhs”:true,“allow-boolean-or- undefined":true} 不应该有额外的属性。

提及此规则的选项的正确方法是什么?

4

2 回答 2

2

eslintrc 规则上你可以尝试下面的配置,eslint 将停止通知你。

  "rules": {
    "@typescript-eslint/strict-boolean-expressions": 0
  }

于 2020-11-01T17:35:59.210 回答
-1

此规则在 ESLint 上不存在 allow-boolean-or-undefined,等效的选项是 allowNullable。正确的语法是:

'@typescript-eslint/strict-boolean-expressions': ['error', { allowNullable: true, ignoreRhs: true }],

您可以查看文档以获取规则strict-boolean-expressions 文档

于 2020-04-08T15:15:09.650 回答