eslint-config for Angular projects
- get the package from npm
$ npm install @ng-all/eslint-config -D
- just extends it in your eslint config file eg.
.eslintrc.json
{
// ...
"extends": [
// ...
"@ng-all"
// ...
]
// ...
}
- linting
$ npx eslint ./ --ext .ts --ext .js --ext .html
- ng lint with
@angular-eslint/builder
configured inangular.json
{
// ...
"lint": {
"builder": "@angular-eslint/builder:lint",
"options": {
"lintFilePatterns": [
"./**/*.ts",
"./**/*.html"
]
}
}
// ...
}
- VS Code Settings for eslint extension
update eslint extension's settings to let it check html file in VS Code
{
// ./.vscode/settings.json
// ...
"eslint.options": {
"extensions": [
".ts",
".js",
".html"
]
},
"eslint.validate": [
"javascript",
"typescript",
"html"
]
// ...
}