如何从 angular cli 的 linting 中忽略/排除某些文件/目录 [英] How to ignore/exclude some files/directory from linting in angular cli

查看:30
本文介绍了如何从 angular cli 的 linting 中忽略/排除某些文件/目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

类似于这个问题

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

I am running the following command to linting my angular2 typeScript code.

ng lint

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

It is proving all the linting error nicely.

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

But I want my vendor folder (let say "src/app/quote/services/generated/**/*") should not get included at the time of lining.

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

I know this can be done with tslint command as follows (Reference Here)

tslint \"src/**/*.ts\" -e \"**/__test__/**\"

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

But in angular cli what will be the parameter? How to exclude some files from tslint?

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

Note: My Angular Cli version is : @angular/cli: 1.0.0-rc.0

推荐答案

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

From Angular6+, .angular-cli.json has been replaced by angular.json, but you can still add the exclude path in its lint part.

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

<小时>

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


According to the angular-cli issue#5063, you can add the exclude path in .angular-cli.json like this:

"lint": [
{
  "project": "src/tsconfig.app.json",
  "exclude": "**/node_modules/**/*"   // the node_modules for example
}]

这篇关于如何从 angular cli 的 linting 中忽略/排除某些文件/目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆