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 ruleP2stack specificStack: react
reactrefactoringcomponentsreadability
Finish extracting logic instead of leaving it half-inline
When pulling logic out of a map/loop into a helper, extract all of it (often into a named component) rather than leaving part as an inline function, which is messier than before.
PR: hegnar-web · org-mining-hist-2026-06Created: Jun 19, 2026
Bad example
Old codetsx
| 1 | {groups.map((group, index) => { |
| 2 | const label = computeLabel(group); |
| 3 | return ( |
| 4 | <dl key={index}> |
| 5 | {/* large inline body still here */} |
| 6 | </dl> |
| 7 | ); |
| 8 | })} |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetsx
| 1 | const ContactField: FC<ContactFieldProps> = ({ group, index }) => { |
| 2 | const label = computeLabel(group); |
| 3 | return <dl key={index}>{/* ... */}</dl>; |
| 4 | }; |
| 5 |
|
| 6 | {groups.map((group, index) => <ContactField key={index} group={group} index={index} />)} |
Explanation (EN)
Objašnjenje (HR)