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 / JavaScript
clean-coderedundancysimplification
Remove conditional defaulting that produces the same value either way
A guard like 'if x>0 use x else 0' on a non-negative value is a no-op; drop it. Push defaults into getters instead of building parallel objects.
PR: hegnar-ws · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetypescript
| 1 | const value = portfolioValue > 0 ? portfolioValue : 0; |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | private get _valueBought(): number { |
| 2 | return this.data.valueBought || 0; |
| 3 | } |
Explanation (EN)
Objašnjenje (HR)