Skip to content

Commit 2c7b214

Browse files
committed
fix(lefthook): add --no-error-on-unmatched-pattern to oxfmt
oxfmt ignores certain files (lock files, CHANGELOGs, snapshots) via its built-in rules. When only such files are staged, oxfmt exits with code 2 because no target files remain after its ignore rules are applied. Adding --no-error-on-unmatched-pattern makes oxfmt exit 0 in this case, preventing false hook failures.
1 parent 85f42cb commit 2c7b214

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

lefthook.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ pre-commit:
33
commands:
44
oxfmt:
55
glob: "*.{ts,tsx,js,jsx,mjs,cjs,json,jsonc,md,mdx,yaml,yml,css,html}"
6-
run: pnpm exec oxfmt {staged_files}
6+
# --no-error-on-unmatched-pattern: oxfmt has built-in ignore rules (lock files,
7+
# CHANGELOGs, etc.) that may exclude all staged files after lefthook's glob
8+
# matches them. Without this flag, oxfmt exits with code 2 when no files remain.
9+
run: pnpm exec oxfmt --no-error-on-unmatched-pattern {staged_files}
710
stage_fixed: true
8-
skip_empty: true

0 commit comments

Comments
 (0)