Rules Hub
Code Ruleset
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
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.
Bad example
| 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)
Manual replacement of a few standard month names can miss other locales and months.
Objašnjenje (HR)
Good example
| 1 | const month = format(new Date(), 'MMM', { locale }); |
Explanation (EN)
Objašnjenje (HR)
Notes (EN)
Use the existing locale formatter for standard month/day names, verifying abbreviation and grammatical context against the design.
Exceptions / Tradeoffs (EN)
Product-specific abbreviations can intentionally differ from the locale standard and need an explicit mapping. Do not add a new date dependency solely for a format already supported by Intl or existing tooling.