- husky
- lint-staged
- @commitlint/cli
- @commitlint/config-conventional
- A
.huskydirectory - A
preparescript - A
lint-stagedconfig
Why wit Hooks Replace Husky
Quick Start
Configuration File
wit uses.wit/hooks.json for hook configuration:
Config Locations
wit looks for config in these locations (in order):.wit/hooks.json(recommended)wit.config.jsonpackage.jsonunder"wit"key
Available Hooks
Commands
Setup Hooks
Add Hook Commands
Sync Configuration
List Hooks
Other Commands
Lint-Staged Style Configuration
Thestaged config runs commands only on staged files matching patterns:
Pattern Syntax
- Uses JavaScript regex patterns
- Files are passed as arguments to commands
- Use
{}placeholder to control file position:
Automatic Setup with npm
Add to yourpackage.json:
npm install.
Hook Definition Formats
Simple String
Array of Commands
Full Definition Object
Writing Custom Hooks
Basic Structure
Hooks are shell scripts in.wit/hooks/:
Pre-commit Hook
Block commits that don’t meet criteria:Commit Message Validation
Pre-push Hook
Run tests before pushing:Bypassing Hooks
Use--no-verify to skip hooks:
Hook Environment
Hooks have access to these environment variables:Migration from Husky
Before (Husky + lint-staged)
After (wit only)
- husky
- lint-staged
- @commitlint/cli (use wit’s built-in validation)
Best Practices
Troubleshooting
Hook not running
Hook not running
- Check if hooks are synced:
wit hooks - Run sync:
wit hooks sync - Check permissions:
ls -la .wit/hooks/
Config changes not applied
Config changes not applied
Run
wit hooks sync after editing .wit/hooks.jsonBypassing hooks temporarily
Bypassing hooks temporarily
Use the
--no-verify flag:Hooks work locally but not for team
Hooks work locally but not for team
Ensure:
.wit/hooks.jsonis committedpostinstallscript callswit hooks sync- Team members run
npm installafter pulling