首页 > 解决方案 > eslint 未检测到角度组件 html nx.dev 中缺少的属性或函数

问题描述

以下template.component.html函数copyTemplate()未定义,但 eslint 未在控制台中显示错误。

<button type="button" (click)="copyTemplate(item.data)" class="btn btn-sm btn-simple-primary ml-2">
   {{ 'words.make_copy' | flowTranslate:null:$flow.getTranslateData() }}
</button>

我正在使用NX.dev带有单声道存储库的工作区

.eslintrc.json在应用程序/应用程序中

{
  "extends": ["../../.eslintrc.json"],
  "ignorePatterns": ["!**/*"],
  "overrides": [
    {
      "files": ["*.ts"],
      "extends": [
        "plugin:@nrwl/nx/angular",
        "plugin:@angular-eslint/template/process-inline-templates"
      ],
      "parserOptions": { "project": ["libs/interfaces/tsconfig.*?.json"] },
      "rules": {
        "@angular-eslint/directive-selector": [
          "error",
          { "type": "attribute", "prefix": "naologic", "style": "camelCase" }
        ],
        "@angular-eslint/component-selector": [
          "error",
          { "type": "element", "prefix": "naologic", "style": "kebab-case" }
        ]
      }
    },
    {
      "files": ["*.html"],
      "extends": ["plugin:@nrwl/nx/angular-template"],
      "rules": {}
    }
  ]
}

.eslintrc.json在项目根目录

{
  "root": true,
  "ignorePatterns": ["**/*"],
  "plugins": ["@nrwl/nx"],
  "overrides": [
    {
      "files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
      "rules": {
        "@nrwl/nx/enforce-module-boundaries": [
          "error",
          {
            "enforceBuildableLibDependency": true,
            "allow": [],
            "depConstraints": [
              { "sourceTag": "*", "onlyDependOnLibsWithTags": ["*"] }
            ]
          }
        ],
        "@angular-eslint/max-len": "off"
      }
    },
    {
      "files": ["*.ts", "*.tsx"],
      "extends": ["plugin:@nrwl/nx/typescript"],
      "rules": {
        "max-len": 0,
        "no-empty-function": "off"
      }
    },
    {
      "files": ["*.js", "*.jsx"],
      "extends": ["plugin:@nrwl/nx/javascript"],
      "rules": {
        "@angular-eslint/max-len": "off",
        "max-len": "off"
      }
    }
  ]
}

标签: angulareslintangular-componentseslintrc

解决方案


推荐阅读