【问题标题】:@typescript-eslint/strict-boolean-expressions lint rule@typescript-eslint/strict-boolean-expressions lint 规则
【发布时间】:2020-01-09 19:34:14
【问题描述】:

添加

"@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} 不应具有其他属性。

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

【问题讨论】:

    标签: eslint typescript-eslint


    【解决方案1】:

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

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

    【讨论】:

      【解决方案2】:

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

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

      您可以查看文档中的规则strict-boolean-expressions documentation

      【讨论】:

        猜你喜欢
        • 2021-03-04
        • 2020-04-09
        • 2021-04-14
        • 2019-11-10
        • 1970-01-01
        • 2020-10-01
        • 2020-11-10
        • 2021-11-21
        • 2019-09-04
        相关资源
        最近更新 更多