我已经提到了在掉毛过程中需要排除的文件,方法是在angular.json中添加“掉毛”部分,但它似乎仍然掉毛了那些文件。因此,当我运行npm run lint命令时,最初会获得通过linting消息传递的所有文件,并突然收到以下消息,但是如果我在tsconfig文件中注释了include语句,则该传递将通过。让我知道是否可以
C:/Development/xxx/src/app/api/generated/testData.ts:2:1
ERROR: 2:1 no-trailing-whitespace trailing whitespace
ERROR: 3:1 indent space indentation expected
ERROR: 4:1 indent space indentation expected
ERROR: 5:1 indent space indentation expected
ERROR: 8:1 no-trailing-whitespace trailing whitespace
ERROR: 9:1 no-consecutive-blank-lines Exceeds the 2 allowed consecutive blank lines
ERROR: 11:1 no-trailing-whitespace trailing whitespace
如果您在下面看到,我已经提到了“ / src / app / api / / *”,尽管它仍然尝试清理/ src / app / api /文件夹下的文件。
angular.json中的皮棉部分
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"src/tsconfig.app.json",
"src/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**/*",
"**/src/app/api/**/*",
"**/src/polyfills.ts"
]
}
完整的angular.json文件
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"app": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"prefix": "irm",
"schematics": {},
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "../wwwroot",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.app.json",
"assets": [
"src/assets",
"src/favicon.ico",
"src/favicon.png",
"src/web.config",
{
"glob": "**/*",
"input": "./node_modules/@wtw/platform/assets",
"output": "./assets"
},
{
"glob": "**/*",
"input": "./assets",
"output": "./assets"
}
],
"styles": [
"../IRM.ClientSide/node_modules/@wtw/platform/styling/platform.scss"
],
"scripts": [
"../IRM.ClientSide/node_modules/jsoneditor/dist/jsoneditor.js"
]
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "environments/environment.ts",
"with": "environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": false,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "app:build"
},
"configurations": {
"production": {
"browserTarget": "app:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "app:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.spec.json",
"karmaConfig": "./karma.config.js",
"styles": [],
"scripts": [],
"assets": []
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"src/tsconfig.app.json",
"src/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**/*",
"**/src/app/api/**/*",
"**/src/polyfills.ts"
]
}
}
}
},
"pdf": {
"root": "src",
"sourceRoot": "src",
"projectType": "application",
"prefix": "irm",
"schematics": {},
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "../pdf",
"index": "pdf.html",
"main": "pdf.ts",
"polyfills": "polyfills.ts",
"tsConfig": "tsconfig.app.json",
"assets": [
"assets",
"favicon.ico",
{
"glob": "**/*",
"input": "../node_modules/@wtw/platform/assets",
"output": "./assets"
}
],
"styles": [
"./styles.scss"
],
"scripts": []
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "environments/environment.ts",
"with": "environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": false,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "app:build"
},
"configurations": {
"production": {
"browserTarget": "app:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "app:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.spec.json",
"karmaConfig": "./karma.config.js",
"styles": [],
"scripts": [],
"assets": []
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"src/tsconfig.app.json",
"src/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**/*",
"**/src/app/api/**/*",
"**/src/polyfills.ts"
]
}
}
}
},
"app-e2e": {
"root": "e2e/",
"projectType": "application",
"architect": {
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "e2e/protractor.conf.js",
"devServerTarget": "app:serve"
},
"configurations": {
"production": {
"devServerTarget": "app:serve:production"
}
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": "e2e/tsconfig.e2e.json",
"exclude": [
"**/node_modules/**"
]
}
}
}
}
},
"defaultProject": "app"
}
tsconfig.app.json
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"baseUrl": "./",
"module": "es2015",
"types": []
},
"exclude": [
"**/*.spec.ts",
"**/*.stub.ts",
"test/**/*.ts"
]
}
tsconfig.spec.json
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/spec",
"baseUrl": "./",
"module": "commonjs",
"target": "es5",
"types": [
"jasmine",
"node"
]
},
"files": [
"test.ts"
]
}
tsconfig
{
"compileOnSave": false,
"compilerOptions": {
"outDir": "./dist/out-tsc",
"baseUrl": "src",
"sourceMap": true,
"declaration": false,
"module": "es2015",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2017",
"dom"
]
}
// ,
// "include": [
// "./src/**/*",
// "./node_modules/@wtw/**/*",
// "./node_modules/@types/**/*"
// ]
}
答案 0 :(得分:0)
从tslint v5.8.0开始,您现在可以忽略tslint.json
文件中的文件。只需将其添加到您的顶级tslint.json
文件中即可:
"linterOptions": {
"exclude": ["src/app/api/**/*"]
}
有关更多信息,请参考原始的PR。