【发布时间】:2023-04-03 12:20:01
【问题描述】:
我尝试执行以下操作以从 tslint 中排除 node_modules。
但他们都没有解决这个问题。
如果是因为我调用 node_modules 文件夹的方式,我会感到困惑。
第一次尝试 - 在tsconfig.json 和tsconfig-aot.json 中添加了以下内容
"exclude": [
"../node_modules/**/*",
"./node_modules/**/*",
"node_modules",
"node_modules/**/*.ts",
"**/node_modules/**/*",
"**/node_modules/**"
]
第二次尝试 - 将exclude 添加到.angular-cli.json 中的每个项目部分
"lint": [{
"project": "../../../tsconfig.json",
"exclude": "./node_modules/*" // also tried **/node_modules/**/*
},
{
"project": "../../../tsconfig-aot.json",
"exclude": "./node_modules/*"
}
],
第三次尝试 - 使用 --exclude 选项执行 tslint-cli
tslint --exclude node_modules --project tsconfig-aot.json
tslint --exclude node_modules --project tsconfig.json
仍然没有变化。每当我执行yarn webpack:build 时,我仍然会从 node_modules 收到这些警告。
同样在tsconfig.json和tsconfig-aot.json中,已经有"skipLibCheck": true
更新
我安装了导致错误的 npm 模块 angular-select2-component。添加了 tslint 堆栈跟踪。
WARNING in ./node_modules/angular-select2-component/index.ts
[1, 41]: file should end with a newline
@ ./src/main/webapp/app/home/home.module.ts 13:34-70
@ ./src/main/webapp/app/app.module.ts
@ ./src/main/webapp/app/app.main.ts
WARNING in ./node_modules/angular-select2-component/src/select2.component.ts
[22, 24]: Type boolean trivially inferred from a boolean literal, remove type annotation
[43, 22]: missing whitespace
[44, 40]: missing whitespace
[46, 14]: missing whitespace
[54, 45]: missing whitespace
[67, 14]: missing whitespace
[61, 32]: missing whitespace
[79, 18]: missing whitespace
[59, 51]: " should be '
[54, 33]: == should be ===
[35, 45]: missing whitespace
[44, 11]: missing whitespace
[54, 11]: missing whitespace
[61, 15]: missing whitespace
[30, 1]: Consecutive blank lines are forbidden
[13, 15]: The selector of the component "Select2Component" should be named kebab-case and include dash (https://angular.io/styleguide#style-05-02)
@ ./node_modules/angular-select2-component/index.ts 6:9-43
@ ./src/main/webapp/app/home/home.module.ts
@ ./src/main/webapp/app/app.module.ts
@ ./src/main/webapp/app/app.main.ts
WARNING in ./node_modules/angular-select2-component/src/custom-input.ts
[59, 2]: file should end with a newline
[20, 47]: missing whitespace
@ ./node_modules/angular-select2-component/src/select2.component.ts 25:21-46
@ ./node_modules/angular-select2-component/index.ts
@ ./src/main/webapp/app/home/home.module.ts
@ ./src/main/webapp/app/app.module.ts
@ ./src/main/webapp/app/app.main.ts
【问题讨论】:
-
你能给我们你的 linting 的堆栈跟踪吗?
标签: angular typescript tslint