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
reactreadabilitystate
Set boolean state directly from the condition, but keep intent explicit
When a flag mirrors a boolean expression, set it directly (setX(cond)); if branches encode distinct intent, keep them explicit rather than collapsing for brevity.
PR: hegnar-forum-web · org-mining-3rd-2026-06Created: Jun 18, 2026
Bad example
Old codets
| 1 | const exceeds = el.scrollHeight > el.clientHeight; |
| 2 | if (exceeds) { |
| 3 | setIsTruncatable(true); |
| 4 | } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codets
| 1 | const exceeds = el.scrollHeight > el.clientHeight; |
| 2 | setIsTruncatable(exceeds); |
Explanation (EN)
Objašnjenje (HR)