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).
Name computed values after their standardized platform meaning, not an ad hoc synonym
When a variable represents a well-known concept (e.g. protocol + host), use the platform-standard name for it (`origin`) instead of inventing a new name (`baseUrl`) — otherwise every reader has to relearn what the custom name means.
Bad example
| 1 | const baseUrl = `${protocol}://${host}`; |
| 2 | const canonicalUrl = `${baseUrl}${req.path}`; |
Explanation (EN)
`baseUrl` is a made-up name for a concept that already has a standardized term (`origin`, as in `window.location.origin` / `new URL(...).origin`). Coining new names for existing concepts means the team accumulates synonyms and loses a shared vocabulary.
Objašnjenje (HR)
`baseUrl` je izmisljeno ime za koncept koji vec ima standardizirani naziv (`origin`, kao u `window.location.origin` / `new URL(...).origin`). Smisljanje novih imena za postojece koncepte znaci da tim gomila sinonime i gubi zajednicki rjecnik.
Good example
| 1 | const origin = `${protocol}://${host}`; |
| 2 | const canonicalUrl = `${origin}${req.path}`; |
Explanation (EN)
Using the platform-standard name (`origin`) makes the value immediately recognizable and searchable, and keeps it consistent with how the same concept is named elsewhere in the stack.
Objašnjenje (HR)
Koristenje standardnog naziva platforme (`origin`) cini vrijednost odmah prepoznatljivom i pretrazivom, te je drzi dosljednom s time kako se isti koncept naziva drugdje u stacku.
Notes (EN)
Applies to any value with an established platform/spec name (origin, pathname, hostname, etc.) — check for an existing standard term before naming a derived value.
Bilješke (HR)
Vrijedi za svaku vrijednost s ustaljenim nazivom platforme/specifikacije (origin, pathname, hostname, itd.) — provjeri postoji li vec standardni naziv prije nego imenujes izvedenu vrijednost.