@mrciphersmith/keryx 0.4.29 → 0.4.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +2408 -1369
- package/dist/core.js +90 -27
- package/dist/keryx-general-worker-entry.js +82 -25
- package/package.json +1 -1
- package/src/gdskills/bundled/install-manifest.json +2 -0
- package/src/gdskills/bundled/rules/core/api-contracts.mdc +21 -136
- package/src/gdskills/bundled/rules/core/async-patterns.mdc +18 -171
- package/src/gdskills/bundled/rules/core/clean-architecture.mdc +21 -3
- package/src/gdskills/bundled/rules/core/cli-interface-design.mdc +63 -194
- package/src/gdskills/bundled/rules/core/code-style-patterns.mdc +36 -49
- package/src/gdskills/bundled/rules/core/concurrency-patterns.mdc +32 -0
- package/src/gdskills/bundled/rules/core/database-patterns.mdc +26 -148
- package/src/gdskills/bundled/rules/core/error-handling.mdc +7 -8
- package/src/gdskills/bundled/rules/core/frontend-assistant.mdc +14 -29
- package/src/gdskills/bundled/rules/core/layout-rendering.mdc +51 -0
- package/src/gdskills/bundled/rules/core/mobx-store-template.mdc +69 -511
- package/src/gdskills/bundled/rules/core/nestjs-dto.mdc +18 -36
- package/src/gdskills/bundled/rules/core/playwright-testing.mdc +35 -308
- package/src/gdskills/bundled/rules/core/security-baseline.mdc +18 -140
- package/src/gdskills/bundled/rules/core/solid-principles.mdc +31 -7
- package/src/gdskills/bundled/rules/core/storybook-guidelines.mdc +20 -22
- package/src/gdskills/bundled/rules/core/tdd-workflow.mdc +37 -74
- package/src/gdskills/bundled/rules/core/ui-anti-slop.mdc +48 -37
- package/src/gdskills/bundled/skills/quality/deprecation-path/SKILL.md +1 -1
- package/src/gdskills/bundled/skills/review/review-architecture/SKILL.md +24 -60
- package/src/gdskills/bundled/skills/review/review-backend/SKILL.md +13 -65
- package/src/gdskills/bundled/skills/review/review-clean-code/SKILL.md +22 -35
- package/src/gdskills/bundled/skills/review/review-frontend/SKILL.md +16 -309
- package/src/gdskills/bundled/skills/review/review-frontend-conventions/SKILL.md +7 -21
- package/src/gdskills/bundled/skills/review/review-highload/SKILL.md +83 -227
- package/src/gdskills/bundled/skills/review/review-layout/SKILL.md +22 -28
- package/src/gdskills/bundled/skills/review/review-logic/SKILL.md +8 -8
- package/src/gdskills/bundled/skills/review/review-performance/SKILL.md +15 -37
- package/src/gdskills/bundled/skills/review/review-security-code/SKILL.md +7 -7
- package/src/gdskills/bundled/skills/review/review-style/SKILL.md +31 -66
- package/src/gdskills/bundled/skills/review/review-testing-practices/SKILL.md +21 -39
- package/src/gdskills/bundled/skills/review/review-ui-ux/SKILL.md +42 -82
- package/src/gdskills/bundled/stacks/angular/rules/coding-style.mdc +15 -57
- package/src/gdskills/bundled/stacks/angular/rules/patterns.mdc +16 -60
- package/src/gdskills/bundled/stacks/angular/rules/security.mdc +11 -49
- package/src/gdskills/bundled/stacks/angular/rules/testing.mdc +13 -52
- package/src/gdskills/bundled/stacks/c-cpp/rules/coding-style.mdc +33 -57
- package/src/gdskills/bundled/stacks/c-cpp/rules/patterns.mdc +35 -62
- package/src/gdskills/bundled/stacks/c-cpp/rules/security.mdc +35 -62
- package/src/gdskills/bundled/stacks/c-cpp/rules/testing.mdc +34 -54
- package/src/gdskills/bundled/stacks/ci-github-gitlab/rules/patterns.mdc +27 -56
- package/src/gdskills/bundled/stacks/ci-github-gitlab/rules/security.mdc +51 -119
- package/src/gdskills/bundled/stacks/csharp-dotnet/rules/coding-style.mdc +42 -74
- package/src/gdskills/bundled/stacks/csharp-dotnet/rules/patterns.mdc +45 -84
- package/src/gdskills/bundled/stacks/csharp-dotnet/rules/security.mdc +34 -59
- package/src/gdskills/bundled/stacks/csharp-dotnet/rules/testing.mdc +33 -62
- package/src/gdskills/bundled/stacks/django/rules/coding-style.mdc +15 -56
- package/src/gdskills/bundled/stacks/django/rules/patterns.mdc +16 -68
- package/src/gdskills/bundled/stacks/django/rules/security.mdc +13 -71
- package/src/gdskills/bundled/stacks/django/rules/testing.mdc +16 -62
- package/src/gdskills/bundled/stacks/docker-k8s-terraform/rules/coding-style.mdc +30 -53
- package/src/gdskills/bundled/stacks/docker-k8s-terraform/rules/patterns.mdc +20 -56
- package/src/gdskills/bundled/stacks/docker-k8s-terraform/rules/security.mdc +52 -122
- package/src/gdskills/bundled/stacks/docker-k8s-terraform/rules/testing.mdc +23 -42
- package/src/gdskills/bundled/stacks/fastapi/rules/coding-style.mdc +13 -47
- package/src/gdskills/bundled/stacks/fastapi/rules/patterns.mdc +18 -81
- package/src/gdskills/bundled/stacks/fastapi/rules/security.mdc +13 -75
- package/src/gdskills/bundled/stacks/fastapi/rules/testing.mdc +14 -58
- package/src/gdskills/bundled/stacks/flutter-dart/rules/coding-style.mdc +36 -74
- package/src/gdskills/bundled/stacks/flutter-dart/rules/patterns.mdc +30 -66
- package/src/gdskills/bundled/stacks/flutter-dart/rules/security.mdc +33 -67
- package/src/gdskills/bundled/stacks/flutter-dart/rules/testing.mdc +41 -73
- package/src/gdskills/bundled/stacks/go/rules/coding-style.mdc +36 -57
- package/src/gdskills/bundled/stacks/go/rules/patterns.mdc +27 -42
- package/src/gdskills/bundled/stacks/go/rules/security.mdc +26 -43
- package/src/gdskills/bundled/stacks/go/rules/testing.mdc +23 -41
- package/src/gdskills/bundled/stacks/java-kotlin-spring/rules/coding-style.mdc +18 -37
- package/src/gdskills/bundled/stacks/java-kotlin-spring/rules/patterns.mdc +26 -43
- package/src/gdskills/bundled/stacks/java-kotlin-spring/rules/security.mdc +25 -37
- package/src/gdskills/bundled/stacks/java-kotlin-spring/rules/testing.mdc +34 -50
- package/src/gdskills/bundled/stacks/kotlin-android/rules/coding-style.mdc +28 -65
- package/src/gdskills/bundled/stacks/kotlin-android/rules/patterns.mdc +34 -78
- package/src/gdskills/bundled/stacks/kotlin-android/rules/security.mdc +35 -68
- package/src/gdskills/bundled/stacks/kotlin-android/rules/testing.mdc +34 -68
- package/src/gdskills/bundled/stacks/mobx/rules/coding-style.mdc +18 -64
- package/src/gdskills/bundled/stacks/mobx/rules/patterns.mdc +13 -66
- package/src/gdskills/bundled/stacks/mobx/rules/security.mdc +8 -35
- package/src/gdskills/bundled/stacks/mobx/rules/testing.mdc +10 -39
- package/src/gdskills/bundled/stacks/nestjs/rules/coding-style.mdc +32 -45
- package/src/gdskills/bundled/stacks/nestjs/rules/patterns.mdc +40 -60
- package/src/gdskills/bundled/stacks/nestjs/rules/security.mdc +30 -50
- package/src/gdskills/bundled/stacks/nestjs/rules/testing.mdc +27 -47
- package/src/gdskills/bundled/stacks/nextjs-nuxt/rules/coding-style.mdc +14 -48
- package/src/gdskills/bundled/stacks/nextjs-nuxt/rules/patterns.mdc +15 -67
- package/src/gdskills/bundled/stacks/nextjs-nuxt/rules/security.mdc +12 -50
- package/src/gdskills/bundled/stacks/nextjs-nuxt/rules/testing.mdc +11 -43
- package/src/gdskills/bundled/stacks/php-laravel/rules/coding-style.mdc +17 -58
- package/src/gdskills/bundled/stacks/php-laravel/rules/patterns.mdc +15 -56
- package/src/gdskills/bundled/stacks/php-laravel/rules/security.mdc +13 -50
- package/src/gdskills/bundled/stacks/php-laravel/rules/testing.mdc +14 -55
- package/src/gdskills/bundled/stacks/python/rules/coding-style.mdc +13 -41
- package/src/gdskills/bundled/stacks/python/rules/patterns.mdc +20 -61
- package/src/gdskills/bundled/stacks/python/rules/security.mdc +15 -57
- package/src/gdskills/bundled/stacks/python/rules/testing.mdc +16 -50
- package/src/gdskills/bundled/stacks/react/rules/coding-style.mdc +14 -40
- package/src/gdskills/bundled/stacks/react/rules/patterns.mdc +15 -55
- package/src/gdskills/bundled/stacks/react/rules/security.mdc +13 -49
- package/src/gdskills/bundled/stacks/react/rules/testing.mdc +10 -37
- package/src/gdskills/bundled/stacks/ruby-rails/rules/coding-style.mdc +12 -45
- package/src/gdskills/bundled/stacks/ruby-rails/rules/patterns.mdc +18 -67
- package/src/gdskills/bundled/stacks/ruby-rails/rules/security.mdc +11 -60
- package/src/gdskills/bundled/stacks/ruby-rails/rules/testing.mdc +14 -65
- package/src/gdskills/bundled/stacks/rust/rules/coding-style.mdc +39 -65
- package/src/gdskills/bundled/stacks/rust/rules/patterns.mdc +33 -60
- package/src/gdskills/bundled/stacks/rust/rules/security.mdc +35 -57
- package/src/gdskills/bundled/stacks/rust/rules/testing.mdc +29 -52
- package/src/gdskills/bundled/stacks/sql-db/rules/coding-style.mdc +12 -48
- package/src/gdskills/bundled/stacks/sql-db/rules/patterns.mdc +22 -113
- package/src/gdskills/bundled/stacks/sql-db/rules/security.mdc +11 -56
- package/src/gdskills/bundled/stacks/sql-db/rules/testing.mdc +14 -59
- package/src/gdskills/bundled/stacks/swift-ios/rules/coding-style.mdc +29 -65
- package/src/gdskills/bundled/stacks/swift-ios/rules/patterns.mdc +41 -88
- package/src/gdskills/bundled/stacks/swift-ios/rules/security.mdc +28 -53
- package/src/gdskills/bundled/stacks/swift-ios/rules/testing.mdc +32 -65
- package/src/gdskills/bundled/stacks/vue/rules/coding-style.mdc +17 -52
- package/src/gdskills/bundled/stacks/vue/rules/patterns.mdc +17 -63
- package/src/gdskills/bundled/stacks/vue/rules/security.mdc +11 -41
- package/src/gdskills/bundled/stacks/vue/rules/testing.mdc +16 -48
|
@@ -17,7 +17,7 @@ triggers:
|
|
|
17
17
|
- "ai slop check"
|
|
18
18
|
metadata:
|
|
19
19
|
author: "MrCipherSmith"
|
|
20
|
-
version: "1.
|
|
20
|
+
version: "1.3.0"
|
|
21
21
|
origin: "authored"
|
|
22
22
|
category: "review"
|
|
23
23
|
compatible_harnesses: "cursor,codex,zed,opencode,claude"
|
|
@@ -28,27 +28,17 @@ license: "MIT"
|
|
|
28
28
|
|
|
29
29
|
Reviewer for what the user sees and does. Its inputs are the reviewer payload only; session memory and earlier conversation are not inputs.
|
|
30
30
|
|
|
31
|
-
Read-only, three passes, cheapest and most objective first: deterministic checks → usability heuristics → aesthetic judgment.
|
|
32
|
-
tiers, thresholds, and slop score come from `rules/core/ui-anti-slop.mdc` — read it first.
|
|
31
|
+
Read-only, three passes, cheapest and most objective first: deterministic checks → usability heuristics → aesthetic judgment.
|
|
33
32
|
Never edits code; fixes are proposed, not applied.
|
|
34
33
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
## Workflow
|
|
34
|
+
## Rules This Lens Reads
|
|
38
35
|
|
|
39
|
-
|
|
40
|
-
review-ui-ux Progress:
|
|
41
|
-
- [ ] Step 1: Read Job Context and DESIGN.md (if present)
|
|
42
|
-
- [ ] Step 2: Determine mode (code | live | both) and scope
|
|
43
|
-
- [ ] Step 3: Restate context: product, audience, primary task, surface type
|
|
44
|
-
- [ ] Step 4: Pass 1 — deterministic checks (code + render)
|
|
45
|
-
- [ ] Step 5: Pass 2 — usability heuristics, states, forms
|
|
46
|
-
- [ ] Step 6: Pass 3 — hierarchy, distinctiveness, slop score
|
|
47
|
-
- [ ] Step 7: Rate severity, attach evidence, write fixes
|
|
48
|
-
- [ ] Step 8: Emit report; list checks not run
|
|
49
|
-
```
|
|
36
|
+
Read both in `.metaproject/rules/core/` first. Conditions they rate are rated by their **Review severities** tables; this lens states none of them again and keeps only its method and calibration.
|
|
50
37
|
|
|
51
|
-
|
|
38
|
+
| Condition | Rule |
|
|
39
|
+
|---|---|
|
|
40
|
+
| Tell catalog and tiers, **Applies to** (marketing vs app screens), craft thresholds, slop score, exemptions, invented proof, focus, contrast, states, the WCAG floor | `ui-anti-slop.mdc` |
|
|
41
|
+
| Overflow, clipping and sideways scroll at a width, the 320px floor, locale and RTL geometry | `layout-rendering.mdc`, rated by `review-layout`: report none of it here |
|
|
52
42
|
|
|
53
43
|
## Input Contract
|
|
54
44
|
|
|
@@ -75,26 +65,24 @@ review-ui-ux Progress:
|
|
|
75
65
|
|
|
76
66
|
If there is neither a diff with UI files nor a supplied render, return `NEEDS_CONTEXT`.
|
|
77
67
|
|
|
78
|
-
|
|
68
|
+
Before Pass 1, read the job context and `DESIGN.md` if present, then state the product, audience,
|
|
69
|
+
primary task and surface type (marketing/content or app screen, per **Applies to** in the rule).
|
|
79
70
|
|
|
80
71
|
## Pass 1 — Deterministic checks
|
|
81
72
|
|
|
82
|
-
Objective, measurable, run first.
|
|
73
|
+
Objective, measurable, run first. The signals and thresholds are the rule's; this table is
|
|
74
|
+
where each is read in each mode, and each finding cites the measured value and the threshold.
|
|
83
75
|
|
|
84
|
-
| Check | Code mode
|
|
76
|
+
| Check | Code mode | Live mode |
|
|
85
77
|
|---|---|---|
|
|
86
|
-
| Focus | `outline: none` / `outline-0` without `:focus-visible` | Tab through: ring visible,
|
|
87
|
-
| Contrast | Token pairs computed from theme | Computed colors
|
|
88
|
-
| Color-only meaning | Status by class color only |
|
|
89
|
-
|
|
|
90
|
-
|
|
|
91
|
-
|
|
|
92
|
-
| Names & semantics | Icon-only buttons without accessible name; `div` with `onClick`; heading skips | Accessibility tree check |
|
|
78
|
+
| Focus | `outline: none` / `outline-0` without `:focus-visible` | Tab through: ring visible, not hidden by sticky bars |
|
|
79
|
+
| Contrast | Token pairs computed from the theme | Computed colors on the render |
|
|
80
|
+
| Color-only meaning, targets | Status by class color only; icon buttons with tiny padding | Grayscale read; measured target box |
|
|
81
|
+
| Reduced motion | No `prefers-reduced-motion` branch; `transition: all` | Emulate reduced motion: content stays, travel stops |
|
|
82
|
+
| Zoom | `user-scalable=no`, `maximum-scale=1` | Pinch-zoom on the render |
|
|
83
|
+
| Names & semantics | Icon-only buttons without accessible name; `div` with `onClick`; heading skips | Accessibility tree |
|
|
93
84
|
| Forms | Placeholder-as-label, missing `type`/`autocomplete`, pre-disabled submit, paste blocked | Submit empty: first error focused, message next to field |
|
|
94
|
-
| Fonts |
|
|
95
|
-
| Palette tells | `from-purple-* to-blue-*`, `bg-clip-text`, untouched `indigo-500`/`emerald-500` | Visible on render |
|
|
96
|
-
| Uniform surfaces | Same radius + shadow class on most containers; cards in cards | Visual scan |
|
|
97
|
-
| Copy tells | Filler verbs, emoji in headings, Jane Doe / Acme, lorem, invented round stats | Visible text |
|
|
85
|
+
| Fonts, palette, surfaces, copy | Theme fonts, palette classes, radius/shadow classes, visible strings | Computed font-family, the render, visible text |
|
|
98
86
|
|
|
99
87
|
## Pass 2 — Usability
|
|
100
88
|
|
|
@@ -104,29 +92,25 @@ Against the stated primary task:
|
|
|
104
92
|
consistency & standards, error prevention, recognition over recall, accelerators, minimalism,
|
|
105
93
|
error recovery, help. Cite the heuristic number.
|
|
106
94
|
- **States** — every interactive element: hover, focus-visible, active, disabled, loading.
|
|
107
|
-
Every data view: loading (
|
|
108
|
-
|
|
109
|
-
remedy, input kept), sparse, dense.
|
|
95
|
+
Every data view: loading (timing per the rule), empty (specific reason + action, never
|
|
96
|
+
"No results" while loading), error (near source, cause + remedy, input kept), sparse, dense.
|
|
110
97
|
- **Forms** — labels, inline errors, no redundant entry (3.3.7), password managers allowed (3.3.8).
|
|
111
|
-
- **Laws of UX** — Fitts (primary
|
|
112
|
-
|
|
113
|
-
look is not), proximity/common region (grouping matches meaning).
|
|
98
|
+
- **Laws of UX** — Fitts (primary large and near, destructive not beside it), Hick (fewer
|
|
99
|
+
choices, recommended marked), Jakob, proximity/common region (grouping matches meaning).
|
|
114
100
|
- **Destructive & async** — confirm or Undo; optimistic updates roll back; double-submit guarded.
|
|
115
101
|
|
|
116
102
|
## Pass 3 — Hierarchy and distinctiveness
|
|
117
103
|
|
|
118
|
-
- **Squint test** — blur the render; the intended focal element still dominates
|
|
119
|
-
treatments and ≤2 large elements per view.
|
|
104
|
+
- **Squint test** — blur the render; the intended focal element still dominates; contrast
|
|
105
|
+
treatments within the rule's cap and ≤2 large elements per view.
|
|
120
106
|
- **Five-second test** — first screen says what this is and what to do.
|
|
121
107
|
- **DESIGN.md conformance** — palette roles, type scale, signature element present and single,
|
|
122
108
|
"not doing" list respected. Drift from DESIGN.md is a finding.
|
|
123
109
|
- **Swap / competitor test** — could a competitor's logo go on this unnoticed?
|
|
124
|
-
- **Slop score** — count tells by tier
|
|
125
|
-
honor
|
|
110
|
+
- **Slop score** — count tells by tier with the rule's formula on the surfaces **Applies to**
|
|
111
|
+
names, list them, honor exemptions. Score ≥9 → recommend `ui-direction`, not patching.
|
|
126
112
|
- **Restraint** — name the one element that should be removed.
|
|
127
113
|
|
|
128
|
-
---
|
|
129
|
-
|
|
130
114
|
## Output Contract
|
|
131
115
|
|
|
132
116
|
```
|
|
@@ -143,8 +127,6 @@ task, surface type, mode); Scores (slop score with T1/T2/T3 counts and band, WCA
|
|
|
143
127
|
pass/fail, viewports checked or "not run"); Top 3 changes; findings by severity; What works
|
|
144
128
|
(keep); Checks not run.
|
|
145
129
|
|
|
146
|
-
---
|
|
147
|
-
|
|
148
130
|
## Iron Laws
|
|
149
131
|
|
|
150
132
|
### This reviewer's own
|
|
@@ -155,32 +137,19 @@ pass/fail, viewports checked or "not run"); Top 3 changes; findings by severity;
|
|
|
155
137
|
| Measure on the render when possible | Class names are intent; pixels are truth. A contrast, size or visual claim without a measurement (computed value, screenshot region, exact token pair) is `info` |
|
|
156
138
|
| One tell is not slop; the stack is | Inter for body text alone is fine; five defaults together are not |
|
|
157
139
|
| Distinctive look, conventional behavior | Never penalize a standard interaction pattern as "generic" |
|
|
158
|
-
| DESIGN.md
|
|
140
|
+
| `DESIGN.md`, the brief or the job context wins | A deliberate choice is not a tell (shared law 4) |
|
|
159
141
|
| Never claim checks that weren't run | List them under "Checks not run" |
|
|
160
142
|
|
|
161
143
|
### Shared laws (every reviewer)
|
|
162
144
|
|
|
163
|
-
|
|
164
145
|
1. **A claim of runtime harm with no reproducible path is `info`.** If you cannot name the input, call, or condition that reaches the code, you have an observation, not a finding. Report it as `info` and say what would settle it.
|
|
165
146
|
2. **Never flag the theoretical.** The path you describe must exist in the code under review. Do not report a safe API because it could be misused, or a pattern because it is often wrong elsewhere.
|
|
166
147
|
3. **One finding per class, not one per occurrence.** When the same shape appears at several sites, report it once and list every site. Ten findings that are one finding hide the other nine problems.
|
|
167
148
|
4. **A deliberate choice is not a defect until its reason is read and shown wrong.** An explicit override, suppression or exemption, a comment or commit giving a reason, or a sibling doing the same is a decision: read its reason (the comment, `git log -L` or `git blame`, the sibling) before you report it, and report it only when you can show that reason wrong. A project rule is checked against accepted platform practice and its known exceptions before a deviation from it is reported.
|
|
168
149
|
|
|
169
150
|
Severity levels are defined once, in `review-orchestrator/SKILL.md` →
|
|
170
|
-
**Severity (canonical)**. This reviewer keeps no rubric of its own
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
| Condition | Severity | Why, under the canonical rubric |
|
|
174
|
-
|---|---|---|
|
|
175
|
-
| Invented proof shipped as fact: fake stats, logos, testimonials, customers | `major` | Named trigger (the rendered page), named outcome (users read false claims) |
|
|
176
|
-
| Primary task unreachable by keyboard, or focus invisible on the primary flow | `major` | Named trigger (Tab through the flow), named outcome (the task cannot be finished) |
|
|
177
|
-
| Text contrast below 4.5:1 (3:1 large) on primary content, measured | `major` | Named trigger and outcome (the text is unreadable for low-vision users) |
|
|
178
|
-
| Missing loading / empty / error state on a primary view; destructive action without confirm or Undo | `major` | Named trigger (that state), named outcome (blank, stuck or irreversible screen) |
|
|
179
|
-
| T1 slop tell, or slop score ≥9 | `minor` | The UI works; the cost is identity and trust, not behavior |
|
|
180
|
-
| T2 tells, hierarchy competition, inconsistent tokens, generic CTA labels | `minor` | Behaves correctly; aesthetic or clarity cost |
|
|
181
|
-
| T3 tells, polish, or any visual claim you could not measure | `info` | Shared law 1 |
|
|
182
|
-
|
|
183
|
-
---
|
|
151
|
+
**Severity (canonical)**. This reviewer keeps no rubric of its own: its conditions are
|
|
152
|
+
rated by the **Review severities** table in `ui-anti-slop.mdc`.
|
|
184
153
|
|
|
185
154
|
## Orchestrated Review Contract
|
|
186
155
|
|
|
@@ -215,39 +184,30 @@ a claim that the class has exactly one member — make it deliberately.
|
|
|
215
184
|
- **Fix**: concrete change (token, component, copy, state)
|
|
216
185
|
```
|
|
217
186
|
|
|
218
|
-
---
|
|
219
|
-
|
|
220
187
|
## Scope Boundaries
|
|
221
188
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
| Naming, readability | NO | `review-style` |
|
|
228
|
-
| Re-render cost, bundle size | NO | `review-performance` |
|
|
229
|
-
| Pixel geometry: sizing, collapse, overflow, RTL, locale length | NO | `review-layout` |
|
|
230
|
-
| Logic bugs behind the UI | NO | `review-logic` |
|
|
231
|
-
| Creating a direction or rebuilding the UI | NO | `ui-direction`, `ui-craft` |
|
|
189
|
+
In scope: usability, states, forms, hierarchy, the a11y floor, slop. Elsewhere: React/MobX
|
|
190
|
+
structure (`review-frontend`), class/token conventions (`review-frontend-conventions`), naming
|
|
191
|
+
(`review-style`), re-render cost and bundle size (`review-performance`), pixel geometry — sizing,
|
|
192
|
+
collapse, overflow, reflow at a width, RTL, locale length (`review-layout`), logic bugs behind the
|
|
193
|
+
UI (`review-logic`), creating a direction or rebuilding the UI (`ui-direction`, `ui-craft`).
|
|
232
194
|
|
|
233
195
|
## Job Context Awareness
|
|
234
196
|
|
|
235
197
|
When dispatched with `JOB_NAME` / `CONTEXT_PATH`, read the context document before scope
|
|
236
|
-
detection
|
|
237
|
-
|
|
198
|
+
detection for the primary task, audience and agreed design decisions; an agreed decision is an
|
|
199
|
+
exemption like one in `DESIGN.md`.
|
|
238
200
|
|
|
239
201
|
## Red Flags
|
|
240
202
|
|
|
241
203
|
| Rationalization | Reality |
|
|
242
204
|
|---|---|
|
|
243
205
|
| "It looks fine to me" | State the measurement or cap at `info` |
|
|
244
|
-
| "Generic is safe for an admin panel" |
|
|
206
|
+
| "Generic is safe for an admin panel" | App screens skip the marketing rows (**Applies to**); missing states and broken focus still count |
|
|
245
207
|
| "Accessibility is a separate review" | The WCAG 2.2 AA floor is in scope here |
|
|
246
208
|
| "No browser, so I'll assume the contrast passes" | Compute from tokens or list it under "Checks not run" |
|
|
247
209
|
| "Every card has the same style — that's consistency" | Consistency of tokens, yes; one radius + shadow on everything is the card kit |
|
|
248
210
|
|
|
249
|
-
---
|
|
250
|
-
|
|
251
211
|
## Verification
|
|
252
212
|
|
|
253
213
|
Report done only once all of these hold:
|
|
@@ -259,9 +219,9 @@ Report done only once all of these hold:
|
|
|
259
219
|
about; `line` is derived at ingest from that quote, never counted.
|
|
260
220
|
- Every `blocker` and `major` carries `class_scope` with `sites` and an
|
|
261
221
|
`enumeration_method` naming the search that derived the set.
|
|
262
|
-
- No finding invents a severity: each
|
|
263
|
-
`review-orchestrator/SKILL.md`.
|
|
264
|
-
- Slop score lists its tells by tier and the
|
|
222
|
+
- No finding invents a severity: each comes from the `ui-anti-slop.mdc` table, under
|
|
223
|
+
**Severity (canonical)** in `review-orchestrator/SKILL.md`; overflow went to `review-layout`.
|
|
224
|
+
- Slop score lists its tells by tier and the exemptions it honored, with where each was read.
|
|
265
225
|
- "Checks not run" names every skipped check and why.
|
|
266
226
|
- The reply is the `REVIEW_RESULT` the Orchestrated Review Contract asks for, with
|
|
267
227
|
finding ids prefixed `UX-`, or `NEEDS_CONTEXT` naming what was missing.
|
|
@@ -8,75 +8,33 @@ metadata:
|
|
|
8
8
|
# Angular coding style
|
|
9
9
|
|
|
10
10
|
Narrows the stack-agnostic style rules to current Angular idiom (standalone
|
|
11
|
-
components, signals, `inject()`).
|
|
12
|
-
|
|
13
|
-
common rules this file `extends`.
|
|
11
|
+
components, signals, `inject()`). Everything not Angular-specific comes from
|
|
12
|
+
the common rules this file `extends`.
|
|
14
13
|
|
|
15
14
|
## Components and files
|
|
16
15
|
|
|
17
|
-
- Components, directives, and pipes are standalone
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
end-to-end.
|
|
21
|
-
- One component (and its template/styles) per file, named after the
|
|
22
|
-
component class (`OrderSummary` in `order-summary.ts`, not a generic
|
|
23
|
-
`component.ts`). Match whatever file-suffix convention (`.component.ts`
|
|
24
|
-
vs. plain `.ts`) the project's own `angular.json`/existing files already
|
|
25
|
-
use rather than introducing a second one.
|
|
26
|
-
- Keep a component's template under roughly 60-80 lines before extracting a
|
|
27
|
-
child component; a template doing significant `@if`/`@for` branching for
|
|
28
|
-
more than one concern is a sign the branches belong in separate
|
|
29
|
-
components.
|
|
16
|
+
- Components, directives, and pipes are standalone: do not set `standalone: false` or write a new `NgModule` unless the project is NgModule-based end-to-end.
|
|
17
|
+
- One component per file, named after the class (`OrderSummary` in `order-summary.ts`, not `component.ts`). Match the project's file-suffix convention (`.component.ts` vs plain `.ts`); do not introduce a second one.
|
|
18
|
+
- Extract a child component when a template passes roughly 60-80 lines or branches (`@if`/`@for`) for more than one concern.
|
|
30
19
|
|
|
31
20
|
## Dependency injection
|
|
32
21
|
|
|
33
|
-
- Prefer
|
|
34
|
-
|
|
35
|
-
cleanly with field initializers and works outside constructors (guards,
|
|
36
|
-
resolvers, `provide*` factories). Do not mix `inject()` and
|
|
37
|
-
constructor-parameter injection for different dependencies in the same
|
|
38
|
-
class — pick one per class, and prefer `inject()` for new classes.
|
|
39
|
-
- `inject()` only works inside an injection context (a constructor, a field
|
|
40
|
-
initializer, or a call wrapped in `runInInjectionContext`) — do not call
|
|
41
|
-
it inside a `setTimeout`, a plain async callback, or after the
|
|
42
|
-
constructor has returned.
|
|
22
|
+
- Prefer `inject()` over constructor-parameter injection for new code (`private readonly router = inject(Router);`). Pick one style per class; do not mix.
|
|
23
|
+
- Call `inject()` only in an injection context (constructor, field initializer, `runInInjectionContext`), not in `setTimeout` or a plain async callback.
|
|
43
24
|
|
|
44
25
|
## Signals and state
|
|
45
26
|
|
|
46
|
-
- Use `signal()` for local
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
value directly; always go through `.set()`/`.update()`.
|
|
50
|
-
- Keep a `computed()`'s computation pure (no side effects, no writes to
|
|
51
|
-
other signals inside it) — if a change needs to trigger a side effect,
|
|
52
|
-
use `effect()`, not a computed callback abused for its side effect.
|
|
53
|
-
- Do not mirror a signal's value into a plain class field "for convenience"
|
|
54
|
-
in the template — read the signal directly (`value()`) so Angular's
|
|
55
|
-
fine-grained reactivity tracks the actual dependency.
|
|
27
|
+
- Use `signal()` for local state, `computed()` for derived values, `input()`/`model()` for inputs; change a signal only through `.set()`/`.update()`.
|
|
28
|
+
- Keep `computed()` pure (no side effects, no writes to other signals); use `effect()` for side effects.
|
|
29
|
+
- Do not mirror a signal into a plain class field for the template; read `value()` directly.
|
|
56
30
|
|
|
57
31
|
## Templates and control flow
|
|
58
32
|
|
|
59
|
-
- Use
|
|
60
|
-
|
|
61
|
-
surrounding component's own template still uses the structural-directive
|
|
62
|
-
form throughout, in which case match the existing file rather than
|
|
63
|
-
mixing both styles in one template.
|
|
64
|
-
- Always give `@for` an explicit `track` expression (the item's own stable
|
|
65
|
-
id, not `$index`, unless the list has no natural identity) — an untracked
|
|
66
|
-
or index-tracked loop over data that reorders forces Angular to
|
|
67
|
-
re-render every row instead of just the ones that changed.
|
|
33
|
+
- Use `@if`, `@for` (with `track`), `@switch` in new templates, not `*ngIf`/`*ngFor`/`*ngSwitch`; in a template that still uses the structural-directive form throughout, match the file.
|
|
34
|
+
- Always give `@for` an explicit `track` on the item's stable id, not `$index`, unless the list has no natural identity.
|
|
68
35
|
|
|
69
36
|
## Naming and typing
|
|
70
37
|
|
|
71
|
-
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
already signals reactivity.
|
|
75
|
-
- Type every `input()`/`output()`/`model()` explicitly
|
|
76
|
-
(`input<Order | null>(null)`) rather than relying on inference from a
|
|
77
|
-
loosely-typed default; an untyped input silently becomes `unknown`/`any`
|
|
78
|
-
at every call site.
|
|
79
|
-
- Avoid `any` in component/service code; when the Angular CLI's generated
|
|
80
|
-
boilerplate produces a loosely-typed value (e.g. a form's raw value),
|
|
81
|
-
narrow it explicitly at the boundary instead of propagating `any`
|
|
82
|
-
through the class.
|
|
38
|
+
- Name a signal for the value it holds (`user`, not `userSignal`).
|
|
39
|
+
- Type every `input()`/`output()`/`model()` explicitly (`input<Order | null>(null)`).
|
|
40
|
+
- Avoid `any` in component/service code; narrow loosely-typed CLI-generated values (a form's raw value) at the boundary.
|
|
@@ -7,78 +7,34 @@ metadata:
|
|
|
7
7
|
|
|
8
8
|
# Angular patterns
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
to this stack.
|
|
10
|
+
Component/service/change-detection design for current Angular, narrowing the
|
|
11
|
+
common architecture rules to this stack.
|
|
13
12
|
|
|
14
13
|
## Change detection
|
|
15
14
|
|
|
16
|
-
- Default new components to `ChangeDetectionStrategy.OnPush`.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
`OnPush` plus signals rarely needs a manual `markForCheck()` at all.
|
|
20
|
-
- If a component still receives data via `@Input()` mutation of a plain
|
|
21
|
-
object (not a signal) under `OnPush`, replace the mutation with a new
|
|
22
|
-
object reference (or migrate the input to a signal) — `OnPush` only
|
|
23
|
-
re-checks on a new reference/signal change, not a mutated property on the
|
|
24
|
-
same object.
|
|
25
|
-
- Reach for `ChangeDetectorRef.markForCheck()` only when a value changes
|
|
26
|
-
outside Angular's own change-detection triggers (a third-party callback,
|
|
27
|
-
a native DOM event Angular didn't bind) and cannot reasonably be modeled
|
|
28
|
-
as a signal — not as a routine fix for "the view didn't update".
|
|
15
|
+
- Default new components to `ChangeDetectionStrategy.OnPush`.
|
|
16
|
+
- Under `OnPush`, replace `@Input()` mutation of a plain object with a new reference, or migrate the input to a signal.
|
|
17
|
+
- Use `ChangeDetectorRef.markForCheck()` only for a value that changes outside Angular's triggers (third-party callback, unbound native DOM event) and cannot be a signal.
|
|
29
18
|
|
|
30
19
|
## Dependency injection and service boundaries
|
|
31
20
|
|
|
32
|
-
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
the whole app's lifetime.
|
|
36
|
-
- Keep a component's class focused on view state and event wiring; move
|
|
37
|
-
business logic, HTTP calls, and cross-component state into an injectable
|
|
38
|
-
service. A component `inject()`-ing `HttpClient` directly to build
|
|
39
|
-
request logic inline is a sign that logic belongs in a service instead.
|
|
40
|
-
- Use Angular's `HttpClient` (with `provideHttpClient()` and interceptors
|
|
41
|
-
for cross-cutting concerns like auth headers) rather than a bare `fetch`
|
|
42
|
-
scattered through components — interceptors are the idiomatic place for
|
|
43
|
-
auth/error handling, not per-call boilerplate.
|
|
21
|
+
- `providedIn: 'root'` for app-wide singletons; route `providers` (or a standalone component's `providers`) for per-feature/per-route state.
|
|
22
|
+
- Keep the component class to view state and event wiring; business logic, HTTP calls, and cross-component state go in an injectable service.
|
|
23
|
+
- Use `HttpClient` with `provideHttpClient()` and interceptors (auth headers, error handling), not bare `fetch` in components.
|
|
44
24
|
|
|
45
25
|
## RxJS and signal interop
|
|
46
26
|
|
|
47
|
-
- Prefer `toSignal()`/`toObservable()` (`@angular/core/rxjs-interop`) at
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
subscribing into a plain field.
|
|
51
|
-
- When an `Observable` genuinely needs a manual `.subscribe()` inside a
|
|
52
|
-
component (rare once `async` pipe / `toSignal()` cover the common case),
|
|
53
|
-
pipe through `takeUntilDestroyed()` (call it in an injection context, or
|
|
54
|
-
pass an explicit `DestroyRef`) instead of hand-rolling a `Subject`+
|
|
55
|
-
`ngOnDestroy` teardown.
|
|
56
|
-
- Do not fan a single source Observable out into multiple independent
|
|
57
|
-
`.subscribe()` calls that each re-trigger the source's side effects
|
|
58
|
-
(e.g. a re-fetching HTTP call); share it (`shareReplay`, or convert once
|
|
59
|
-
with `toSignal()`) so the side effect runs once per meaningful change.
|
|
27
|
+
- Prefer `toSignal()`/`toObservable()` (`@angular/core/rxjs-interop`) at the RxJS/signal boundary over manual subscribing into a plain field.
|
|
28
|
+
- A manual `.subscribe()` pipes through `takeUntilDestroyed()` (in an injection context, or with an explicit `DestroyRef`), not a hand-rolled `Subject` + `ngOnDestroy`.
|
|
29
|
+
- Do not fan one source Observable into several `.subscribe()` calls that each re-trigger its side effects; share it (`shareReplay`, or convert once with `toSignal()`).
|
|
60
30
|
|
|
61
31
|
## Forms
|
|
62
32
|
|
|
63
|
-
- Prefer
|
|
64
|
-
|
|
65
|
-
trivial single-field form — typed forms catch a renamed/removed control
|
|
66
|
-
at compile time instead of a silent runtime `undefined`.
|
|
67
|
-
- Validate with Angular's built-in or custom `ValidatorFn`s registered on
|
|
68
|
-
the control, not ad-hoc validation logic scattered through submit-button
|
|
69
|
-
click handlers.
|
|
33
|
+
- Prefer typed Reactive Forms (`FormGroup<{...}>`, `FormControl<T>`) over template-driven forms beyond a trivial single-field form.
|
|
34
|
+
- Validate with built-in or custom `ValidatorFn`s on the control, not in submit handlers.
|
|
70
35
|
|
|
71
36
|
## Anti-patterns
|
|
72
37
|
|
|
73
|
-
- Do not reach into a child
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
declaratively.
|
|
77
|
-
- Do not perform DOM manipulation directly through `ElementRef.nativeElement`
|
|
78
|
-
in ordinary component code — use Angular's `Renderer2`, template
|
|
79
|
-
bindings, or a directive when direct DOM access is genuinely required
|
|
80
|
-
(a third-party widget, focus management); bypassing Angular's rendering
|
|
81
|
-
layer breaks server-side rendering and change-detection assumptions.
|
|
82
|
-
- Do not put HTTP calls or other side effects inside a `computed()` — a
|
|
83
|
-
computed's callback can re-run any number of times and must stay pure;
|
|
84
|
-
side effects belong in `effect()` or an explicit event handler.
|
|
38
|
+
- Do not reach into a child via `ViewChild` when an `input()`/signal binding or `output()` event expresses the interaction.
|
|
39
|
+
- Do not manipulate the DOM through `ElementRef.nativeElement` in ordinary component code; use `Renderer2`, template bindings, or a directive when direct access is required (third-party widget, focus management).
|
|
40
|
+
- Do not put HTTP calls or other side effects inside `computed()`; use `effect()` or an event handler.
|
|
@@ -7,64 +7,26 @@ metadata:
|
|
|
7
7
|
|
|
8
8
|
# Angular security
|
|
9
9
|
|
|
10
|
-
Stack-specific risks on top of the common security rules
|
|
11
|
-
|
|
12
|
-
create an opening.
|
|
10
|
+
Stack-specific risks on top of the common security rules: where Angular's
|
|
11
|
+
sanitization can be bypassed and where DI/routing choices open a hole.
|
|
13
12
|
|
|
14
13
|
## Template injection and sanitization bypass
|
|
15
14
|
|
|
16
|
-
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
`bypassSecurityTrustResourceUrl`/`bypassSecurityTrustScript` on
|
|
20
|
-
user-supplied or user-influenced content. Those calls tell Angular "trust
|
|
21
|
-
this value completely, skip sanitization" — reserve them for genuinely
|
|
22
|
-
static, developer-authored content (a hardcoded SVG, a known-safe
|
|
23
|
-
asset URL), never for a value that traces back to user input or an
|
|
24
|
-
external API response.
|
|
25
|
-
- Prefer binding through the normal property/interpolation syntax
|
|
26
|
-
(`{{ value }}`, `[textContent]`) over `[innerHTML]` for user-controlled
|
|
27
|
-
text; if `[innerHTML]` is genuinely required for rich content, sanitize
|
|
28
|
-
server-side or via a vetted sanitizer library rather than trusting
|
|
29
|
-
Angular's default sanitizer alone for anything beyond simple formatting.
|
|
30
|
-
- Never write directly to `ElementRef.nativeElement.innerHTML` — that
|
|
31
|
-
bypasses Angular's sanitizer entirely, unlike the `[innerHTML]` template
|
|
32
|
-
binding which still runs through it.
|
|
15
|
+
- Do not call `DomSanitizer.bypassSecurityTrustHtml`/`bypassSecurityTrustUrl`/`bypassSecurityTrustResourceUrl`/`bypassSecurityTrustScript` on user-influenced content; reserve them for static, developer-authored content (hardcoded SVG, known-safe asset URL), never a value traced to user input or an external API response.
|
|
16
|
+
- Bind user-controlled text with `{{ value }}` or `[textContent]`, not `[innerHTML]`; if `[innerHTML]` is required for rich content, sanitize server-side or with a vetted sanitizer library.
|
|
17
|
+
- Never write to `ElementRef.nativeElement.innerHTML`.
|
|
33
18
|
|
|
34
19
|
## HTTP and CSRF
|
|
35
20
|
|
|
36
|
-
- Send credentials/tokens
|
|
37
|
-
|
|
38
|
-
`Authorization` header at each call site — a missed call site is a
|
|
39
|
-
silent auth gap, not a build error.
|
|
40
|
-
- When the backend uses cookie-based sessions, rely on Angular's built-in
|
|
41
|
-
`XSRF-TOKEN`/`X-XSRF-TOKEN` CSRF handling (`withXsrfConfiguration` /
|
|
42
|
-
the default cookie name) rather than disabling `withCredentials` or
|
|
43
|
-
rolling a custom CSRF header scheme, unless the backend's own CSRF
|
|
44
|
-
contract genuinely requires different header/cookie names — configure
|
|
45
|
-
those, don't drop the protection.
|
|
21
|
+
- Send credentials/tokens through `HttpClient` interceptors (`HttpInterceptorFn` or class-based `HttpInterceptor`), not a hand-appended `Authorization` header at each call site.
|
|
22
|
+
- With cookie-based sessions, use Angular's built-in `XSRF-TOKEN`/`X-XSRF-TOKEN` handling (`withXsrfConfiguration` or the default cookie name); do not disable `withCredentials` or roll a custom CSRF header scheme. If the backend contract needs different names, configure them.
|
|
46
23
|
|
|
47
24
|
## Routing and route guards
|
|
48
25
|
|
|
49
|
-
- Gate
|
|
50
|
-
|
|
51
|
-
state (a token's validity, a role from the authenticated session) — never
|
|
52
|
-
a guard that only checks a client-side flag with no corresponding
|
|
53
|
-
server-side check on the API the route's data comes from.
|
|
54
|
-
- Do not put secrets, API keys, or backend-only credentials into
|
|
55
|
-
environment files (`environment.ts`) that ship in the client bundle —
|
|
56
|
-
anything in `environment.*.ts` is public once built; only put
|
|
57
|
-
publicly-safe configuration (API base URLs, feature flags) there.
|
|
26
|
+
- Gate authenticated/authorized routes with a guard (`CanActivateFn`/`CanMatchFn`) that checks server-verified state (token validity, role from the session), never only a client-side flag.
|
|
27
|
+
- Do not put secrets, API keys, or backend-only credentials in `environment.*.ts`; only publicly-safe configuration (API base URLs, feature flags).
|
|
58
28
|
|
|
59
29
|
## Dependency injection surface
|
|
60
30
|
|
|
61
|
-
- Do not widen a service
|
|
62
|
-
|
|
63
|
-
per-session state — a root-scoped singleton is shared across the whole
|
|
64
|
-
app's lifetime (and across users in SSR), so session-scoped data leaking
|
|
65
|
-
into it is a cross-request data leak, not just a design smell.
|
|
66
|
-
- Validate and narrow data crossing a trust boundary (route params, query
|
|
67
|
-
params, a form's raw value, a third-party postMessage payload) before
|
|
68
|
-
using it in a template binding or passing it to a service call — treat
|
|
69
|
-
router/query-string values as untrusted input, not as pre-validated
|
|
70
|
-
application state.
|
|
31
|
+
- Do not widen a service holding per-user or per-session state to `providedIn: 'root'` to work around an injection error (cross-request leak in SSR).
|
|
32
|
+
- Validate and narrow data crossing a trust boundary (route params, query params, a form's raw value, a `postMessage` payload) before using it in a template binding or service call.
|
|
@@ -7,67 +7,28 @@ metadata:
|
|
|
7
7
|
|
|
8
8
|
# Angular testing
|
|
9
9
|
|
|
10
|
-
Test layout, runner, and fixture conventions for Angular
|
|
11
|
-
|
|
12
|
-
`TestBed`-based Angular idiom.
|
|
10
|
+
Test layout, runner, and fixture conventions for Angular, narrowing the
|
|
11
|
+
common testing rules to `TestBed`-based idiom.
|
|
13
12
|
|
|
14
13
|
## Layout and runner
|
|
15
14
|
|
|
16
|
-
- Co-locate a unit test with its source (`order-summary.ts`
|
|
17
|
-
|
|
18
|
-
spec files already do; do not invent a parallel `__tests__/` tree in an
|
|
19
|
-
Angular CLI project that uses co-located `.spec.ts` files.
|
|
20
|
-
- Run the project's configured runner (`ng test`, or a Jest/Vitest setup if
|
|
21
|
-
the project has migrated off Karma) rather than assuming Karma is
|
|
22
|
-
present — check `angular.json`'s `test` builder or the project's
|
|
23
|
-
`package.json` `test` script before invoking a specific runner by name.
|
|
15
|
+
- Co-locate a unit test with its source (`order-summary.spec.ts` beside `order-summary.ts`), matching existing spec files; no parallel `__tests__/` tree in a CLI project with co-located specs.
|
|
16
|
+
- Run the project's configured runner (`ng test`, or Jest/Vitest if migrated off Karma); check `angular.json`'s `test` builder or `package.json` before naming a runner.
|
|
24
17
|
|
|
25
18
|
## Component tests
|
|
26
19
|
|
|
27
|
-
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
- Set signal-based inputs through `fixture.componentRef.setInput('name',
|
|
32
|
-
value)`, not by assigning the component instance's field directly —
|
|
33
|
-
direct field assignment on a signal input does not go through Angular's
|
|
34
|
-
input-binding machinery and can silently not reflect in the template the
|
|
35
|
-
way a real caller's binding would.
|
|
36
|
-
- After a change that affects the DOM (setting an input, clicking a
|
|
37
|
-
button, resolving a promise/observable the component depends on), call
|
|
38
|
-
`fixture.detectChanges()` (or `await fixture.whenStable()` for
|
|
39
|
-
async work) before asserting on the rendered DOM — an assertion made
|
|
40
|
-
before change detection runs reads stale markup.
|
|
41
|
-
- Query the DOM through `fixture.debugElement.query(By.css(...))` /
|
|
42
|
-
`By.directive(...)`, or `fixture.nativeElement.querySelector(...)` for
|
|
43
|
-
plain DOM assertions — prefer a stable selector (a `data-testid`, a
|
|
44
|
-
semantic role/label) over a CSS class that styling changes could break.
|
|
20
|
+
- Use `TestBed.configureTestingModule` with the standalone component in `imports`, then `TestBed.createComponent`.
|
|
21
|
+
- Set signal-based inputs with `fixture.componentRef.setInput('name', value)`, not by assigning the instance field.
|
|
22
|
+
- Call `fixture.detectChanges()` (or `await fixture.whenStable()` for async work) before asserting on the DOM.
|
|
23
|
+
- Query with `fixture.debugElement.query(By.css(...))`/`By.directive(...)` or `fixture.nativeElement.querySelector(...)`; prefer a stable selector (`data-testid`, role/label) over a styling class.
|
|
45
24
|
|
|
46
25
|
## Services, HTTP, and doubles
|
|
47
26
|
|
|
48
|
-
- Test
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
instance.
|
|
52
|
-
- Mock `HttpClient`-backed calls with `provideHttpClientTesting()` /
|
|
53
|
-
`HttpTestingController` (`expectOne`, `.flush(...)`) rather than a
|
|
54
|
-
hand-rolled fetch stub — it verifies the exact request was made and lets
|
|
55
|
-
the test control the exact response, and `httpTestingController.verify()`
|
|
56
|
-
at the end of each test catches an unexpected extra request.
|
|
57
|
-
- Stub a genuinely external dependency (a third-party SDK, `window`/
|
|
58
|
-
browser APIs the test environment can't provide) at that boundary via
|
|
59
|
-
Angular's provider overrides (`TestBed.overrideProvider`) — do not mock
|
|
60
|
-
the component's own signals/services, which is what the test is supposed
|
|
61
|
-
to exercise.
|
|
27
|
+
- Test a service through `TestBed.inject(MyService)` (or direct instantiation if it has no dependencies), not through a component's private field.
|
|
28
|
+
- Mock HTTP with `provideHttpClientTesting()`/`HttpTestingController` (`expectOne`, `.flush(...)`), not a hand-rolled fetch stub; call `httpTestingController.verify()` at the end of each test.
|
|
29
|
+
- Stub external dependencies (third-party SDK, browser APIs the environment lacks) at the boundary with `TestBed.overrideProvider`; do not mock the component's own signals/services.
|
|
62
30
|
|
|
63
31
|
## Determinism
|
|
64
32
|
|
|
65
|
-
- Prefer `fakeAsync`/`tick()` (or `waitForAsync`) over
|
|
66
|
-
|
|
67
|
-
timers/microtasks explicitly rather than adding an arbitrary `tick(1000)`
|
|
68
|
-
guess.
|
|
69
|
-
- Reset any shared test state (a spy's call count, a `TestBed` module
|
|
70
|
-
configured with `teardown: { destroyAfterEach: true }`, which is
|
|
71
|
-
Angular's own default) between tests so one spec's setup cannot leak
|
|
72
|
-
into the next — do not disable that default teardown to "fix" a
|
|
73
|
-
cross-test leak instead of finding the actual shared state.
|
|
33
|
+
- Prefer `fakeAsync`/`tick()` (or `waitForAsync`) over real `setTimeout`; flush timers explicitly, not with an arbitrary `tick(1000)`.
|
|
34
|
+
- Reset shared test state between tests; keep `TestBed`'s default `teardown: { destroyAfterEach: true }` and do not disable it to hide a cross-test leak.
|