docs(rules): update TypeScript and Angular rules for TS 7 and trim duplicates

TypeScript 7.0 ships the native compiler as tsc and drops options
deprecated in 6.0. Angular 22 still requires TypeScript >=6.0.0 <6.1.0,
so both rule sets now warn against moving Angular projects to TS 7, and
the Angular index asks to check the Angular version first.

TypeScript runtime safety adds error handling (Error objects only,
cause chaining, unknown in catch, one error model per layer, no
swallowed errors) plus exact decimals for money, ISO 8601 UTC dates, and
Intl formatting. Angular adds per-route SSR render modes, a global
ErrorHandler with provideBrowserGlobalErrorListeners, and translatable
text with locale-aware formatting.

Generic guidance that the TypeScript, refactoring, and UI/UX rules
already cover is removed from the Angular rules, which shrink by about
7.5 percent despite the additions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Julian LechnerandClaude Opus 5.5 committed 2026-11-18 10:08:25 +01:00
1 parent 368cf5ee4a
commit b6c33780c3
9 files changed
+43 -114

No files matched your search

@@ -1,28 +1,17 @@
# Angular Templates and Styling
Apply these rules when writing Angular templates, control flow, or component styles.
Apply these rules when writing Angular templates, control flow, or component styles. Load the UI/UX rules for visual design.
## Templates
* Keep expressions short and readable.
* Reading signals and `computed` values in templates is correct. Do not call other methods that compute or allocate from templates; use `computed` or a pure pipe instead.
* Avoid complex conditions directly in markup.
* Prefer derived state in TypeScript over repeated template expressions.
* Use Angular control flow syntax such as `@if`, `@for` and `@switch` for new code.
* Keep template expressions short. Reading signals and `computed` values is correct; do not call other methods that compute or allocate from templates, and move complex conditions into `computed` state or a pure pipe.
* Use built-in control flow (`@if`, `@for`, `@switch`) in new code.
* In `@for`, track a stable unique key such as `track item.id`; use `$index` only for static lists that never reorder. For legacy `*ngFor`, supply `trackBy`.
* Avoid deeply nested template structures.
* Split large templates into focused components when it improves maintainability.
* Avoid unnecessary DOM elements.
* Split large or deeply nested templates into focused components, and avoid unnecessary DOM elements.
* Use semantic HTML and native elements before custom implementations; see the accessibility section of the Angular security and accessibility rule.
* Keep user-facing text translatable with the project's i18n approach, such as `i18n` attributes and `$localize`, and format dates, numbers, and currencies with locale-aware pipes instead of hand-built strings.
## Styling
* Keep styles scoped and predictable.
* Avoid unnecessary global CSS.
* Follow the project's styling strategy consistently.
* Avoid excessive specificity.
* Avoid `!important` unless there is a concrete reason.
* Prefer reusable design tokens and shared styles over duplicated magic values.
* Keep component styles focused on component concerns.
* Avoid styling based on fragile DOM structure.
* Do not mix multiple styling approaches without need.
* Keep styles scoped to the component and follow the project's styling strategy; avoid unnecessary global CSS and mixing styling approaches.
* Prefer design tokens and shared styles over magic values. Avoid excessive specificity, `!important`, and selectors that depend on fragile DOM structure.