Rules Hub

Coding Rules Library

← Back to all rules
fullstack ruleStack: general
clean-codereadabilityjavascripttypescript

Use numeric separators for large numbers

Use underscores (_) as numeric separators for large numbers and time calculations to improve visual parsing and reduce errors.

PR: Feat/FCK-2245 - Cache Bellsheep and profile loaders with TanStack Query #343Created: Dec 10, 2025

Bad example

Old codets
1const staleTime = 1000 * 10;
2const maxFileSize = 5000000;
3const ONE_HOUR_MS = 3600000;

Explanation (EN)

Writing large numbers or unit conversions without separators makes them difficult to scan visually. It is easy to miss a zero or misinterpret the magnitude (e.g., confusing 10000 with 1000).

Objašnjenje (HR)

Pisanje velikih brojeva ili pretvorbi jedinica bez separatora otežava vizualno skeniranje. Lako je propustiti nulu ili pogrešno protumačiti veličinu (npr. zamijeniti 10000 s 1000).

Good example

New codets
1const staleTime = 1_000 * 10;
2const maxFileSize = 5_000_000;
3const ONE_HOUR_MS = 3_600_000;

Explanation (EN)

Using underscores (`_`) visually groups digits (usually by thousands) or separates units (like `1_000` ms). This makes the code self-documenting and significantly reduces the risk of reading errors.

Objašnjenje (HR)

Korištenje podvlaka (`_`) vizualno grupira znamenke (obično po tisućama) ili odvaja jedinice (poput `1_000` ms). To čini kod samodokumentirajućim i značajno smanjuje rizik od pogrešaka pri čitanju.

Notes (EN)

This is especially useful for milliseconds calculations (e.g., `1_000 * 60` for one minute).

Bilješke (HR)

Ovo je posebno korisno za izračune milisekundi (npr. `1_000 * 60` za jednu minutu).