Overview
A production-ready, opinionated ESLint configuration that enforces best practices for Angular applications. Combines rules from industry-leading plugins into a single package with zero additional configuration required.
Features
🅰️ Angular: 40+ rules for standalone, lifecycle, components/directives standards, metadata, signals, pipes,...
📘 TypeScript: Promise-async, type imports, strict typing, type safety, extraneous classes,...
✨ Code Quality: Complexity max, file length control, import cycles detection, 100+ Unicorn best practices,...
🎨 Style: Airbnb extended, max line length, object/class newlines, sorted classes/imports/objects/types,...
📁 Naming: File/folder/class suffix conventions enforced (components, services, pipes, interfaces,...)
🔍 Templates: 30+ rules with alphabetical attrs, complexity max, control flow, trackBy, a11y, no-any,...
What's Included
✨ No additional ESLint installation needed! Everything is bundled.
Installation
1. Install Package
yarn add eslint-config-angular-strict --dev
⚠️ Important: Remove any existing eslint dependency from your project - it's included!
2. Configure ESLint
Create an eslint.config.js file (flat config format):
import angularStrict from 'eslint-config-angular-strict';
export default [
...angularStrict,
// Your custom overrides here
];
3. Update package.json
Add the following to your package.json:
{
// ...
"type": "module",
}
4. Lint JSON, Markdown, TOML and YAML files (optional)
JSON, Markdown, TOML and YAML files are checked against the preset of their plugin (recommended for JSON and Markdown, standard for TOML and YAML) and the Unicorn rules recommended for them, but ng lint only looks at the patterns declared in angular.json. Add the ones you need there — files ignored by git are skipped:
{
// ...
"lint": {
"builder": "@angular-eslint/builder:lint",
"options": {
"lintFilePatterns": ["src/**/*.ts", "src/**/*.html", "**/*.json", "**/*.md", "**/*.toml", "**/*.yaml", "**/*.yml"],
},
},
}
TypeScript Configuration
Make sure your tsconfig.json is properly configured:
{
"compilerOptions": {
// ...
"allowUnreachableCode": false,
"allowUnusedLabels": false,
"exactOptionalPropertyTypes": true,
"noImplicitOverride": true,
"noUncheckedIndexedAccess": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"target": "esnext",
},
"angularCompilerOptions": {
// ...
"extendedDiagnostics": { "defaultCategory": "error" },
"strictInjectionParameters": true,
"strictStandalone": true,
"strictTemplates": true,
},
}
ℹ️ Note: target: "esnext" auto-includes the latest standard lib (esnext + DOM), which several Unicorn rules require. Without it, some rules may suggest APIs that TypeScript doesn't recognize as built-in. No need to set lib explicitly — TypeScript infers it from target.
Prettier
This config handles TypeScript formatting via ESLint. Prettier should only be used for HTML templates.
Recommended .prettierrc
{
"htmlWhitespaceSensitivity": "ignore",
"overrides": [
{
"files": "*.html",
"options": { "parser": "angular" }
}
],
"printWidth": 165,
"singleQuote": true
}
ℹ️ Note: htmlWhitespaceSensitivity: "ignore" lets Prettier break a template wherever it reads best, instead of leaving dangling > to avoid adding whitespace. Angular already drops whitespace-only text between two tags, so nothing changes there. Whitespace next to text is still rendered, though: Prettier may add a space between a tag and the text glued to it (</i>{{ label }}), and it trims the spaces at the edges of a tag (<span> - </span>). A space in the middle of text is safe ({{ title }} - <span>…</span>, <small>{{ label }}: {{ value }}</small>): keep it there rather than at the edge of a tag. Otherwise, never rely on a typed space for spacing: use CSS, wrap the text in its own tag, or, as a last resort, write the space as &ngsp;.
Recommended lint scripts (package.json)
{
"scripts": {
// ...
"lint": "ng lint && prettier --check \"src/**/*.html\"",
"lint:fix": "ng lint --fix && prettier --write \"src/**/*.html\"",
},
}
⚠️ Important: Only target *.html files with Prettier. Running Prettier on .ts files will conflict with ESLint Stylistic rules.
Recommended VS Code settings
{
// ...
"[html]": { "editor.defaultFormatter": "esbenp.prettier-vscode" },
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
"editor.formatOnSave": true,
"editor.formatOnType": true,
"eslint.format.enable": true,
"eslint.validate": [, /*...*/ "html", "typescript"],
}
This ensures ESLint handles .ts formatting on save, while Prettier handles .html templates.
Beyond Angular
The config also works as-is in a TypeScript project without Angular, such as a Node backend or Cloud Functions: the Angular rules have nothing to report there, and everything else applies, file naming conventions included. The installation is the same; without ng lint, run ESLint directly on the files you want:
{
"scripts": {
// ...
"lint": "eslint \"**/*.{json,md,toml,ts,yaml,yml}\"",
},
}
In tsconfig.json, leave out angularCompilerOptions and pick the target that matches your runtime. The Prettier section only concerns Angular templates.
Contributing
Contributions are welcome! Please open an issue or submit a PR.
License
MIT © Jean-benoit Gautier