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).
Don't name variables after type keywords like `unknown`
Avoid TypeScript reserved/type words (unknown, any, never, object) as variable names; pick a descriptive name instead.
Bad example
| 1 | const unknown = new Set(envs).difference(VALID_ENVS); |
| 2 | if (unknown.size) { |
| 3 | console.error(`Unknown env(s): ${[...unknown].join(', ')}`); |
| 4 | } |
Explanation (EN)
`unknown` is a TypeScript type keyword. Using it as a variable name is confusing and will outright break if the file is ever migrated to TypeScript.
Objašnjenje (HR)
`unknown` je TypeScript kljucna rijec za tip. Koristenje kao naziv varijable zbunjuje i potpuno ce puknuti ako se datoteka ikad migrira na TypeScript.
Good example
| 1 | const unknownEnvs = new Set(envs).difference(VALID_ENVS); |
| 2 | if (unknownEnvs.size) { |
| 3 | console.error(`Unknown env(s): ${[...unknownEnvs].join(', ')}`); |
| 4 | } |
Explanation (EN)
A descriptive name (`unknownEnvs`) avoids the keyword clash and reads better. Since Node can run TypeScript directly, write new scripts in TS so the type checker catches such issues.
Objašnjenje (HR)
Opisni naziv (`unknownEnvs`) izbjegava sudar s kljucnom rijeci i citljiviji je. Buduci da Node moze izravno pokretati TypeScript, nove skripte pisi u TS-u da type checker uhvati ovakve probleme.
Notes (EN)
Same caution applies to other type keywords used as identifiers (any, never, object, string, number).
Bilješke (HR)
Isti oprez vrijedi i za druge kljucne rijeci tipova koristene kao identifikatori (any, never, object, string, number).