首页 > 解决方案 > 禁用 eslint 的主机配置

问题描述

我在角度应用程序中使用 eslint,在执行ng lint时出现以下错误

An unhandled exception occurred: .eslintrc.json#overrides[0]:
        Configuration for rule "@angular-eslint/directive-selector" is invalid:
        Value {"type":"attribute","style":"camelCase","use-host-property-decorator":false} should NOT have additional properties.

尝试从配置中禁用主机,如下所示

.eslintrc

"rules": {
        "@angular-eslint/directive-selector": [
          "error",
          {
            "type": "attribute",
            // "prefix": "app",
            "style": "camelCase",
            "use-host-property-decorator": false
          }
        ],
        "@angular-eslint/component-selector": [
          "error",
          {
            "type": "element",
            "prefix": "app",
            "style": "kebab-case"
          }
        ]
      }

我在指令中使用了主机

@Directive({
  selector: 'th[sortable]',
  host: {
    '[class.asc]': 'direction === "asc"',
    '[class.desc]': 'direction === "desc"',
    '(click)': 'rotate()'
  }
})

标签: javascriptangulareslinteslintrc

解决方案


推荐阅读