Husky Pre-commit Lint Hook Blocking CI - Fix in CI
A Husky pre-commit hook runs lint-staged (ESLint/Prettier) on commit. It can block a CI bot's commit, or fail because staged files have lint/format violations - turning a local convenience into a pipeline blocker.
What this error means
A commit in CI (release bot, automated bump) fails at the pre-commit hook with lint-staged errors, or Husky tries to run in an environment with no Node/ESLint. The same commit succeeds locally.
husky - pre-commit script failed (code 1)
✖ eslint --max-warnings 0 --fix:
/app/src/App.tsx
12:7 error 'foo' is assigned a value but never used no-unused-vars
husky - command not found (in CI without dev deps)Common causes
Staged files violate lint/format rules
lint-staged runs ESLint/Prettier on staged files; any violation fails the hook, blocking the commit (including automated commits in CI).
Hooks running in CI without the toolchain
Husky installs Git hooks; in a CI step that commits, the hook fires but ESLint/Prettier may be absent (dev deps pruned) or undesired entirely.
How to fix it
Fix the violations or run the same check in CI
- Run lint-staged locally (
npx lint-staged) and fix the reported violations before committing. - Mirror the hook's lint/format command as a normal CI job so the gate is explicit, not hidden in a commit hook.
- Keep
--max-warnings 0consistent between the hook and CI.
Skip hooks for trusted automated commits
Disable Husky for CI bot commits that should not be re-linted, or guard installation.
# skip hooks for an automated commit
git commit -m "chore: release" --no-verify
# or disable Husky install in CI: HUSKY=0 npm ciHow to prevent it
- Run lint-staged locally so violations are caught before commit.
- Mirror the hook's checks as explicit CI jobs, not only in the commit hook.
- Set
HUSKY=0for CI steps that legitimately should not run hooks.