Rules Hub
Code Ruleset
← 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: javascript
booleansreadabilitynitpick
Don't compare booleans to true/false explicitly
Use a boolean expression directly in conditions instead of `=== true`/`=== false` or ternaries that just remap booleans.
PR: frontpage-web · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetypescript
| 1 | if (alternativeEnabled === true) {} |
| 2 | const checkLng = props.lng === 'da' ? false : true; |
Explanation (EN)
For a known boolean, the strict comparison adds no information; broader input domains can behave differently.
Objašnjenje (HR)
Good example
New codetypescript
| 1 | if (alternativeEnabled) {} |
| 2 | const checkLng = props.lng !== 'da'; |
Explanation (EN)
Objašnjenje (HR)
Notes (EN)
Simplify equality-to-boolean checks only when the operand is known to be boolean. For boolean-valued ternaries, preserve coercion and nullability semantics.
Exceptions / Tradeoffs (EN)
Keep strict comparisons for boolean-or-unknown inputs, tri-state flags and checks that intentionally reject truthy non-booleans.