【问题标题】:Data path "" should have required property 'lintFilePatterns'数据路径“”应该具有必需的属性“lintFilePatterns”
【发布时间】:2021-06-19 23:02:28
【问题描述】:

运行 ng lint 时,我的 angular 10 项目的 Linting 失败 node --max_old_space_size=8192 node_modules/@angular/cli/bin/ng lint

它失败了,返回码 1 并说:

Schema validation failed with the following errors:
  Data path "" should have required property 'lintFilePatterns'.

它仍然会检查文件,并将警告和错误打印到控制台。但我想在某个时候将其集成到我们的 CI 中。

下面是我的 angular.json lint 配置以及我的 eslint 配置

"lint": {
      "builder": "@angular-eslint/builder:lint",
      "options": {
        "lintFilePatterns": ["src/**/*.ts", "src/**/*.html"]
      },
      "configurations": {
        "dev": {
          "builder": "@angular-eslint/builder:lint",
          "lintFilePatterns": ["src/**/*.ts", "src/**/*.html"]
        }
      }
    }

还有 eslintrc.js

module.exports = {
"root": true,
"overrides": [
  {
    "files": ["*.ts"],
    "parserOptions": {
        "project": [
          "src/tsconfig.app.json",
          "src/tsconfig.spec.json",
          "e2e/tsconfig.json"
        ],
        "createDefaultProgram": true,
        "tsconfigRootDir": __dirname,
      },
    "extends": [
      "plugin:@angular-eslint/recommended",
      // This is required if you use inline templates in Components
      "plugin:@angular-eslint/template/process-inline-templates",
      'plugin:@typescript-eslint/recommended',
    ],
    "rules": {
      /**
       * Any TypeScript source code (NOT TEMPLATE) related rules you wish to use/reconfigure over and above the
       * recommended set provided by the @angular-eslint project would go here.
       */

      "@angular-eslint/directive-selector": [
        "error",
        { "type": "attribute", "prefix": "app", "style": "camelCase" }
      ],
      "@angular-eslint/component-selector": [
        "error",
        { "type": "element", "prefix": "app", "style": "kebab-case" }
      ]
    }
  },
  {
    "files": ["*.html"],
    "extends": ["plugin:@angular-eslint/template/recommended"],
    "rules": {
      /**
       * Any template/HTML related rules you wish to use/reconfigure over and above the
       * recommended set provided by the @angular-eslint project would go here.
       */
    }
  }
]

}

感谢任何帮助

【问题讨论】:

    标签: angular eslint lint


    【解决方案1】:

    尝试用

    替换或编辑 angular.json 文件中的“lint”块
    "lint": {
      "builder": "@angular-eslint/builder:lint",
      "options": {
        "eslintConfig": ".eslintrc.json",
        "lintFilePatterns": ["**/*.spec.ts", "**/*.ts"]
      }
    }
    

    或者你的 eslint 配置文件存储在哪里。

    【讨论】:

    • 我厌倦了这个,但仍然没有运气。同样的错误。据我所知,它似乎找不到 lint 路径。
    猜你喜欢
    • 1970-01-01
    • 2021-11-17
    • 1970-01-01
    • 2021-01-28
    • 1970-01-01
    • 2020-07-11
    • 2019-10-25
    • 2020-12-10
    • 2021-03-30
    相关资源
    最近更新 更多