如何忽略/排除一些文件/目录与角度cli中的linting

Par*_*osh 27 tslint angular-cli angular

此问题类似

我正在运行以下命令来lint我的angular2 typeScript代码.

ng lint
Run Code Online (Sandbox Code Playgroud)

它很好地证明了所有的掉毛错误.

但我希望我的供应商文件夹(假设"src/app/quote/services/generated/**/*")不应该包含在内衬时.

我知道这可以用tslint命令完成,如下所示(参考这里)

tslint \"src/**/*.ts\" -e \"**/__test__/**\"
Run Code Online (Sandbox Code Playgroud)

但在角度cli中,参数是什么?如何从tslint中排除一些文件?

注意:我的Angular Cli版本是:@ angular/cli:1.0.0-rc.0

Pen*_*gyy 39

Angular6 +开始,.angular-cli.json已被替换为angular.json,但您仍然可以在其中添加排除路径lint.

"lint": {
      "builder": "@angular-devkit/build-angular:tslint",
      "options": {
        "tsConfig": [
          "src/tsconfig.app.json",
          "src/tsconfig.spec.json"
        ],
        "exclude": [
          "**/node_modules/**"      // excluded directories
        ]
      }
    }
Run Code Online (Sandbox Code Playgroud)

根据angular-cli 问题#5063,您可以.angular-cli.json像这样添加排除路径:

"lint": [
{
  "project": "src/tsconfig.app.json",
  "exclude": "**/node_modules/**/*"   // the node_modules for example
}]
Run Code Online (Sandbox Code Playgroud)

  • 实际上,我发现我的解决方案是编辑`./src/tsconfig.app.json`下的`exclude`属性,而不是`.angular-cli.json`。 (2认同)

Red*_*ile 12

弄清楚它是一个blob模式..

如果你想要多个文件/目录,只需使用你的数组 .angular-cli.json

"exclude": [
 "**/*whatever.pipe.ts", 
 "**/*whatever_else.component.ts"
]
Run Code Online (Sandbox Code Playgroud)

  • 实际上,我发现我的解决方案是编辑`./src/app/tsconfig.app.json`下的`exclude`属性,而不是`.angular-cli.json`。 (2认同)