43

I am using "ng lint" command from the latest 'angular cli'.

Is it possible to run this command on only one typescript file instead of running on all the typescript files in the entire project ?

Thanks Adam

Adam
  • 1,221
  • 4
  • 13
  • 27

4 Answers4

26

For 10.1.7+ versions of angular cli use --lint-file-patterns

ng lint --lint-file-patterns src/app/app.component.ts
Manu Janardhanan
  • 600
  • 4
  • 10
23

As of Angular CLI version 8, you can lint a single file with

ng lint --files src/app/app.component.ts

Eonasdan
  • 7,563
  • 8
  • 55
  • 82
1

An easy workaround: ng lint | grep nameofyourfile?

millerf
  • 686
  • 1
  • 8
  • 16
-1

I know I am late to the party but someone else could benefit from this. We face the same issue and to solve this I have created a package

https://www.npmjs.com/package/ng-lintone-cli

It is fairly simple package - you just need to pass command
lintone file name <file-name>

and it will display lint error associated to that file

Sandeep Chikhale
  • 1,505
  • 2
  • 21
  • 36