Rules Hub
Coding Rules Library
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Guard hardcoded URL/path literals against typos and leftover edits
Literal endpoint paths aren't type-checked, so typos like 'eveqqnts' for 'events' pass compilation and break at runtime; review them and strip leftover debug edits before merge.
Bad example
| 1 | const url = new URL(`${this.apiUrl}/public/v3/eveqqnts`); // typo, compiles fine, 404 at runtime |
Explanation (EN)
A typo or leftover debugging change in a string literal endpoint is invisible to the compiler and only surfaces as a runtime failure.
Objašnjenje (HR)
Tipfeler ili zaostala debug izmjena u string literalu krajnje tocke nevidljiva je prevoditelju i pojavljuje se tek kao pogreska u izvodenju.
Good example
| 1 | const EVENTS_PATH = '/public/v3/events'; |
| 2 | const url = new URL(`${this.apiUrl}${EVENTS_PATH}`); // single named constant, easy to review/reuse |
Explanation (EN)
Hoisting the path into a named constant makes the value reviewable in one place, reusable, and harder to corrupt with a stray edit.
Objašnjenje (HR)
Izdvajanje putanje u imenovanu konstantu cini vrijednost preglednom na jednom mjestu, ponovno iskoristivom i tezom za pokvariti slucajnom izmjenom.