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 variables for what they actually hold
Pick identifiers that match the real meaning of the value; avoid misnomers like calling a host URL a 'repository'.
Bad example
| 1 | // Holds a host origin/URL, but named as if it were a repository |
| 2 | app.locals.componentsRepositoryUrl = resolveComponentsUrl(); |
Explanation (EN)
'componentsRepositoryUrl' implies a code repository, but the value is just the host URL/origin used for preconnect. The name actively misleads the next reader about what the value is.
Objašnjenje (HR)
Naziv 'componentsRepositoryUrl' sugerira repozitorij koda, ali vrijednost je samo URL/origin hosta koji se koristi za preconnect. Takav naziv aktivno zavarava sljedećeg čitatelja o tome što vrijednost zapravo predstavlja.
Good example
| 1 | // Name says exactly what it is: a URL/origin of the components host |
| 2 | app.locals.componentsUrl = resolveComponentsUrl(); |
Explanation (EN)
'componentsUrl' (or 'componentsOrigin') describes the value precisely. The identifier carries the truth, so readers don't have to chase the definition to learn what it really is.
Objašnjenje (HR)
'componentsUrl' (ili 'componentsOrigin') precizno opisuje vrijednost. Identifikator nosi istinu pa čitatelji ne moraju tražiti definiciju da bi saznali što ona zapravo jest.
Notes (EN)
When in doubt, name by the concept (URL, origin, id, count) rather than by an adjacent system you happened to read it from.
Bilješke (HR)
Kad ste u nedoumici, imenujte prema konceptu (URL, origin, id, count) umjesto prema susjednom sustavu iz kojeg ste vrijednost slučajno pročitali.