Skip to content
Latchkey

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
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

  1. Run lint-staged locally (npx lint-staged) and fix the reported violations before committing.
  2. Mirror the hook's lint/format command as a normal CI job so the gate is explicit, not hidden in a commit hook.
  3. Keep --max-warnings 0 consistent 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.

Terminal
# skip hooks for an automated commit
git commit -m "chore: release" --no-verify
# or disable Husky install in CI: HUSKY=0 npm ci

How 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=0 for CI steps that legitimately should not run hooks.

Frequently asked questions

What causes "husky pre-commit blocks CI"?
lint-staged runs ESLint/Prettier on staged files; any violation fails the hook, blocking the commit (including automated commits in CI).
How do I fix husky pre-commit blocks CI?
Fix the violations or run the same check in CI

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card