Linting and Formatting
Shared Configuration Packages
All libraries must use the company‑provided shared configurations for ESLint, Prettier, and Stylelint. These packages are versioned, distributed via the private npm registry, and ensure a consistent coding style across the whole front‑end ecosystem.
@company/eslint-config– base ESLint configuration with Angular, TypeScript, and RxJS rules.@company/prettier-config– centralized Prettier settings.@company/stylelint-config– Stylelint configuration for SCSS and CSS custom properties.
Each library extends these configurations in its local config files, avoiding divergent or ad‑hoc rule overrides.
ESLint
The ESLint setup enforces code quality, best practices, and strict typing conventions. The shared configuration (@company/eslint-config) includes the following plugins and rulesets:
@typescript-eslint: strict type‑aware rules.
@angular-eslint: component and template rules.
eslint-plugin-rxjs: appropriate operator usage.
eslint-plugin-import: ordered imports and no unresolved paths.
eslint-config-prettier: disables formatting rules that conflict with Prettier.
Core Rules (strictness)
@typescript-eslint/explicit-function-return-type: warn for public functions and methods; optional for internal helpers to avoid noise.@typescript-eslint/consistent-type-assertions: enforceas Typesyntax, disallow<Type>assertions.@angular-eslint/no-input-rename: error – prevents renaming inputs (keeps API predictable).@angular-eslint/no-output-rename: error.@angular-eslint/use-lifecycle-interface: error.@angular-eslint/no-empty-lifecycle-method: error.@typescript-eslint/no-unused-vars: error (TypeScript variant), disallowing unused imports and variables.@angular-eslint/prefer-signals: errorno-console: warn – console logs may be used during development but must be removed before merging.
Prettier
Prettier is the single source of truth for code formatting. The shared configuration @company/prettier-config defines:
All libraries add a .prettierrc.js that simply references the shared config:
Prettier runs automatically:
in the developer’s IDE (recommended setup via
.vscode/extensions.jsonand settings).as a pre‑commit hook.
in CI with
prettier --checkto ensure no unformatted files are merged.
Stylelint
Stylelint validates SCSS files and enforces the theming variable conventions. The shared configuration @company/stylelint-config includes:
stylelint-config-standard-scssas the baseline.stylelint-orderfor consistent property ordering.Custom rules that verify the two‑level variable cascade (global → component‑specific → default).
Mandatory Rules
declaration-no-important: error –!importantis banned. Exceptions require a comment and team approval.
Integration
Stylelint runs on all
*.scssfiles.In pre‑commit,
stylelint --fixautomatically corrects order violations where possible.CI runs
stylelint --max-warnings=0and blocks the build on any error.