ng lint command - How can I execute it on only one

2020-03-01 10:20发布

问题:

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

回答1:

An easy workaround: ng lint | grep nameofyourfile?



回答2:

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



回答3:

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

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