Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Having trouble running ng lint on a directory

I'm attempting to use the linter that comes with Angular 8, but I've neglected TSLint errors for a while. I'm hoping to slowly clean up the errors, and I'm searching for a way to run the linter on entire directories, some of which may have multiple subdirectories.

I've looked at the Angular documentation for ng lint, but I'm not finding anything helpful (or I may be overlooking something). What I thought I was looking for was the --files flag, but I must be doing something wrong, because when I run ng lint --files, I can only get it to work with a single file, and not an entire directory.

For example, using ng lint --files src/app/+register/registration.component.ts works perfectly.

Does anybody have any thoughts on this? I'd love some help.

Thanks in advance!

like image 529
rustyshackleford Avatar asked Oct 22 '25 06:10

rustyshackleford


2 Answers

For those like me who visit this question some years later with a newer Angular version:

ng lint --lint-file-patterns=src/app/your/path/**/*.ts

tested on Angular 14

like image 70
slim Avatar answered Oct 23 '25 21:10

slim


You can use a glob, or wildcard, to get the functionality you need. Example below.

ng lint --files=src/app/folder/**/*.ts
like image 39
R. Richards Avatar answered Oct 23 '25 22:10

R. Richards



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!