Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
frontend ruleP2universalStack: react
testingreactseparation-of-concernstestability
Extract non-trivial component logic into testable functions
Pull formatting/derivation logic out of components into standalone functions so it can be unit-tested directly, and add tests for the variants that matter.
PR: frontpage-web · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetsx
| 1 | render() { |
| 2 | const label = /* 20 lines of derivation */; |
| 3 | return <span>{label}</span>; |
| 4 | } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | export function buildLabel(item: Item): string { /* ... */ } |
| 2 | // component: const label = buildLabel(item); |
Explanation (EN)
Objašnjenje (HR)