【发布时间】:2019-03-14 18:31:10
【问题描述】:
我正在尝试开始检查我的 Angular 项目。使用 Angular 4.x,所以我还有一个 .angular.cli.json 文件,其中包含:
"lint": [
{
"project": "CedarsReport/src/tsconfig.app.json"
},
{
"project": "CedarsReport/src/tsconfig.spec.json"
},
{
"project": "CedarsReport/e2e/tsconfig.e2e.json"
}
],
这个路径下的 tsconfig.app.json 很简单:
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"module": "es2015",
"baseUrl": "",
"types": []
},
"exclude": [
"test.ts",
"**/*.spec.ts"
]
}
但是,当我在父目录(或“ng lint my-app”,其中 my-app 是我的项目名称)中执行“ng lint”时,我只会在项目根目录中收到 test.ts 的错误:
CedarsReport/src/test.ts[16, 13]: Identifier '__karma__' is never reassigned; use 'const' instead of 'let'.
CedarsReport/src/test.ts[17, 13]: Identifier 'require' is never reassigned; use 'const' instead of 'let'.
即使上面显示的 tsconfig.app.json 中明确排除了 test.ts。此外,父目录中的 tsconfig.json(在上面的“扩展”中引用)包含以下内容:
"include": [
"src/app/**/*",
"src/*.ts",
"src/*.html"
],
我想这应该会导致我的所有源代码都被 linted (??),但这似乎也没有发生。
我猜我对如何正确设置“ng lint”有误解,所以它知道我想要删除的源文件在哪里,以及我想要排除的内容。然而documentation for Angular CLI's lint command 是稀疏的。任何指针(甚至是文档)都表示赞赏!
【问题讨论】:
标签: angular angular-cli tslint