Skip to content

Husky + lint-staged

Terminal window
tinkerise add husky

The husky module checks for:

  • An existing .husky/ directory
  • An installed husky dependency
  • A prepare script that references Husky (reported as detection context)
  • husky
  • lint-staged

The install flow is adaptive:

  • Requires a .git directory; otherwise installation fails with a warning (git init first)
  • Creates .husky/pre-commit with npx lint-staged
  • Writes lint-staged config in package.json based on what tooling exists:
    • Adds eslint --fix rules when ESLint is installed
    • Adds prettier --write rules when Prettier is installed
  • Adds prepare script: husky
  • Creates .husky/pre-commit with npx lint-staged
  • Writes lint-staged config in package.json

Expected outcome after tinkerise add husky:

  • Commits run staged-file checks automatically
  • Pre-commit behavior matches your currently installed lint/format stack

If Husky is already detected, interactive execution can show diffs and allow accept/skip decisions before finalizing writes.