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 ruleP1universalStack: javascript
dateformattingrelative-timei18n
Don't hardcode a single unit when formatting relative time
Use a relative-time formatter that picks the right unit (m/h/d) instead of fixing the label to minutes.
PR: hegnar-web · org-mining-hist-2026-06Created: Jun 19, 2026
Bad example
Old codejavascript
| 1 | const label = `${diffMinutes}m`; // shows 1869m for a 2-day-old item |
Explanation (EN)
Objašnjenje (HR)
Good example
New codejavascript
| 1 | const label = formatRelativeTime(date); // "2d", "3h", "5m" |
Explanation (EN)
Objašnjenje (HR)