Angular-CLI Serve with Lint Watch


Is there any way to run ng lint while watching for file changes during ng serve? To encourage best practices according to the Angular 2 Style Guide our CI tool runs ng lint during the build process and it isn't always a developers first thought to run lint before submitting a pull request.

Is it possible to customize what ng serve does or has anyone figured out a way to include running lint as part of the recompilation process? If not, I'd also be interested in knowing whether others have any opinions on whether this is a good idea or not and why.

By : pumakuma


Yeah its possible and we are using lint with our development process. Here is an excellent seed project which is shipped with lint support.

Angular2 seed project with lint support

This project has amazing community support and follows best practices. Right now it supports lint in prod build. Its has excellent gulp tasks, so you can tailor them according to your needs.

Gulp tasks: tslint and csslint

These are two gulp tasks for tslint and csslint. You can include them in your dev build

Main gulpfile

This is the part of gulpfile which takes care of dev build, so here you can include lint tasks. As you can see that dev build has lint tasks but they are commented out. The prod build has active support for lint. But you can always playaround and tailor it according to your needs.

By : hhsadiq

This video can help you solving your question :)
By: admin