@netural/eslint-config-angular
v4.0.5
Published
Netural ESLint flat config for Angular + TypeScript projects
Downloads
952
Readme
@netural/eslint-config-angular
Netural's shared ESLint flat config for Angular + TypeScript projects.
Requires ESLint v9+ and the flat config format.
For ESLint v8 (legacy.eslintrcformat), use v3 of this package.
What's included
This config extends and builds on:
@typescript-eslint/eslint-pluginrecommended — strict TypeScript rules@angular-eslint/eslint-pluginrecommended — Angular best practices
On top of those bases, the following opinions are enforced:
| Category | Rules |
|---|---|
| Code style | curly: error, no-console: warn (allows warn/error) |
| TypeScript | Explicit function return types, explicit member accessibility (lifecycle hooks excluded), array syntax for array types, strict naming conventions |
| Safety | @typescript-eslint/no-unused-vars: warn, @typescript-eslint/no-array-constructor: error, no-object-constructor: error |
| Naming | camelCase variables/properties, UPPER_CASE enums & exported consts, StrictPascalCase types/interfaces/booleans (with is/should/has/can/will prefix) |
| RxJS | Subjects (Subject, BehaviorSubject, ReplaySubject, AsyncSubject) must be readonly |
| Angular | Empty lifecycle methods warned, input rename off |
Installation
Install the package and its peer dependencies:
npm install --save-dev \
@netural/eslint-config-angular \
eslint \
@typescript-eslint/eslint-plugin \
@typescript-eslint/parser \
@angular-eslint/eslint-pluginUsage
In your project's eslint.config.js:
// eslint.config.js
const neuralAngularConfig = require("@netural/eslint-config-angular");
module.exports = [
...neuralAngularConfig,
// Optional: project-specific overrides
{
rules: {
// override specific rules here
},
},
];Or with ESM (eslint.config.mjs):
// eslint.config.mjs
import neuralAngularConfig from "@netural/eslint-config-angular";
export default [
...neuralAngularConfig,
];Restricting to TypeScript files
If you only want the config to apply to .ts files (recommended for Angular projects):
// eslint.config.js
const neuralAngularConfig = require("@netural/eslint-config-angular");
module.exports = [
...neuralAngularConfig.map((config) => ({
...config,
files: ["**/*.ts"],
})),
];Migrating from v3 to v4
v4 switches from the legacy .eslintrc extends format to ESLint's flat config format. The package now exports a plain array of config objects, so FlatCompat is no longer needed for this package.
Before (v3 with FlatCompat)
// eslint.config.mjs
import { FlatCompat } from '@eslint/eslintrc';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
const compat = new FlatCompat({ baseDirectory: path.dirname(fileURLToPath(import.meta.url)) });
export default [
// ...
...compat
.extends(
'plugin:@typescript-eslint/recommended',
'plugin:@angular-eslint/recommended',
'@netural/eslint-config-angular'
)
.map((config) => ({ ...config, files: ['**/*.ts'] })),
];After (v4 — direct import + spread)
// eslint.config.mjs
import neturalConfig from '@netural/eslint-config-angular';
export default [
// ...
// @netural/eslint-config-angular is now a flat config – spread it directly.
// It already includes @typescript-eslint/recommended and @angular-eslint/recommended.
...neturalConfig.map((config) => ({
...config,
files: ['**/*.ts'],
})),
];Key changes:
- Remove
FlatCompatand itsextends(...)call for this package entirely. - Import
@netural/eslint-config-angulardirectly and spread it. - The config already bundles
@typescript-eslint/recommendedand@angular-eslint/recommended, so those no longer need to be listed separately. FlatCompatmay still be needed for other legacy configs in your project (e.g.eslint:recommendedvia@eslint/js, or other third-party configs not yet on flat config).
Peer dependencies
| Package | Minimum version |
|---|---|
| eslint | >= 9 |
| @typescript-eslint/eslint-plugin | >= 7 |
| @typescript-eslint/parser | >= 7 |
| @angular-eslint/eslint-plugin | >= 17 |
Progressive strictness
The following rules are intentionally left off by default because they require type-aware linting (a parserOptions.project setup) and can produce many errors in codebases that aren't fully typed yet. Enable them incrementally as your project reaches stricter typing:
// eslint.config.js — project-specific overrides
{
rules: {
"@typescript-eslint/no-unsafe-call": "error",
"@typescript-eslint/no-unsafe-member-access": "error",
"@typescript-eslint/no-unsafe-argument": "error",
"@typescript-eslint/no-unsafe-assignment": "error",
"@typescript-eslint/member-ordering": "error",
},
}Versioning
This package follows Semantic Versioning. Breaking changes to rules or peer dependency requirements will be released as major versions.
License
ISC © Netural GmbH
