@bovinphang/frontend-craft 2.8.0 → 2.9.0
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/.claude-plugin/marketplace.json +3 -3
- package/.claude-plugin/plugin.json +1 -1
- package/CHANGELOG.md +378 -339
- package/CHANGELOG.zh-CN.md +377 -338
- package/CONTRIBUTING.md +371 -361
- package/CONTRIBUTING.zh-CN.md +371 -361
- package/README.md +545 -493
- package/README.openclaw.md +359 -320
- package/README.openclaw.zh-CN.md +359 -320
- package/README.zh-CN.md +545 -493
- package/agents/fec-code-reviewer.md +24 -3
- package/agents/fec-debugger.md +1 -1
- package/agents/fec-doc-updater.md +1 -1
- package/agents/fec-e2e-runner.md +1 -1
- package/agents/fec-figma-implementer.md +1 -1
- package/agents/fec-performance-optimizer.md +1 -1
- package/agents/fec-refactor-cleaner.md +4 -1
- package/agents/fec-refactoring-expert.md +81 -0
- package/agents/fec-security-reviewer.md +17 -1
- package/agents/fec-test-planner.md +1 -1
- package/agents/fec-typescript-reviewer.md +24 -8
- package/agents/fec-ui-checker.md +11 -11
- package/commands/fec-debug.md +1 -1
- package/commands/fec-refactor-plan.md +17 -0
- package/commands/fec-refactor.md +18 -0
- package/commands/fec-review.md +40 -10
- package/commands/fec-scaffold.md +1 -1
- package/commands/fec-smell.md +17 -0
- package/commands/fec-tdd.md +6 -2
- package/dist/bin/frontend-craft.js +190 -38
- package/dist/hooks/fec-run-tests.js +5 -1
- package/dist/hooks/fec-session-start.js +1 -1
- package/docs/example-prompts.md +157 -140
- package/docs/ja-JP/README.md +534 -493
- package/docs/ko-KR/README.md +534 -493
- package/docs/project-structure.md +151 -131
- package/docs/refactoring/README.md +50 -0
- package/docs/refactoring/catalog.md +105 -0
- package/docs/refactoring/smell-refactoring-matrix.md +41 -0
- package/docs/review-and-diagram-workflows.md +39 -0
- package/docs/runtimes/antigravity.md +18 -10
- package/docs/runtimes/augment.md +18 -10
- package/docs/runtimes/claude.md +191 -177
- package/docs/runtimes/claude.zh-CN.md +189 -175
- package/docs/runtimes/cline.md +18 -10
- package/docs/runtimes/codebuddy.md +18 -10
- package/docs/runtimes/codex.md +18 -10
- package/docs/runtimes/compatibility.md +27 -0
- package/docs/runtimes/copilot.md +18 -10
- package/docs/runtimes/cursor.md +18 -10
- package/docs/runtimes/gemini.md +18 -10
- package/docs/runtimes/kilo.md +18 -10
- package/docs/runtimes/openclaw.md +18 -10
- package/docs/runtimes/opencode.md +18 -10
- package/docs/runtimes/qoder.md +18 -19
- package/docs/runtimes/trae.md +18 -10
- package/docs/runtimes/windsurf.md +18 -10
- package/docs/superpowers/plans/2026-09-26-content-integrity.md +145 -0
- package/docs/superpowers/plans/2026-09-26-diagram-quality.md +170 -0
- package/docs/superpowers/specs/2026-09-26-diagram-quality-design.md +77 -0
- package/docs/superpowers/specs/2026-09-26-project-optimization-design.md +95 -0
- package/docs/zh-CN/example-prompts.md +157 -140
- package/docs/zh-CN/project-structure.md +148 -128
- package/docs/zh-CN/review-and-diagram-workflows.md +39 -0
- package/docs/zh-TW/README.md +534 -493
- package/localized/zh-CN/agents/fec-code-reviewer.md +22 -3
- package/localized/zh-CN/agents/fec-refactor-cleaner.md +3 -0
- package/localized/zh-CN/agents/fec-refactoring-expert.md +53 -0
- package/localized/zh-CN/agents/fec-security-reviewer.md +16 -0
- package/localized/zh-CN/agents/fec-typescript-reviewer.md +23 -7
- package/localized/zh-CN/commands/fec-refactor-plan.md +15 -0
- package/localized/zh-CN/commands/fec-refactor.md +14 -0
- package/localized/zh-CN/commands/fec-review.md +40 -9
- package/localized/zh-CN/commands/fec-smell.md +13 -0
- package/localized/zh-CN/commands/fec-tdd.md +4 -0
- package/localized/zh-CN/skills/eval_queries.json +244 -0
- package/localized/zh-CN/skills/fec-code-review/SKILL.md +20 -1
- package/localized/zh-CN/skills/fec-code-review/references/report-template.md +11 -1
- package/localized/zh-CN/skills/fec-code-smells/SKILL.md +33 -0
- package/localized/zh-CN/skills/fec-code-smells/references/detection-guide.md +25 -0
- package/localized/zh-CN/skills/fec-code-smells/references/smell-catalog.md +817 -0
- package/localized/zh-CN/skills/fec-code-smells/references/smell-to-refactoring-map.md +265 -0
- package/localized/zh-CN/skills/fec-image-generation/SKILL.md +31 -1
- package/localized/zh-CN/skills/fec-image-generation/assets/quality-examples/README.md +14 -0
- package/localized/zh-CN/skills/fec-image-generation/assets/quality-examples/architecture.json +121 -0
- package/localized/zh-CN/skills/fec-image-generation/assets/quality-examples/invalid-explicit.json +41 -0
- package/localized/zh-CN/skills/fec-image-generation/assets/quality-examples/sequence.json +53 -0
- package/localized/zh-CN/skills/fec-image-generation/assets/quality-examples/sequence.mmd +21 -0
- package/localized/zh-CN/skills/fec-image-generation/assets/quality-examples/workflow.json +98 -0
- package/localized/zh-CN/skills/fec-image-generation/assets/quality-examples/workflow.mmd +7 -0
- package/localized/zh-CN/skills/fec-image-generation/references/diagram-workflows.md +10 -3
- package/localized/zh-CN/skills/fec-image-generation/references/html-technical-diagrams.md +8 -1
- package/localized/zh-CN/skills/fec-image-generation/references/png-qa-autofix.md +9 -2
- package/localized/zh-CN/skills/fec-image-generation/scripts/diagram-browser.mjs +90 -0
- package/localized/zh-CN/skills/fec-image-generation/scripts/diagram-layout.mjs +176 -0
- package/localized/zh-CN/skills/fec-image-generation/scripts/export-diagram.mjs +48 -80
- package/localized/zh-CN/skills/fec-image-generation/scripts/mermaid-render.mjs +64 -0
- package/localized/zh-CN/skills/fec-image-generation/scripts/png-qa.mjs +35 -4
- package/localized/zh-CN/skills/fec-image-generation/scripts/tech-diagram-render.mjs +193 -53
- package/localized/zh-CN/skills/fec-refactor-clean/SKILL.md +3 -0
- package/localized/zh-CN/skills/fec-refactoring/SKILL.md +83 -0
- package/localized/zh-CN/skills/fec-refactoring/references/principles.md +43 -0
- package/localized/zh-CN/skills/fec-refactoring/references/refactoring-vs-feature-change.md +25 -0
- package/localized/zh-CN/skills/fec-refactoring/references/when-to-refactor.md +17 -0
- package/localized/zh-CN/skills/fec-refactoring/references/workflow.md +59 -0
- package/localized/zh-CN/skills/fec-refactoring-api/SKILL.md +25 -0
- package/localized/zh-CN/skills/fec-refactoring-api/references/api-refactorings.md +496 -0
- package/localized/zh-CN/skills/fec-refactoring-catalog/SKILL.md +21 -0
- package/localized/zh-CN/skills/fec-refactoring-catalog/references/catalog-index.md +99 -0
- package/localized/zh-CN/skills/fec-refactoring-catalog/references/composition-guide.md +49 -0
- package/localized/zh-CN/skills/fec-refactoring-catalog/references/selection-guide.md +41 -0
- package/localized/zh-CN/skills/fec-refactoring-control/SKILL.md +25 -0
- package/localized/zh-CN/skills/fec-refactoring-control/references/conditional-refactorings.md +299 -0
- package/localized/zh-CN/skills/fec-refactoring-data/SKILL.md +25 -0
- package/localized/zh-CN/skills/fec-refactoring-data/references/data-refactorings.md +248 -0
- package/localized/zh-CN/skills/fec-refactoring-encapsulation/SKILL.md +25 -0
- package/localized/zh-CN/skills/fec-refactoring-encapsulation/references/encapsulation-refactorings.md +452 -0
- package/localized/zh-CN/skills/fec-refactoring-functions/SKILL.md +25 -0
- package/localized/zh-CN/skills/fec-refactoring-functions/references/function-refactorings.md +567 -0
- package/localized/zh-CN/skills/fec-refactoring-inheritance/SKILL.md +25 -0
- package/localized/zh-CN/skills/fec-refactoring-inheritance/references/inheritance-refactorings.md +550 -0
- package/localized/zh-CN/skills/fec-refactoring-move-features/SKILL.md +25 -0
- package/localized/zh-CN/skills/fec-refactoring-move-features/references/moving-refactorings.md +453 -0
- package/localized/zh-CN/skills/fec-refactoring-validation/SKILL.md +52 -0
- package/localized/zh-CN/skills/fec-refactoring-validation/references/behavior-preservation.md +15 -0
- package/localized/zh-CN/skills/fec-refactoring-validation/references/refactoring-test-checklist.md +25 -0
- package/localized/zh-CN/skills/fec-security-review/SKILL.md +16 -0
- package/localized/zh-CN/skills/fec-security-review/references/report-template.md +10 -0
- package/localized/zh-CN/skills/fec-tdd-workflow/SKILL.md +3 -0
- package/localized/zh-CN/skills/metadata.json +408 -50
- package/localized/zh-CN/skills/relations.json +271 -3
- package/localized/zh-CN/templates/shared/rules/fec-agent-workflow.md +1 -0
- package/openclaw.plugin.json +2 -3
- package/package.json +27 -17
- package/skills/eval_queries.json +244 -0
- package/skills/fec-code-review/SKILL.md +20 -1
- package/skills/fec-code-review/references/report-template.md +11 -1
- package/skills/fec-code-smells/SKILL.md +33 -0
- package/skills/fec-code-smells/references/detection-guide.md +25 -0
- package/skills/fec-code-smells/references/smell-catalog.md +861 -0
- package/skills/fec-code-smells/references/smell-to-refactoring-map.md +265 -0
- package/skills/fec-data-fetching/SKILL.md +1 -1
- package/skills/fec-image-generation/SKILL.md +31 -1
- package/skills/fec-image-generation/assets/quality-examples/README.md +14 -0
- package/skills/fec-image-generation/assets/quality-examples/architecture.json +121 -0
- package/skills/fec-image-generation/assets/quality-examples/invalid-explicit.json +41 -0
- package/skills/fec-image-generation/assets/quality-examples/sequence.json +53 -0
- package/skills/fec-image-generation/assets/quality-examples/sequence.mmd +21 -0
- package/skills/fec-image-generation/assets/quality-examples/workflow.json +98 -0
- package/skills/fec-image-generation/assets/quality-examples/workflow.mmd +7 -0
- package/skills/fec-image-generation/references/diagram-workflows.md +10 -3
- package/skills/fec-image-generation/references/html-technical-diagrams.md +8 -1
- package/skills/fec-image-generation/references/png-qa-autofix.md +9 -2
- package/skills/fec-image-generation/scripts/diagram-browser.mjs +90 -0
- package/skills/fec-image-generation/scripts/diagram-layout.mjs +176 -0
- package/skills/fec-image-generation/scripts/export-diagram.mjs +48 -80
- package/skills/fec-image-generation/scripts/mermaid-render.mjs +64 -0
- package/skills/fec-image-generation/scripts/png-qa.mjs +35 -4
- package/skills/fec-image-generation/scripts/tech-diagram-render.mjs +193 -53
- package/skills/fec-legacy-web-standard/SKILL.md +1 -1
- package/skills/fec-refactor-clean/SKILL.md +3 -0
- package/skills/fec-refactoring/SKILL.md +83 -0
- package/skills/fec-refactoring/references/principles.md +60 -0
- package/skills/fec-refactoring/references/refactoring-vs-feature-change.md +27 -0
- package/skills/fec-refactoring/references/when-to-refactor.md +31 -0
- package/skills/fec-refactoring/references/workflow.md +90 -0
- package/skills/fec-refactoring-api/SKILL.md +25 -0
- package/skills/fec-refactoring-api/references/api-refactorings.md +496 -0
- package/skills/fec-refactoring-catalog/SKILL.md +28 -0
- package/skills/fec-refactoring-catalog/references/catalog-index.md +99 -0
- package/skills/fec-refactoring-catalog/references/composition-guide.md +49 -0
- package/skills/fec-refactoring-catalog/references/selection-guide.md +47 -0
- package/skills/fec-refactoring-control/SKILL.md +25 -0
- package/skills/fec-refactoring-control/references/conditional-refactorings.md +299 -0
- package/skills/fec-refactoring-data/SKILL.md +25 -0
- package/skills/fec-refactoring-data/references/data-refactorings.md +248 -0
- package/skills/fec-refactoring-encapsulation/SKILL.md +25 -0
- package/skills/fec-refactoring-encapsulation/references/encapsulation-refactorings.md +452 -0
- package/skills/fec-refactoring-functions/SKILL.md +25 -0
- package/skills/fec-refactoring-functions/references/function-refactorings.md +567 -0
- package/skills/fec-refactoring-inheritance/SKILL.md +25 -0
- package/skills/fec-refactoring-inheritance/references/inheritance-refactorings.md +550 -0
- package/skills/fec-refactoring-move-features/SKILL.md +25 -0
- package/skills/fec-refactoring-move-features/references/moving-refactorings.md +453 -0
- package/skills/fec-refactoring-validation/SKILL.md +59 -0
- package/skills/fec-refactoring-validation/references/behavior-preservation.md +53 -0
- package/skills/fec-refactoring-validation/references/refactoring-test-checklist.md +42 -0
- package/skills/fec-security-review/SKILL.md +16 -0
- package/skills/fec-security-review/references/report-template.md +10 -0
- package/skills/fec-tdd-workflow/SKILL.md +5 -1
- package/skills/metadata.json +434 -71
- package/skills/relations.json +264 -0
- package/templates/shared/rules/fec-agent-workflow.md +1 -0
- package/docs/superpowers/plans/2026-05-29-fec-debug.md +0 -491
- package/docs/superpowers/specs/2026-05-29-fec-debug-design.md +0 -340
|
@@ -0,0 +1,567 @@
|
|
|
1
|
+
# Function Refactorings
|
|
2
|
+
|
|
3
|
+
These cards transform the supplied standard catalog into concise operational guidance for frontend agents. Standard IDs/names are preserved; examples and framework adaptations are original.
|
|
4
|
+
|
|
5
|
+
## RF-EXTRACT-FUNCTION — Extract Function
|
|
6
|
+
|
|
7
|
+
### Intent
|
|
8
|
+
Move a coherent fragment into a well-named function so the caller reads in terms of intent.
|
|
9
|
+
|
|
10
|
+
### Typical Signals
|
|
11
|
+
- A block has a distinct purpose that can be named; comments divide a function into concepts.
|
|
12
|
+
|
|
13
|
+
### Avoid When
|
|
14
|
+
- Do not extract when the new function would merely hide a trivial expression without adding a useful name.
|
|
15
|
+
|
|
16
|
+
### Preconditions
|
|
17
|
+
- Current observable behavior and affected callers are understood.
|
|
18
|
+
- The target scope is inside a declared diff budget and can be verified after this one primary transformation.
|
|
19
|
+
|
|
20
|
+
### Mechanics
|
|
21
|
+
1. Identify the coherent statements and their inputs/outputs.
|
|
22
|
+
2. Create a function named for purpose rather than implementation.
|
|
23
|
+
3. Move the statements and replace them with the call.
|
|
24
|
+
4. Run narrow verification before any further extraction.
|
|
25
|
+
|
|
26
|
+
### Behavior-Preservation Checkpoints
|
|
27
|
+
- Compare inputs, outputs, exceptions, side effects, ordering, and public contracts before/after the step.
|
|
28
|
+
- For frontend code, also check UI state, events, focus, network behavior, lifecycle/state transitions, and relevant identity semantics.
|
|
29
|
+
|
|
30
|
+
### Related Code Smells
|
|
31
|
+
- `SMELL-DUPLICATED-CODE`
|
|
32
|
+
- `SMELL-LONG-FUNCTION`
|
|
33
|
+
- `SMELL-MUTABLE-DATA`
|
|
34
|
+
- `SMELL-DIVERGENT-CHANGE`
|
|
35
|
+
- `SMELL-FEATURE-ENVY`
|
|
36
|
+
- `SMELL-MESSAGE-CHAINS`
|
|
37
|
+
- `SMELL-DATA-CLASS`
|
|
38
|
+
- `SMELL-COMMENTS`
|
|
39
|
+
|
|
40
|
+
### Composes Well With
|
|
41
|
+
- Move Function when its preconditions independently hold.
|
|
42
|
+
- Replace Temp with Query when its preconditions independently hold.
|
|
43
|
+
|
|
44
|
+
### JavaScript Notes
|
|
45
|
+
- Preserve JavaScript evaluation order, closures, `this`, default parameters, rest/spread, and side effects.
|
|
46
|
+
|
|
47
|
+
### TypeScript Notes
|
|
48
|
+
- Use typed parameter objects and keep inference/public signatures stable; do not silence errors with casts.
|
|
49
|
+
|
|
50
|
+
### React Notes
|
|
51
|
+
- For React, extracted helpers must not violate Hook rules or capture stale values; keep event/effect ordering stable.
|
|
52
|
+
|
|
53
|
+
### Vue Notes
|
|
54
|
+
- For Vue, preserve `ref`/`reactive` unwrapping, computed dependencies, and composable lifecycle scope.
|
|
55
|
+
|
|
56
|
+
### Frontend-Craft Adaptation
|
|
57
|
+
- Prefer helpers, handlers, modules, hooks/composables, or services when they express the same intent more naturally than classes.
|
|
58
|
+
|
|
59
|
+
### Example Transformation
|
|
60
|
+
Before: a submit handler validates recipients, normalizes payload, then sends. After: extract `validateRecipients()` while preserving the same errors and order.
|
|
61
|
+
|
|
62
|
+
## RF-INLINE-FUNCTION — Inline Function
|
|
63
|
+
|
|
64
|
+
### Intent
|
|
65
|
+
Remove a function boundary whose body is clearer than its name or whose indirection blocks better restructuring.
|
|
66
|
+
|
|
67
|
+
### Typical Signals
|
|
68
|
+
- A function only delegates or its name adds no semantic value.
|
|
69
|
+
|
|
70
|
+
### Avoid When
|
|
71
|
+
- Keep a small function when its name is the useful abstraction, a test seam, or a stable public contract.
|
|
72
|
+
|
|
73
|
+
### Preconditions
|
|
74
|
+
- Current observable behavior and affected callers are understood.
|
|
75
|
+
- The target scope is inside a declared diff budget and can be verified after this one primary transformation.
|
|
76
|
+
|
|
77
|
+
### Mechanics
|
|
78
|
+
1. Check all callers and whether the function is overridden/exported.
|
|
79
|
+
2. Replace one caller with the body and verify.
|
|
80
|
+
3. Repeat for remaining safe callers.
|
|
81
|
+
4. Remove the declaration only after all references are resolved.
|
|
82
|
+
|
|
83
|
+
### Behavior-Preservation Checkpoints
|
|
84
|
+
- Compare inputs, outputs, exceptions, side effects, ordering, and public contracts before/after the step.
|
|
85
|
+
- For frontend code, also check UI state, events, focus, network behavior, lifecycle/state transitions, and relevant identity semantics.
|
|
86
|
+
|
|
87
|
+
### Related Code Smells
|
|
88
|
+
- `SMELL-SHOTGUN-SURGERY`
|
|
89
|
+
- `SMELL-LAZY-ELEMENT`
|
|
90
|
+
- `SMELL-SPECULATIVE-GENERALITY`
|
|
91
|
+
- `SMELL-MIDDLE-MAN`
|
|
92
|
+
|
|
93
|
+
### Composes Well With
|
|
94
|
+
- `RF-EXTRACT-FUNCTION` when its preconditions independently hold.
|
|
95
|
+
|
|
96
|
+
### JavaScript Notes
|
|
97
|
+
- Preserve JavaScript evaluation order, closures, `this`, default parameters, rest/spread, and side effects.
|
|
98
|
+
|
|
99
|
+
### TypeScript Notes
|
|
100
|
+
- Use typed parameter objects and keep inference/public signatures stable; do not silence errors with casts.
|
|
101
|
+
|
|
102
|
+
### React Notes
|
|
103
|
+
- For React, extracted helpers must not violate Hook rules or capture stale values; keep event/effect ordering stable.
|
|
104
|
+
|
|
105
|
+
### Vue Notes
|
|
106
|
+
- For Vue, preserve `ref`/`reactive` unwrapping, computed dependencies, and composable lifecycle scope.
|
|
107
|
+
|
|
108
|
+
### Frontend-Craft Adaptation
|
|
109
|
+
- Prefer helpers, handlers, modules, hooks/composables, or services when they express the same intent more naturally than classes.
|
|
110
|
+
|
|
111
|
+
### Example Transformation
|
|
112
|
+
Before: `isEmptyName(v)` only returns `!v.trim()`. After: inline the expression where that makes the surrounding guard clearer.
|
|
113
|
+
|
|
114
|
+
## RF-EXTRACT-VARIABLE — Extract Variable
|
|
115
|
+
|
|
116
|
+
### Intent
|
|
117
|
+
Name an important subexpression so a complex calculation or condition exposes its concepts.
|
|
118
|
+
|
|
119
|
+
### Typical Signals
|
|
120
|
+
- A long expression contains meaningful parts that readers must mentally decode.
|
|
121
|
+
|
|
122
|
+
### Avoid When
|
|
123
|
+
- Avoid names that merely restate syntax or force readers to bounce between lines.
|
|
124
|
+
|
|
125
|
+
### Preconditions
|
|
126
|
+
- Current observable behavior and affected callers are understood.
|
|
127
|
+
- The target scope is inside a declared diff budget and can be verified after this one primary transformation.
|
|
128
|
+
|
|
129
|
+
### Mechanics
|
|
130
|
+
1. Select a stable subexpression.
|
|
131
|
+
2. Introduce a `const` with an intent-revealing name.
|
|
132
|
+
3. Replace matching occurrences where evaluation semantics stay the same.
|
|
133
|
+
4. Verify evaluation count and short-circuit behavior.
|
|
134
|
+
|
|
135
|
+
### Behavior-Preservation Checkpoints
|
|
136
|
+
- Compare inputs, outputs, exceptions, side effects, ordering, and public contracts before/after the step.
|
|
137
|
+
- For frontend code, also check UI state, events, focus, network behavior, lifecycle/state transitions, and relevant identity semantics.
|
|
138
|
+
|
|
139
|
+
### Related Code Smells
|
|
140
|
+
- No single code smell required; select from concrete structural evidence.
|
|
141
|
+
|
|
142
|
+
### Composes Well With
|
|
143
|
+
- `RF-INLINE-VARIABLE` when its preconditions independently hold.
|
|
144
|
+
|
|
145
|
+
### JavaScript Notes
|
|
146
|
+
- Preserve JavaScript evaluation order, closures, `this`, default parameters, rest/spread, and side effects.
|
|
147
|
+
|
|
148
|
+
### TypeScript Notes
|
|
149
|
+
- Use typed parameter objects and keep inference/public signatures stable; do not silence errors with casts.
|
|
150
|
+
|
|
151
|
+
### React Notes
|
|
152
|
+
- For React, extracted helpers must not violate Hook rules or capture stale values; keep event/effect ordering stable.
|
|
153
|
+
|
|
154
|
+
### Vue Notes
|
|
155
|
+
- For Vue, preserve `ref`/`reactive` unwrapping, computed dependencies, and composable lifecycle scope.
|
|
156
|
+
|
|
157
|
+
### Frontend-Craft Adaptation
|
|
158
|
+
- Prefer helpers, handlers, modules, hooks/composables, or services when they express the same intent more naturally than classes.
|
|
159
|
+
|
|
160
|
+
### Example Transformation
|
|
161
|
+
Before: a JSX condition repeats `user.permissions.includes("mail.send")`. After: introduce `canSendMail` and render from that name.
|
|
162
|
+
|
|
163
|
+
## RF-INLINE-VARIABLE — Inline Variable
|
|
164
|
+
|
|
165
|
+
### Intent
|
|
166
|
+
Remove a temporary variable that obscures a simple expression or blocks another refactoring.
|
|
167
|
+
|
|
168
|
+
### Typical Signals
|
|
169
|
+
- A variable is assigned once and its name adds less clarity than the expression.
|
|
170
|
+
|
|
171
|
+
### Avoid When
|
|
172
|
+
- Do not inline when it duplicates expensive/effectful evaluation or removes a useful domain name.
|
|
173
|
+
|
|
174
|
+
### Preconditions
|
|
175
|
+
- Current observable behavior and affected callers are understood.
|
|
176
|
+
- The target scope is inside a declared diff budget and can be verified after this one primary transformation.
|
|
177
|
+
|
|
178
|
+
### Mechanics
|
|
179
|
+
1. Confirm the initializer is stable and side-effect semantics are unchanged.
|
|
180
|
+
2. Replace reads with the initializer.
|
|
181
|
+
3. Remove the declaration.
|
|
182
|
+
4. Verify evaluation count and type inference.
|
|
183
|
+
|
|
184
|
+
### Behavior-Preservation Checkpoints
|
|
185
|
+
- Compare inputs, outputs, exceptions, side effects, ordering, and public contracts before/after the step.
|
|
186
|
+
- For frontend code, also check UI state, events, focus, network behavior, lifecycle/state transitions, and relevant identity semantics.
|
|
187
|
+
|
|
188
|
+
### Related Code Smells
|
|
189
|
+
- No single code smell required; select from concrete structural evidence.
|
|
190
|
+
|
|
191
|
+
### Composes Well With
|
|
192
|
+
- `RF-EXTRACT-VARIABLE` when its preconditions independently hold.
|
|
193
|
+
|
|
194
|
+
### JavaScript Notes
|
|
195
|
+
- Preserve JavaScript evaluation order, closures, `this`, default parameters, rest/spread, and side effects.
|
|
196
|
+
|
|
197
|
+
### TypeScript Notes
|
|
198
|
+
- Use typed parameter objects and keep inference/public signatures stable; do not silence errors with casts.
|
|
199
|
+
|
|
200
|
+
### React Notes
|
|
201
|
+
- For React, extracted helpers must not violate Hook rules or capture stale values; keep event/effect ordering stable.
|
|
202
|
+
|
|
203
|
+
### Vue Notes
|
|
204
|
+
- For Vue, preserve `ref`/`reactive` unwrapping, computed dependencies, and composable lifecycle scope.
|
|
205
|
+
|
|
206
|
+
### Frontend-Craft Adaptation
|
|
207
|
+
- Prefer helpers, handlers, modules, hooks/composables, or services when they express the same intent more naturally than classes.
|
|
208
|
+
|
|
209
|
+
### Example Transformation
|
|
210
|
+
Before: `const result = draft.subject.trim(); return result;`. After: return `draft.subject.trim()` directly.
|
|
211
|
+
|
|
212
|
+
## RF-CHANGE-FUNCTION-DECLARATION — Change Function Declaration
|
|
213
|
+
|
|
214
|
+
### Intent
|
|
215
|
+
Make a function name or parameter contract better express how callers should use it.
|
|
216
|
+
|
|
217
|
+
### Typical Signals
|
|
218
|
+
- A name is misleading, parameters are missing/unused, or callers need a clearer contract.
|
|
219
|
+
|
|
220
|
+
### Avoid When
|
|
221
|
+
- Do not casually change exported/public signatures, framework callback contracts, or externally consumed APIs.
|
|
222
|
+
|
|
223
|
+
### Preconditions
|
|
224
|
+
- Current observable behavior and affected callers are understood.
|
|
225
|
+
- The target scope is inside a declared diff budget and can be verified after this one primary transformation.
|
|
226
|
+
|
|
227
|
+
### Mechanics
|
|
228
|
+
1. Map all callers and public boundaries.
|
|
229
|
+
2. Introduce the new name/signature, using a compatibility shim when needed.
|
|
230
|
+
3. Migrate callers in small verified steps.
|
|
231
|
+
4. Remove the old form only when compatibility requirements allow.
|
|
232
|
+
|
|
233
|
+
### Behavior-Preservation Checkpoints
|
|
234
|
+
- Compare inputs, outputs, exceptions, side effects, ordering, and public contracts before/after the step.
|
|
235
|
+
- For frontend code, also check UI state, events, focus, network behavior, lifecycle/state transitions, and relevant identity semantics.
|
|
236
|
+
|
|
237
|
+
### Related Code Smells
|
|
238
|
+
- `SMELL-MYSTERIOUS-NAME`
|
|
239
|
+
- `SMELL-SPECULATIVE-GENERALITY`
|
|
240
|
+
- `SMELL-ALTERNATIVE-CLASSES-DIFFERENT-INTERFACES`
|
|
241
|
+
- `SMELL-COMMENTS`
|
|
242
|
+
|
|
243
|
+
### Composes Well With
|
|
244
|
+
- Combine only with a separately justified next transformation; no fixed sequence is required.
|
|
245
|
+
|
|
246
|
+
### JavaScript Notes
|
|
247
|
+
- Preserve JavaScript evaluation order, closures, `this`, default parameters, rest/spread, and side effects.
|
|
248
|
+
|
|
249
|
+
### TypeScript Notes
|
|
250
|
+
- Use typed parameter objects and keep inference/public signatures stable; do not silence errors with casts.
|
|
251
|
+
|
|
252
|
+
### React Notes
|
|
253
|
+
- For React, extracted helpers must not violate Hook rules or capture stale values; keep event/effect ordering stable.
|
|
254
|
+
|
|
255
|
+
### Vue Notes
|
|
256
|
+
- For Vue, preserve `ref`/`reactive` unwrapping, computed dependencies, and composable lifecycle scope.
|
|
257
|
+
|
|
258
|
+
### Frontend-Craft Adaptation
|
|
259
|
+
- Prefer helpers, handlers, modules, hooks/composables, or services when they express the same intent more naturally than classes.
|
|
260
|
+
|
|
261
|
+
### Example Transformation
|
|
262
|
+
Before: private `send(data, true)` becomes `sendUrgently(data)` or a clearer signature; public APIs keep a compatibility path when required.
|
|
263
|
+
|
|
264
|
+
## RF-ENCAPSULATE-VARIABLE — Encapsulate Variable
|
|
265
|
+
|
|
266
|
+
### Intent
|
|
267
|
+
Route access to a variable through an explicit boundary so reads and writes can be controlled.
|
|
268
|
+
|
|
269
|
+
### Typical Signals
|
|
270
|
+
- A shared variable can be mutated from many locations or representation changes are difficult.
|
|
271
|
+
|
|
272
|
+
### Avoid When
|
|
273
|
+
- Do not add ceremonial getters around genuinely local constants.
|
|
274
|
+
|
|
275
|
+
### Preconditions
|
|
276
|
+
- Current observable behavior and affected callers are understood.
|
|
277
|
+
- The target scope is inside a declared diff budget and can be verified after this one primary transformation.
|
|
278
|
+
|
|
279
|
+
### Mechanics
|
|
280
|
+
1. Create a controlled read/write API around the variable.
|
|
281
|
+
2. Migrate one access path at a time.
|
|
282
|
+
3. Restrict direct access after callers are migrated.
|
|
283
|
+
4. Then change representation or ownership behind the seam if useful.
|
|
284
|
+
|
|
285
|
+
### Behavior-Preservation Checkpoints
|
|
286
|
+
- Compare inputs, outputs, exceptions, side effects, ordering, and public contracts before/after the step.
|
|
287
|
+
- For frontend code, also check UI state, events, focus, network behavior, lifecycle/state transitions, and relevant identity semantics.
|
|
288
|
+
|
|
289
|
+
### Related Code Smells
|
|
290
|
+
- `SMELL-GLOBAL-DATA`
|
|
291
|
+
- `SMELL-MUTABLE-DATA`
|
|
292
|
+
|
|
293
|
+
### Composes Well With
|
|
294
|
+
- `RF-RENAME-VARIABLE` when its preconditions independently hold.
|
|
295
|
+
- Move Function when its preconditions independently hold.
|
|
296
|
+
|
|
297
|
+
### JavaScript Notes
|
|
298
|
+
- Preserve JavaScript evaluation order, closures, `this`, default parameters, rest/spread, and side effects.
|
|
299
|
+
|
|
300
|
+
### TypeScript Notes
|
|
301
|
+
- Use typed parameter objects and keep inference/public signatures stable; do not silence errors with casts.
|
|
302
|
+
|
|
303
|
+
### React Notes
|
|
304
|
+
- For React, extracted helpers must not violate Hook rules or capture stale values; keep event/effect ordering stable.
|
|
305
|
+
|
|
306
|
+
### Vue Notes
|
|
307
|
+
- For Vue, preserve `ref`/`reactive` unwrapping, computed dependencies, and composable lifecycle scope.
|
|
308
|
+
|
|
309
|
+
### Frontend-Craft Adaptation
|
|
310
|
+
- Prefer helpers, handlers, modules, hooks/composables, or services when they express the same intent more naturally than classes.
|
|
311
|
+
|
|
312
|
+
### Example Transformation
|
|
313
|
+
Before: modules assign `currentTenant` directly. After: expose `getCurrentTenant()` / `setCurrentTenant()` or a store action boundary.
|
|
314
|
+
|
|
315
|
+
## RF-RENAME-VARIABLE — Rename Variable
|
|
316
|
+
|
|
317
|
+
### Intent
|
|
318
|
+
Give a variable a name that communicates its role and domain meaning.
|
|
319
|
+
|
|
320
|
+
### Typical Signals
|
|
321
|
+
- Readers must infer meaning from context; the name is generic, stale, or misleading.
|
|
322
|
+
|
|
323
|
+
### Avoid When
|
|
324
|
+
- Do not churn stable domain vocabulary without evidence of confusion.
|
|
325
|
+
|
|
326
|
+
### Preconditions
|
|
327
|
+
- Current observable behavior and affected callers are understood.
|
|
328
|
+
- The target scope is inside a declared diff budget and can be verified after this one primary transformation.
|
|
329
|
+
|
|
330
|
+
### Mechanics
|
|
331
|
+
1. Choose the domain-accurate name.
|
|
332
|
+
2. Rename the declaration and all statically verified references.
|
|
333
|
+
3. Check string-based/dynamic references where relevant.
|
|
334
|
+
4. Run type/lint/tests for the affected scope.
|
|
335
|
+
|
|
336
|
+
### Behavior-Preservation Checkpoints
|
|
337
|
+
- Compare inputs, outputs, exceptions, side effects, ordering, and public contracts before/after the step.
|
|
338
|
+
- For frontend code, also check UI state, events, focus, network behavior, lifecycle/state transitions, and relevant identity semantics.
|
|
339
|
+
|
|
340
|
+
### Related Code Smells
|
|
341
|
+
- `SMELL-MYSTERIOUS-NAME`
|
|
342
|
+
|
|
343
|
+
### Composes Well With
|
|
344
|
+
- Combine only with a separately justified next transformation; no fixed sequence is required.
|
|
345
|
+
|
|
346
|
+
### JavaScript Notes
|
|
347
|
+
- Preserve JavaScript evaluation order, closures, `this`, default parameters, rest/spread, and side effects.
|
|
348
|
+
|
|
349
|
+
### TypeScript Notes
|
|
350
|
+
- Use typed parameter objects and keep inference/public signatures stable; do not silence errors with casts.
|
|
351
|
+
|
|
352
|
+
### React Notes
|
|
353
|
+
- For React, extracted helpers must not violate Hook rules or capture stale values; keep event/effect ordering stable.
|
|
354
|
+
|
|
355
|
+
### Vue Notes
|
|
356
|
+
- For Vue, preserve `ref`/`reactive` unwrapping, computed dependencies, and composable lifecycle scope.
|
|
357
|
+
|
|
358
|
+
### Frontend-Craft Adaptation
|
|
359
|
+
- Prefer helpers, handlers, modules, hooks/composables, or services when they express the same intent more naturally than classes.
|
|
360
|
+
|
|
361
|
+
### Example Transformation
|
|
362
|
+
Before: `let d` in a date-range calculation becomes `billingPeriodEnd` when that is the actual meaning.
|
|
363
|
+
|
|
364
|
+
## RF-INTRODUCE-PARAMETER-OBJECT — Introduce Parameter Object
|
|
365
|
+
|
|
366
|
+
### Intent
|
|
367
|
+
Group parameters that form one concept into a named object contract.
|
|
368
|
+
|
|
369
|
+
### Typical Signals
|
|
370
|
+
- Several values repeatedly travel together or their relationships are hidden by positional arguments.
|
|
371
|
+
|
|
372
|
+
### Avoid When
|
|
373
|
+
- Avoid a bag-of-options object when values are unrelated or the object only makes a one-off call less explicit.
|
|
374
|
+
|
|
375
|
+
### Preconditions
|
|
376
|
+
- Current observable behavior and affected callers are understood.
|
|
377
|
+
- The target scope is inside a declared diff budget and can be verified after this one primary transformation.
|
|
378
|
+
|
|
379
|
+
### Mechanics
|
|
380
|
+
1. Identify the stable parameter cluster.
|
|
381
|
+
2. Define an object/options shape with meaningful field names.
|
|
382
|
+
3. Add the object parameter and migrate callers.
|
|
383
|
+
4. Move behavior into the object only when invariants or domain behavior justify it.
|
|
384
|
+
|
|
385
|
+
### Behavior-Preservation Checkpoints
|
|
386
|
+
- Compare inputs, outputs, exceptions, side effects, ordering, and public contracts before/after the step.
|
|
387
|
+
- For frontend code, also check UI state, events, focus, network behavior, lifecycle/state transitions, and relevant identity semantics.
|
|
388
|
+
|
|
389
|
+
### Related Code Smells
|
|
390
|
+
- `SMELL-LONG-FUNCTION`
|
|
391
|
+
- `SMELL-LONG-PARAMETER-LIST`
|
|
392
|
+
- `SMELL-DATA-CLUMPS`
|
|
393
|
+
- `SMELL-PRIMITIVE-OBSESSION`
|
|
394
|
+
|
|
395
|
+
### Composes Well With
|
|
396
|
+
- Combine only with a separately justified next transformation; no fixed sequence is required.
|
|
397
|
+
|
|
398
|
+
### JavaScript Notes
|
|
399
|
+
- Preserve JavaScript evaluation order, closures, `this`, default parameters, rest/spread, and side effects.
|
|
400
|
+
|
|
401
|
+
### TypeScript Notes
|
|
402
|
+
- Use typed parameter objects and keep inference/public signatures stable; do not silence errors with casts.
|
|
403
|
+
|
|
404
|
+
### React Notes
|
|
405
|
+
- For React, extracted helpers must not violate Hook rules or capture stale values; keep event/effect ordering stable.
|
|
406
|
+
|
|
407
|
+
### Vue Notes
|
|
408
|
+
- For Vue, preserve `ref`/`reactive` unwrapping, computed dependencies, and composable lifecycle scope.
|
|
409
|
+
|
|
410
|
+
### Frontend-Craft Adaptation
|
|
411
|
+
- Prefer helpers, handlers, modules, hooks/composables, or services when they express the same intent more naturally than classes.
|
|
412
|
+
|
|
413
|
+
### Example Transformation
|
|
414
|
+
Before: `loadMessages(folderId, page, size, sort)` becomes `loadMessages({ folderId, page, size, sort })` with a typed request shape.
|
|
415
|
+
|
|
416
|
+
## RF-COMBINE-FUNCTIONS-INTO-CLASS — Combine Functions into Class
|
|
417
|
+
|
|
418
|
+
### Intent
|
|
419
|
+
Place functions that operate on shared data behind one cohesive context so their relationship is explicit.
|
|
420
|
+
|
|
421
|
+
### Typical Signals
|
|
422
|
+
- Several functions repeatedly accept the same data and calculate related results.
|
|
423
|
+
|
|
424
|
+
### Avoid When
|
|
425
|
+
- Do not force a class when a module, closure, hook, composable, or service provides the clearer frontend abstraction.
|
|
426
|
+
|
|
427
|
+
### Preconditions
|
|
428
|
+
- Current observable behavior and affected callers are understood.
|
|
429
|
+
- The target scope is inside a declared diff budget and can be verified after this one primary transformation.
|
|
430
|
+
|
|
431
|
+
### Mechanics
|
|
432
|
+
1. Identify the shared data/context and related functions.
|
|
433
|
+
2. Create the smallest cohesive owner for that context.
|
|
434
|
+
3. Move one function at a time while preserving outputs.
|
|
435
|
+
4. Choose class/module/hook/composable/service based on existing architecture.
|
|
436
|
+
|
|
437
|
+
### Behavior-Preservation Checkpoints
|
|
438
|
+
- Compare inputs, outputs, exceptions, side effects, ordering, and public contracts before/after the step.
|
|
439
|
+
- For frontend code, also check UI state, events, focus, network behavior, lifecycle/state transitions, and relevant identity semantics.
|
|
440
|
+
|
|
441
|
+
### Related Code Smells
|
|
442
|
+
- `SMELL-LONG-PARAMETER-LIST`
|
|
443
|
+
- `SMELL-MUTABLE-DATA`
|
|
444
|
+
- `SMELL-SHOTGUN-SURGERY`
|
|
445
|
+
|
|
446
|
+
### Composes Well With
|
|
447
|
+
- Combine only with a separately justified next transformation; no fixed sequence is required.
|
|
448
|
+
|
|
449
|
+
### JavaScript Notes
|
|
450
|
+
- Preserve JavaScript evaluation order, closures, `this`, default parameters, rest/spread, and side effects.
|
|
451
|
+
|
|
452
|
+
### TypeScript Notes
|
|
453
|
+
- Use typed parameter objects and keep inference/public signatures stable; do not silence errors with casts.
|
|
454
|
+
|
|
455
|
+
### React Notes
|
|
456
|
+
- For React, extracted helpers must not violate Hook rules or capture stale values; keep event/effect ordering stable.
|
|
457
|
+
|
|
458
|
+
### Vue Notes
|
|
459
|
+
- For Vue, preserve `ref`/`reactive` unwrapping, computed dependencies, and composable lifecycle scope.
|
|
460
|
+
|
|
461
|
+
### Frontend-Craft Adaptation
|
|
462
|
+
- Prefer helpers, handlers, modules, hooks/composables, or services when they express the same intent more naturally than classes.
|
|
463
|
+
|
|
464
|
+
### Example Transformation
|
|
465
|
+
Before: several pricing helpers all take the same quote. After: expose a cohesive pricing module or `useQuotePricing()` rather than mechanically introducing a class.
|
|
466
|
+
|
|
467
|
+
## RF-COMBINE-FUNCTIONS-INTO-TRANSFORM — Combine Functions into Transform
|
|
468
|
+
|
|
469
|
+
### Intent
|
|
470
|
+
Collect related derived calculations into a transform that returns the enriched result together.
|
|
471
|
+
|
|
472
|
+
### Typical Signals
|
|
473
|
+
- Many functions derive values from the same immutable input and callers need several of them.
|
|
474
|
+
|
|
475
|
+
### Avoid When
|
|
476
|
+
- Avoid when derivations are effectful, expensive but rarely used, or require independent lifecycle timing.
|
|
477
|
+
|
|
478
|
+
### Preconditions
|
|
479
|
+
- Current observable behavior and affected callers are understood.
|
|
480
|
+
- The target scope is inside a declared diff budget and can be verified after this one primary transformation.
|
|
481
|
+
|
|
482
|
+
### Mechanics
|
|
483
|
+
1. Define the input and derived output fields.
|
|
484
|
+
2. Create a pure transform that copies/enriches rather than mutating the input.
|
|
485
|
+
3. Move one calculation at a time into the transform.
|
|
486
|
+
4. Verify derived values and object identity expectations.
|
|
487
|
+
|
|
488
|
+
### Behavior-Preservation Checkpoints
|
|
489
|
+
- Compare inputs, outputs, exceptions, side effects, ordering, and public contracts before/after the step.
|
|
490
|
+
- For frontend code, also check UI state, events, focus, network behavior, lifecycle/state transitions, and relevant identity semantics.
|
|
491
|
+
|
|
492
|
+
### Related Code Smells
|
|
493
|
+
- `SMELL-MUTABLE-DATA`
|
|
494
|
+
- `SMELL-SHOTGUN-SURGERY`
|
|
495
|
+
|
|
496
|
+
### Composes Well With
|
|
497
|
+
- Combine only with a separately justified next transformation; no fixed sequence is required.
|
|
498
|
+
|
|
499
|
+
### JavaScript Notes
|
|
500
|
+
- Preserve JavaScript evaluation order, closures, `this`, default parameters, rest/spread, and side effects.
|
|
501
|
+
|
|
502
|
+
### TypeScript Notes
|
|
503
|
+
- Use typed parameter objects and keep inference/public signatures stable; do not silence errors with casts.
|
|
504
|
+
|
|
505
|
+
### React Notes
|
|
506
|
+
- For React, extracted helpers must not violate Hook rules or capture stale values; keep event/effect ordering stable.
|
|
507
|
+
|
|
508
|
+
### Vue Notes
|
|
509
|
+
- For Vue, preserve `ref`/`reactive` unwrapping, computed dependencies, and composable lifecycle scope.
|
|
510
|
+
|
|
511
|
+
### Frontend-Craft Adaptation
|
|
512
|
+
- Prefer helpers, handlers, modules, hooks/composables, or services when they express the same intent more naturally than classes.
|
|
513
|
+
|
|
514
|
+
### Example Transformation
|
|
515
|
+
Before: multiple selectors derive displayName, initials, and domain from one contact DTO. After: `toContactViewModel(dto)` returns the enriched view model.
|
|
516
|
+
|
|
517
|
+
## RF-SPLIT-PHASE — Split Phase
|
|
518
|
+
|
|
519
|
+
### Intent
|
|
520
|
+
Separate sequential concerns so each phase has a clear input/output boundary.
|
|
521
|
+
|
|
522
|
+
### Typical Signals
|
|
523
|
+
- One routine performs conceptually distinct stages whose intermediate data can be named.
|
|
524
|
+
|
|
525
|
+
### Avoid When
|
|
526
|
+
- Avoid splitting tightly interleaved work when the intermediate contract would be more complex than the original.
|
|
527
|
+
|
|
528
|
+
### Preconditions
|
|
529
|
+
- Current observable behavior and affected callers are understood.
|
|
530
|
+
- The target scope is inside a declared diff budget and can be verified after this one primary transformation.
|
|
531
|
+
|
|
532
|
+
### Mechanics
|
|
533
|
+
1. Identify the phase boundary and intermediate data.
|
|
534
|
+
2. Extract the later phase first behind an explicit input.
|
|
535
|
+
3. Extract/normalize the earlier phase.
|
|
536
|
+
4. Verify phase ordering, errors, and side effects.
|
|
537
|
+
|
|
538
|
+
### Behavior-Preservation Checkpoints
|
|
539
|
+
- Compare inputs, outputs, exceptions, side effects, ordering, and public contracts before/after the step.
|
|
540
|
+
- For frontend code, also check UI state, events, focus, network behavior, lifecycle/state transitions, and relevant identity semantics.
|
|
541
|
+
|
|
542
|
+
### Related Code Smells
|
|
543
|
+
- `SMELL-DIVERGENT-CHANGE`
|
|
544
|
+
- `SMELL-SHOTGUN-SURGERY`
|
|
545
|
+
- `SMELL-DATA-CLASS`
|
|
546
|
+
|
|
547
|
+
### Composes Well With
|
|
548
|
+
- `RF-EXTRACT-FUNCTION` when its preconditions independently hold.
|
|
549
|
+
- Move Function when its preconditions independently hold.
|
|
550
|
+
|
|
551
|
+
### JavaScript Notes
|
|
552
|
+
- Preserve JavaScript evaluation order, closures, `this`, default parameters, rest/spread, and side effects.
|
|
553
|
+
|
|
554
|
+
### TypeScript Notes
|
|
555
|
+
- Use typed parameter objects and keep inference/public signatures stable; do not silence errors with casts.
|
|
556
|
+
|
|
557
|
+
### React Notes
|
|
558
|
+
- For React, extracted helpers must not violate Hook rules or capture stale values; keep event/effect ordering stable.
|
|
559
|
+
|
|
560
|
+
### Vue Notes
|
|
561
|
+
- For Vue, preserve `ref`/`reactive` unwrapping, computed dependencies, and composable lifecycle scope.
|
|
562
|
+
|
|
563
|
+
### Frontend-Craft Adaptation
|
|
564
|
+
- Prefer helpers, handlers, modules, hooks/composables, or services when they express the same intent more naturally than classes.
|
|
565
|
+
|
|
566
|
+
### Example Transformation
|
|
567
|
+
Before: one submit function parses, normalizes, validates, and sends. After: `parse → normalize → validate → submit`, preserving error order.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: fec-refactoring-inheritance
|
|
3
|
+
description: Use when behavior-preserving frontend refactoring focuses on legacy OO hierarchies, subtype responsibilities, superclass extraction/collapse, or delegation, and the selected technique needs family-specific mechanics, risks, and JavaScript/TypeScript/React/Vue adaptation.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Inheritance Refactorings
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
Use this family after evidence identifies a fitting structural transformation. Apply one primary technique at a time and verify immediately.
|
|
10
|
+
|
|
11
|
+
## Procedure
|
|
12
|
+
1. Confirm the selected technique and its preconditions in [Inheritance Refactorings](references/inheritance-refactorings.md).
|
|
13
|
+
2. Record affected behavior and a diff budget.
|
|
14
|
+
3. Apply only the selected technique's smallest viable step.
|
|
15
|
+
4. Verify the step before composing another transformation.
|
|
16
|
+
5. Stop and reassess when public contracts, lifecycle, state identity, or actual scope exceed expectations.
|
|
17
|
+
|
|
18
|
+
## Quick Reference
|
|
19
|
+
The family reference contains 11 canonical techniques with intent, signals, avoid conditions, mechanics, preservation checkpoints, smell links, composition hints, JavaScript/TypeScript notes, React/Vue notes, adaptation guidance, and original frontend examples.
|
|
20
|
+
|
|
21
|
+
## Common Mistakes
|
|
22
|
+
- Choosing a technique by name without checking its preconditions.
|
|
23
|
+
- Combining several structural intentions in one diff.
|
|
24
|
+
- Assuming a classical class-based form is mandatory in modern frontend code.
|
|
25
|
+
- Treating passing tests as proof when the relevant behavior is not covered.
|