[英]How to exclude all files under a directory in lint using angular CLI?
We can exclude node_modules in this way. 我们可以用这种方式排除node_modules。
"lint": [
{
"project": "src/main/webapp/app/file.json",
"exclude": "**/node_modules/**"
}
]
But how to exclude all files under a directory? 但是如何排除目录下的所有文件?
I tried below way. 我尝试了以下方式。 It is not working
它不起作用
"exclude": [
"**/*whatever.pipe.ts",
"**/*whatever_else.component.ts"
]
So this is my current path for the directory "src/main/assets/js/ngx-typeahead"
所以这是我目前的路径
"src/main/assets/js/ngx-typeahead"
I have to exclude all the files under this directory from linting. 我必须从linting中排除此目录下的所有文件。
How can i achieve that? 我怎样才能实现这一目标?
Any suggestions would be appreciated. 任何建议,将不胜感激。
You can do that by modifying your lint
line inside tsconfig.json
: 你可以通过修改
tsconfig.json
的lint
行来做到这tsconfig.json
:
"lint": [
{
"exclude": [
"src/main/assets/js/ngx-typeahead/**/*.ts",
]
}
]
This PATH/**/*.ts
means all files under this path and any subdirectory inside with the extension .ts
此
PATH/**/*.ts
.ts
表示此路径下的所有文件以及扩展名为.ts
内部任何子目录
And I believe "src/main/assets/js/ngx-typeahead/*
will exclude all files under this path 我相信
"src/main/assets/js/ngx-typeahead/*
将排除此路径下的所有文件
Edit: Another option is to use tslint.json
: 编辑:另一个选择是使用
tslint.json
:
{
"extends": "tslint:recommended",
......
"linterOptions": {
"exclude": [
"src/main/assets/js/ngx-typeahead/**/*.ts",
]
}
}
For more: https://palantir.github.io/tslint/usage/configuration/ 更多信息: https : //palantir.github.io/tslint/usage/configuration/
Edit 2: I found this issue link for angular-cli specific linting, by providing what exactly you want to lint instead of linting the project with excludes! 编辑2:我发现了这个问题链接为angular-cli特定linting,通过提供你想要lint的确切内容,而不是用exlude linting项目!
inside .angular-cli.json
provide lint
option: 在
.angular-cli.json
提供lint
选项:
"lint": [{
"files": "src/**/*.ts",
"project": "src/tsconfig.app.json"
},
{
"files": "src/**/*.ts",
"project": "src/tsconfig.spec.json"
},
{
"files": "src/**/*.ts",
"project": "e2e/tsconfig.e2e.json"
}
]
Finally this works for me 最后这对我有用
"lint": [
{
"project": "src/main/webapp/app/tsconfig.app.json",
"exclude": ["**/node_modules/**", "**/src/main/assets/js/ngx-typeahead**"]
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.