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).
Add a shebang only when the script is run directly
Don't include a #!/usr/bin/env node shebang unless the file is executable and invoked as ./script rather than via node/npm.
Bad example
| 1 | #!/usr/bin/env node |
| 2 | // invoked only via: pnpm run task -> node scripts/task.ts |
| 3 | import { run } from './shared.ts'; |
| 4 | await run(); |
Explanation (EN)
If the script is always launched through `node` or an npm script and is never made executable, the shebang line is unused preamble.
Objašnjenje (HR)
Ako se skripta uvijek pokrece preko `node`-a ili npm skripte i nikad nije executable, shebang linija je neiskoristen preambl.
Good example
| 1 | // invoked via: pnpm run task -> node scripts/task.ts |
| 2 | import { run } from './shared.ts'; |
| 3 | await run(); |
Explanation (EN)
Drop the shebang when it serves no purpose. Add it back only if you chmod +x the file and run it as ./scripts/task.ts.
Objašnjenje (HR)
Izbaci shebang kad nema svrhu. Vrati ga samo ako napravis chmod +x na datoteci i pokreces je kao ./scripts/task.ts.
Exceptions / Tradeoffs (EN)
Keep the shebang for files that are genuinely executable CLIs run directly (chmod +x and ./path or installed via package bin).
Iznimke / Tradeoffi (HR)
Zadrzi shebang za datoteke koje su stvarno executable CLI-jevi pokretani izravno (chmod +x i ./path ili instalirani preko package bin).