【问题标题】:Cannot find "lint" target for the specified project OR Data path "" must have required property 'lintFilePatterns'找不到指定项目的“lint”目标或数据路径“”必须具有必需的属性“lintFilePatterns”
【发布时间】:2021-11-17 13:01:43
【问题描述】:

根据this tutorial 将我的项目结构更改为 Angular 中的 monorepo 结构后,我遇到了许多配置错误,经过大量故障排除后我设法解决了这些错误。

完整的错误读取

Cannot find "lint" target for the specified project.

You should add a package that implements linting capabilities

这个错误的变体

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

这两个错误都可以通过正确配置angular.json 来修复。

在下面找到修复的详细信息

【问题讨论】:

    标签: angular eslint monorepo


    【解决方案1】:

    可以使用以下命令自动添加所需的配置:

    ng add @angular-eslint/schematics
    

    来自Angular ESLint README

    【讨论】:

      【解决方案2】:

      转到angular.json -> <your-projects-root-directory> -> <your-project-name> -> architect并添加或修改

      "lint": {
                "builder": "@angular-eslint/builder:lint",
                "options": {
                  "lintFilePatterns": [
                    "<your-projects-root-directory>/<your-project-name>/src/**/*.ts",
                    "<your-projects-root-directory>/<your-project-name>/src/**/*.html"
                  ]
                }
              },
      

      这告诉 ng lint 命令在各个项目(构建器)中使用哪个 linter 以及要 lint(lintFilePatterns)哪个文件。

      您的项目根目录通常命名为projects。 例如,如果您使用 tslint,您可能必须用另一个 linter 替换 "builder" 属性。详情请见您的package.json

      请记住为angular.json 中定义的所有项目设置此项。

      【讨论】:

        猜你喜欢
        • 2021-06-19
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-06-17
        • 1970-01-01
        • 2015-02-09
        • 2019-03-25
        • 1970-01-01
        相关资源
        最近更新 更多