2
votes

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!

2
Just run ng lint on the project?R. Richards
@R.Richards Right, I can do that, but I want to run it on specific directories and not the entire project...rustyshackleford
You would think you could use a glob with the --file option, but I can't tell if it really works like that. ng lint --files=src/app/folder/**/*.tsR. Richards
@R.Richards Yep, that works perfectly. I didn't know I was able to use a glob. If you want to make that the answer, I'll accept it. Thanks a bunch!rustyshackleford

2 Answers

4
votes

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

ng lint --files=src/app/folder/**/*.ts
1
votes

After some digging, I found this solution:

ng lint [ Project name ] --files '[ Directory path ]/*.ts'

Change between the brackets with your own options.

You can use [ ** ] for the unknown directory.