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: javascript
readabilitymathsimplification
Use Math.min/Math.max to clamp values instead of a ternary
Replace `x > limit ? limit : x` style clamping with `Math.min(limit, x)` (or `Math.max`) for clarity.
PR: hegnar-forum-web · org-mining-hist-2026-06Created: Jun 20, 2026
Bad example
Old codets
| 1 | minimumFractionDigits: decimalPart.length > 2 ? 2 : decimalPart.length, |
Explanation (EN)
Objašnjenje (HR)
Good example
New codets
| 1 | minimumFractionDigits: Math.min(2, decimalPart.length), |
Explanation (EN)
Objašnjenje (HR)