GitHook
We are going to use the git pre-commit hook to make sure the code gets prettified before committing it.
Install Husky
Husky can prevent bad
git commit,git pushand more 🐶 woof!
$ yarn add husky pretty-quick -DAdd the following to the root package.json
"husky": {
"hooks": {
"pre-commit": "pretty-quick --staged"
}
}Make sure husky is install
$ node node_modules/husky/lib/installer/bin installAdd it to postinstall to automate the process:
"scripts": {
"postinstall": "lerna bootstrap && node node_modules/husky/lib/installer/bin install"
}When we commit, we should now see a message similar to this one:
🔍 Finding changed files since git revision 5053732.
🎯 Found 2 changed files.
✍️ Fixing up packages/api/index.ts.
✅ Everything is awesome!Last updated
Was this helpful?