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).
fullstack ruleP2universalStack: typescript
readabilitysimplificationternary
Remove a ternary whose false branch returns the same value
An expression like `x ? transform(x) : x` is clearer as a guarded transform; if the false branch just returns the original (possibly falsy) value, the conditional often signals confused intent. Simplify or rethink the logic.
PR: frontpage-web · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetypescript
| 1 | const quizEmbed = article?.quizEmbed ? addPaywallQuiz(article?.quizEmbed) : article?.quizEmbed; |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | const quizEmbed = article?.quizEmbed && addPaywallQuiz(article.quizEmbed); |
Explanation (EN)
Objašnjenje (HR)