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: typescript
readabilitydrydestructuring
Compute paired conditional values once via array destructuring
When two related values switch together on one condition, derive them in a single ternary with array destructuring instead of repeating the condition.
PR: hegnar-forum-web · org-mining-hist-2026-06Created: Jun 20, 2026
Bad example
Old codetsx
| 1 | const buttonText = count ? `In ${count} lists` : 'Add'; |
| 2 | const icon = count ? <Filled /> : <Outlined />; |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetsx
| 1 | const [buttonText, icon] = count |
| 2 | ? [`In ${count} lists`, <Filled />] |
| 3 | : ['Add', <Outlined />]; |
Explanation (EN)
Objašnjenje (HR)