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
reactreadabilityconditionalsdry
Consolidate repeated render conditions into one block
When several adjacent JSX elements all gate on the same variant/condition, wrap them in a single conditional block instead of repeating the check on each line.
PR: vinify-frontend · org-mining-hist-2026-06Created: Jun 19, 2026
Bad example
Old codetsx
| 1 | {variant === PRICE && <Text>{desc1}</Text>} |
| 2 | {variant === PRICE && <br />} |
| 3 | {variant === PRICE && <Text>{desc2}</Text>} |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetsx
| 1 | {variant === PRICE && ( |
| 2 | <> |
| 3 | <Text>{desc1}</Text> |
| 4 | <br /> |
| 5 | <Text>{desc2}</Text> |
| 6 | </> |
| 7 | )} |
Explanation (EN)
Objašnjenje (HR)