如何在Angular CLI中忽略/排除某些文件/目录 [英] How to ignore/exclude some files/directory from linting in angular cli
问题描述
类似于此问题
我正在运行以下命令来整理我的angular2 typeScript代码.
I am running the following command to linting my angular2 typeScript code.
ng lint
它很好地证明了所有的掉毛错误.
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.
I know this can be done with tslint command as follows (Reference Here)
tslint \"src/**/*.ts\" -e \"**/__test__/**\"
但是在角度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
,但是您仍然可以在其
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中忽略/排除某些文件/目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!