Blog>
Snippets

Utilizing Angular CLI's Linting and Formatting

Demonstrate how to use Angular CLI's built-in linting and formatting tools for clean code.
ng lint
Run the Angular CLI's linting tool to check for code quality issues. This command will analyze the project based on the ESLint configuration.
ng lint --fix
Run the linting tool, but also automatically fix linting errors where possible. This is useful to clean up simple issues like whitespace, missing semicolons and more without manual intervention.
ng lint --format stylish
Run the linting tool using a specific formatter. Here, 'stylish' is used to format the output of the linting results in a more visually appealing way.
ng lint --force
Run the linting process and receive an exit code of 0 even if lint errors are found. This can be useful in continuous integration systems where you may want to proceed despite linting warnings or errors.
// package.json
...
Configure your linting rules in the package.json under the eslintConfig key, or in a dedicated .eslintrc.json file. Custom rules can be added and existing rules can be modified to suit your project's coding standards.