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 ruleP1universalStack: javascript
datesi18ndate-fnsduplication
Format dates with a date library, not manual mappings
Use a date-formatting library (date-fns etc.) for month/day/weekday names instead of hand-written if/else string replacement.
PR: frontpage-web · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetypescript
| 1 | let month = format(new Date(), 'MMMM', { locale }); |
| 2 | if (month === 'september') month = 'sept.'; |
| 3 | else if (month === 'november') month = 'nov.'; |
| 4 | else if (month === 'desember') month = 'des.'; |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | const month = format(new Date(), 'MMM', { locale }); |
Explanation (EN)
Objašnjenje (HR)