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).
Run the dev watch loop from source rather than an uncleaned build directory
Recompiling into an output directory on every save without clearing it leaves files from renamed or deleted modules behind, and those stale artifacts keep executing and mask the change you just made.
Bad example
| 1 | // nodemon.json |
| 2 | { "exec": "tsc && node dist/server" } |
| 3 |
|
| 4 | // Rename src/timer.ts -> src/utils/timer.ts |
| 5 | // dist/timer.js remains and is still imported and executed. |
Explanation (EN)
The output directory accumulates orphaned files, so behaviour on disk no longer matches the source tree and the loop pays a full compile on every keystroke-triggered save.
Objašnjenje (HR)
Izlazni direktorij nakuplja napustene datoteke, pa se ponasanje na disku vise ne podudara sa stablom izvornog koda, a petlja placa puno prevodenje pri svakom spremanju.
Good example
| 1 | // Run the TypeScript sources directly - no intermediate directory in the loop |
| 2 | { "exec": "node --watch --env-file=.env src/server.ts" } |
Explanation (EN)
Nothing is emitted during development, so a renamed or deleted file disappears immediately and there is no stale output to execute.
Objašnjenje (HR)
Tijekom razvoja nista se ne emitira, pa preimenovana ili obrisana datoteka odmah nestaje i nema zastarjelog izlaza za izvrsavanje.
Notes (EN)
If the loop must compile, clean the output directory first. Modern Node runs TypeScript directly once enums are replaced with const objects or `erasableSyntaxOnly` is satisfied.
Bilješke (HR)
Ako petlja mora prevoditi, prvo ocisti izlazni direktorij. Moderni Node izvrsava TypeScript izravno kad se enumi zamijene const objektima ili se zadovolji `erasableSyntaxOnly`.