💻
Building and hosting a WebApp
  • Getting started
  • Project setup
    • Requirements
    • Files organisation
    • Lerna
    • Linter
    • Prettier
    • GitHook
    • Testing
    • Conclusion
  • Backend
    • Files organisation
    • Environment config
    • Express API
    • Security
    • Database
    • GraphQL
    • User authentication
    • Conclusion
  • Frontend
    • Create React App
    • Files organisation
    • Styles
    • Apollo Hooks
    • Form management
    • User authentication
    • Writing tests
    • Types generation
    • Conclusion
  • DevOps
    • CI/CD
    • AWS
      • Managing secrets
      • Pricing
      • RDS
      • S3
      • Route53
      • CloudFront
      • Serverless
      • Security
      • CloudFormation
    • Conclusion
  • 🚧Stripe payment
  • 🚧File upload
Powered by GitBook
On this page

Was this helpful?

  1. Project setup

GitHook

PreviousPrettierNextTesting

Last updated 5 years ago

Was this helpful?

We are going to use the git pre-commit to make sure the code gets prettified before committing it.

Install 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!

branch available on GitHub.

hook
Husky
prettier