Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to ignore/exclude some files/directory from linting in angular cli

Similar to this question

I am running the following command to linting my angular2 typeScript code.

ng lint 

It is proving all the linting error nicely.

But I want my vendor folder (let say "src/app/quote/services/generated/**/*") should not get included at the time of lining.

I know this can be done with tslint command as follows (Reference Here)

tslint \"src/**/*.ts\" -e \"**/__test__/**\" 

But in angular cli what will be the parameter? How to exclude some files from tslint?

Note: My Angular Cli version is : @angular/cli: 1.0.0-rc.0

like image 210
Partha Sarathi Ghosh Avatar asked Feb 28 '17 11:02

Partha Sarathi Ghosh


People also ask

What is TS lint in angular?

TSLint is an extensible static analysis tool that checks TypeScript code for readability, maintainability, and functionality errors. It is widely supported across modern editors & build systems and can be customized with your own lint rules, configurations, and formatters.


Video Answer


2 Answers

From Angular6+, .angular-cli.json has been replaced by angular.json, but you can still add the exclude path in its lint part.

"lint": {       "builder": "@angular-devkit/build-angular:tslint",       "options": {         "tsConfig": [           "src/tsconfig.app.json",           "src/tsconfig.spec.json"         ],         "exclude": [           "**/node_modules/**"      // excluded directories         ]       }     } 

According to the angular-cli issue#5063, you can add the exclude path in .angular-cli.json like this:

"lint": [ {   "project": "src/tsconfig.app.json",   "exclude": "**/node_modules/**/*"   // the node_modules for example }] 
like image 195
Pengyy Avatar answered Sep 27 '22 17:09

Pengyy


Figured out it HAS to be a blob pattern..

If you want multiple files/directories just use an array in your .angular-cli.json

"exclude": [  "**/*whatever.pipe.ts",   "**/*whatever_else.component.ts" ] 
like image 21
RedRoosterMobile Avatar answered Sep 27 '22 18:09

RedRoosterMobile