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
readabilityreactbooleans
Derive boolean UI flags inline to avoid explicit undefined classnames
Compute a clear derived boolean (e.g. isClamped) and use it directly rather than juggling possibly-undefined values.
PR: hegnar-forum-web · org-mining-deep-2026-06Created: Jun 17, 2026
Bad example
Old codetsx
| 1 | className={shouldTruncate && !isExpanded ? styles.clamped : undefined} |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetsx
| 1 | const isClamped = shouldTruncate && !isExpanded; |
| 2 | className={cx({ [styles.clamped]: isClamped })} |
Explanation (EN)
Objašnjenje (HR)