Back to docs
Recipe

Husky pre-commit

Catch lint and type errors before they land on your branch.

Install

npm i -D husky lint-staged

Init hooks

npx husky init

Creates .husky/pre-commit.

Hook script

# .husky/pre-commit npx lint-staged

lint-staged config

// package.json "lint-staged": { "*.{ts,tsx}": [ "eslint --fix", "tsc --noEmit" ] }

Tip: Skip hooks in emergencies with git commit --no-verify.