Rules Hub
Code Ruleset
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)
Duplicating run-once arguments across callers can diverge from the documented package script.
Objašnjenje (HR)
Ponavljanje argumenata za jedno izvršavanje među pozivateljima može se razići s dokumentiranom package skriptom.
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)
For CI or hooks, inspect the configured test/build command in that environment and invoke an explicit run-once package script where ambiguity remains.
Bilješke (HR)
Za CI i hookove provjeri kako se naredba za testiranje ili build ponaša u tom okruženju. Ako postoji dvojba, pozovi izričitu package skriptu za jedno izvršavanje.
Exceptions / Tradeoffs (EN)
Some runners automatically disable watching in CI; verify actual configuration before claiming a job hangs. Keep a separate watch command for development.