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).
Keep pre-commit hook globs consistent with the tool's own ignore list
When a hook passes a file the underlying tool is configured to ignore, the tool can exit non-zero because it was given nothing to do, rejecting a legitimate commit with a message that does not explain itself.
Bad example
| 1 | # lefthook.yml |
| 2 | format: |
| 3 | glob: "*.{js,ts,json}" # matches package.json |
| 4 | run: oxfmt {staged_files} |
| 5 |
|
| 6 | # .oxfmtrc.json |
| 7 | { "ignorePatterns": ["package.json"] } # ...which oxfmt then refuses to format |
| 8 |
|
| 9 | $ git commit -m "bump deps" # only package.json staged |
| 10 | Expected at least one target file. All matched files may have been excluded. |
| 11 | exit status 2 |
Explanation (EN)
The two configs disagree about the same file, so a routine dependency bump is rejected by an error that names neither config.
Objašnjenje (HR)
Dvije konfiguracije se ne slazu oko iste datoteke, pa je rutinsko podizanje ovisnosti odbijeno greskom koja ne imenuje nijednu od njih.
Good example
| 1 | # lefthook.yml - the glob matches only what the tool will actually process |
| 2 | format: |
| 3 | glob: "*.{js,ts}" |
| 4 | run: oxfmt {staged_files} |
Explanation (EN)
The hook only hands over files the tool accepts, so it can never fail on an empty target set.
Objašnjenje (HR)
Hook predaje samo datoteke koje alat prihvaca, pa nikad ne moze pasti na praznom skupu ciljeva.
Notes (EN)
Test a hook by staging each edge-case set on its own: only the manifest, only docs, only ignored paths. Those are where an empty target set appears.
Bilješke (HR)
Testiraj hook tako da posebno stagea svaki rubni skup: samo manifest, samo dokumentaciju, samo ignorirane putanje. Ondje se pojavljuje prazan skup ciljeva.