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
reactearly-returnreadability
Use early-exit rendering instead of mapping that returns null
When iterating a heterogeneous list, return early for the irrelevant branches up front so the render path reads clearly.
PR: vinify-frontend · org-mining-hist-2026-06Created: Jun 19, 2026
Bad example
Old codetsx
| 1 | rows.map(item => { |
| 2 | if (item.type === Type.RSS) return <Rss key={item.id} />; |
| 3 | return null; |
| 4 | }) |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetsx
| 1 | rows.map(item => { |
| 2 | if (item.type !== Type.RSS) return null; |
| 3 | return <Rss key={item.id} />; |
| 4 | }) |
Explanation (EN)
Objašnjenje (HR)