You've just made some adjustments to a project or added a new feature. You make a pull request and wait a couple very lengthy minutes just for your CI/CD setup to spit out:
🚨 Lint error!🚨 😡
That's when you realize that you didn't save the file, or that you didn't git add it. 🤦♂️
This adds up and is a waste of time! Even worse if it fails in the build step...
This is where husky comes in! 🐕
As you can see husky makes it so that you can run a set of steps before your git commands go through. And it is extremely simple to setup:
- Install husky
npm install husky --save-dev
- Config
// Inside package.json
// ...
"husky": {
"hooks": {
"pre-commit": "command-or-script-you-want-to-run-here"
}
},
//...
Pre-commit means before commit. Pre-push would be before push and so on... Husky rejects your git command if all the steps aren't successful.
And that's it. Best part is that everyone working on a project now has this simple check.
Check out husky
My links:
GitHub: https://github.com/ymirke
Medium: https://ymirke.medium.com/
LinkedIn: https://www.linkedin.com/in/ymirke
Top comments (1)
one of the most useful tools out there