Phi*_*ohn 12 typescript tslint angular
我尝试执行以下操作以node_modules
从tslint
. 但他们都没有解决这个问题。
如果是因为我调用node_modules
文件夹的方式,我很困惑。
第一次尝试- 在tsconfig.json
和中添加了以下内容tsconfig-aot.json
"exclude": [
"../node_modules/**/*",
"./node_modules/**/*",
"node_modules",
"node_modules/**/*.ts",
"**/node_modules/**/*",
"**/node_modules/**"
]
Run Code Online (Sandbox Code Playgroud)
第二次尝试- 添加exclude
到每个项目部分.angular-cli.json
"lint": [{
"project": "../../../tsconfig.json",
"exclude": "./node_modules/*" // also tried **/node_modules/**/*
},
{
"project": "../../../tsconfig-aot.json",
"exclude": "./node_modules/*"
}
],
Run Code Online (Sandbox Code Playgroud)
第三次尝试-tslint-cli
使用--exclude
选项执行
tslint --exclude node_modules --project tsconfig-aot.json
tslint --exclude node_modules --project tsconfig.json
Run Code Online (Sandbox Code Playgroud)
还是没有变化。每当我这样做时yarn webpack:build
,我仍然会从 node_modules 收到这些警告。
同样在tsconfig.json
and 中tsconfig-aot.json
,它已经有"skipLibCheck": true
更新
我安装了angular-select2-component
导致错误的 npm 模块。添加了 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
Run Code Online (Sandbox Code Playgroud)
尝试明确指定应从哪个目录开始检查。在我的最后是:
"scripts": {
"lint": "tslint \"src/**/*.ts\"",
},
Run Code Online (Sandbox Code Playgroud)
此解决方案仅适用于您的项目结构良好的情况,即:
package.json
some-other.conf.js
src/here_is_app_code
Run Code Online (Sandbox Code Playgroud)
{
"extends": [
"tslint:recommended"
],
"linterOptions": {
"exclude": [
"node_modules"
]
}
}
Run Code Online (Sandbox Code Playgroud)
更多信息可以在这个 PR 中找到
tslint \"./**/*.ts\" -e \"node_modules\"
Run Code Online (Sandbox Code Playgroud)
-e
是 的缩写--exclude
,随此 PR引入。
归档时间: |
|
查看次数: |
11665 次 |
最近记录: |