I tried to perform the following to exclude node_modules
from tslint
.
But none of them resolved the issue.
I am confused if it is because of the way I call the node_modules
folder.
First attempt - Added the following in tsconfig.json
and tsconfig-aot.json
"exclude": [
"../node_modules/**/*",
"./node_modules/**/*",
"node_modules",
"node_modules/**/*.ts",
"**/node_modules/**/*",
"**/node_modules/**"
]
Second attempt - Added exclude
to each project section in .angular-cli.json
"lint": [{
"project": "../../../tsconfig.json",
"exclude": "./node_modules/*" // also tried **/node_modules/**/*
},
{
"project": "../../../tsconfig-aot.json",
"exclude": "./node_modules/*"
}
],
Third attempt - Executed tslint-cli
with --exclude
option
tslint --exclude node_modules --project tsconfig-aot.json
tslint --exclude node_modules --project tsconfig.json
Still no change. Whenever I do yarn webpack:build
, I am still getting these warnings from node_modules.
Also in tsconfig.json
and tsconfig-aot.json
, it already has "skipLibCheck": true
UPDATE
I installed the npm module angular-select2-component
which was causing the error. Added the tslint stacktrace.
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
Try to specify explicitly from which directory should start checking. On my end it is:
"scripts": {
"lint": "tslint \"src/**/*.ts\"",
},
This solution works only if your project is well structured ie:
package.json
some-other.conf.js
src/here_is_app_code
{
"extends": [
"tslint:recommended"
],
"linterOptions": {
"exclude": [
"node_modules"
]
}
}
More information can be found in this PR
tslint \"./**/*.ts\" -e \"node_modules\"
-e
is an abbreviation for --exclude
, introduced with this PR.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With