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
reactclassnamesreadability
Collapse mutually exclusive className conditions into one expression
For a binary either/or class choice, use a single ternary instead of two separate object-syntax `cx` conditions.
PR: hegnar-forum-web · org-mining-hist-2026-06Created: Jun 20, 2026
Bad example
Old codetsx
| 1 | className={cx({ [styles.row]: leftAligned }, { [styles.rowReverse]: !leftAligned })} |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetsx
| 1 | className={leftAligned ? styles.row : styles.rowReverse} |
Explanation (EN)
Objašnjenje (HR)