#17347: fix(pre-commit): fail fast when lint/format tooling is unavailable
stale
size: XS
Cluster:
Hooks Enhancements and Fixes
## Summary
- switch git pre-commit hook to bash fail-fast mode (`set -euo pipefail`)
- route tool execution through `scripts/pre-commit/run-node-tool.sh` so pnpm/bun/npm fallbacks work
- preserve staged-file handling with NUL-delimited paths and safe re-stage via `git add --`
## Why
The previous hook could print errors (for example, missing `pnpm`) and still exit 0, allowing commits to pass without running lint/format.
## Verification
- reproduced old behavior: commit succeeded even when pre-commit printed `xargs: pnpm: No such file or directory`
- verified new behavior with controlled hook fixtures:
- missing helper -> non-zero exit
- failing tool runner -> non-zero exit
- successful runner with spaced filenames -> success and correct arg passing
No runtime product behavior changed; this is repository tooling hardening.
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Simplified pre-commit hook by removing file type filtering logic. The hook now passes all staged files to `oxlint` and `oxfmt`, relying on these tools to filter by extension internally. The `--no-error-on-unmatched-pattern` flag on `oxfmt` ensures it doesn't fail on non-code files. Maintains NUL-delimited file handling and package manager fallback routing.
<h3>Confidence Score: 3/5</h3>
- Safe to merge after fixing option injection vulnerability
- The PR correctly adds fail-fast error handling and package manager fallback routing. However, it's missing the `--` separator before file arguments in both oxlint and oxfmt calls, which creates an option injection vulnerability if a file is named like `--all`. The base commit had this protection. Additionally, the PR removes file type filtering logic, now relying on the tools to filter internally - this should work but represents a behavior change that warrants testing with non-code files in the staging area.
- git-hooks/pre-commit needs the `--` separator added to prevent option injection
<sub>Last reviewed commit: 5577a9a</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#22425: chore: make prepare git hooks setup cross-platform
by OldFineDev · 2026-02-21
76.8%
#9914: fix(hooks): resolve bundled hook dist paths and packaging checks
by zimmra · 2026-02-05
74.2%
#11817: fix(build): compile bundled hook handlers into dist
by AnonO6 · 2026-02-08
74.0%
#11432: fix(security): add --ignore-scripts to npm install in hook and plug...
by coygeek · 2026-02-07
73.1%
#11980: CLI: add external message lint + warn on tables/mentions
by moestradamos · 2026-02-08
72.6%
#3973: fix: enhance npm package integrity checks and include critical files
by YeSuX · 2026-01-29
72.5%
#16960: perf: skip cache-busting for bundled hooks, use mtime for workspace...
by mudrii · 2026-02-15
71.3%
#3392: fix(hooks): remove debug console.log statements from session-memory...
by WinJayX · 2026-01-28
71.2%
#22383: Chore: apply oxfmt baseline for CI check
by bmendonca3 · 2026-02-21
70.6%
#6596: Fix pre-existing formatting issues causing CI failures
by ryancnelson · 2026-02-01
70.6%