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 push and more 🐶 woof!

$ yarn add husky pretty-quick -D

Add the following to the root package.json

package.json
"husky": {
  "hooks": {
    "pre-commit": "pretty-quick --staged"
  }
}

Make sure husky is install

$ node node_modules/husky/lib/installer/bin install

Add it to postinstall to automate the process:

package.json
"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!

prettierbranch available on GitHub.

Last updated

Was this helpful?