[英]Using tslint with Angular CLI
我試圖開始整理我的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"
],
我想這應該導致我的所有源代碼都被掉線(??),但這似乎也沒有發生。
我猜想我對如何正確設置'ng lint'有誤解,因為它知道我的源文件在哪里,我想刪除這些文件以及我想排除的文件。 但是,Angular CLI的lint命令的文檔很少。 任何指針(甚至指向文檔)都表示贊賞!
我想tslint也在選擇與test.ts相關的文件
就我而言tsconfig.spec.json
"files": [
"test.ts"
],
"include": [
"**/*.spec.ts",
"**/*.d.ts"
]
tsconfig.app.json
"exclude": ["test.ts", "**/*.spec.ts"]
和tsconfig.e2d.json
在這個文件中沒有什么特別的地方
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.