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).
Point automation at a non-interactive script, and keep it in sync with the documented one
When a hook or CI job inlines a run-once command while the package script it shadows still starts a watcher, the enforced and documented commands diverge and anything calling the documented one hangs forever.
Bad example
| 1 | // package.json |
| 2 | { "scripts": { "test": "vitest" } } // watch mode - never exits |
| 3 |
|
| 4 | # lefthook.yml |
| 5 | test: |
| 6 | run: vitest run // diverged: hook bypasses the script |
Explanation (EN)
CI or any script calling the documented command gets a process that never exits, and the two definitions of 'run the tests' drift apart with nothing to catch it.
Objašnjenje (HR)
CI ili bilo koja skripta koja poziva dokumentiranu naredbu dobije proces koji se nikad ne zavrsava, a dvije definicije 'pokreni testove' razilaze se bez ikakve provjere.
Good example
| 1 | // package.json |
| 2 | { |
| 3 | "scripts": { |
| 4 | "test": "vitest", |
| 5 | "test:run": "vitest run" |
| 6 | } |
| 7 | } |
| 8 |
|
| 9 | # lefthook.yml |
| 10 | test: |
| 11 | run: pnpm test:run // one definition, referenced everywhere |
Explanation (EN)
The run-once command exists as a named script, and every automated caller references it instead of restating it.
Objašnjenje (HR)
Naredba za jednokratno pokretanje postoji kao imenovana skripta, a svaki automatizirani pozivatelj referencira nju umjesto da je ponavlja.
Notes (EN)
The same applies to build and lint: automation should invoke package scripts so there is one place to change the command.
Bilješke (HR)
Isto vrijedi za build i lint: automatizacija bi trebala pozivati skripte iz paketa kako bi postojalo jedno mjesto za promjenu naredbe.