eslint configuration for angular
To ensure a high and consistent code quality for .ts, .js, .html
we use eslint.
This eslint extends the ruling conventions from angular linting and prettier. Therefore, you must have prettier installed in your project.
To check the rules see .eslintrc.json
. If for some reason a rule doesn't fit your project, you can override the specific rule in the .eslintrc.json
(as demonstrated below) of your project.
Installing @medienwerft/eslint-config-angular package
npm install @medienwerft/eslint-config-angular prettier --save-dev
Create config
1- run ng add @angular-eslint/schematics
to add linting to your angular project and create the .eslintrc.json
automatically
2- add the following to your .eslintrc.json
file:
{
"extends": ["@medienwerft/eslint-config-angular/.eslintrc"]
}
Use
run lint over the whole project:
ng lint
run and fix code:
ng lint --fix
adding eslint to lintstagedrc
{
"*{.ts,.js,.html}": "eslint --fix",
... other lint staged commands,
}