DEV Community


I've replaced husky with simple-git-hooks

acro5piano profile image Kay Gosho ・2 min read

I've been using husky for over 2 years and was a big fan of it. However, husky v5 enforces us to update our husky configuration.

Since v5 design concept is completely different from v4, we should update husky configuration file and create .husky directory regarding to the documentation. Then add some test commits and confirms our migration has been completed.

To be honest, I was disappointed these changes. I understand maintaining OSS is a hard task and there should be an appropriate reason, but I don't want to "migrate" these changes. "Just work" is the best and there should not be a long documentation.

My colleague's PC didn't trigger a pre-commit hook which made me mad. I'm sorry for people who sends pull requests to my own OSS.

Furthermore, I personally don't like the design of husky v5. Why we should create the .husky directory, what will happen on husky install? What is and .husky/_?

Also, husky changes .git/config without confirmation, which might cause issues using with other git hooks tools. I just wanted to run Prettier before git commit!

I've ended up to say goodbye to husky and install simple-git-hooks. It works like a charm!

The setup is pretty easy. All we should do is:

yarn add -D simple-git-hooks
Enter fullscreen mode Exit fullscreen mode
  "scripts": {
    "prepare": "simple-git-hooks"
  "simple-git-hooks": {
    "pre-commit": "npx lint-staged"
Enter fullscreen mode Exit fullscreen mode

I'll live with simple-git-hooks. Thank you @toplenboren .

If you migrate from husky, don't forget to revert the git config husky modified.

yarn remove husky
rm -rf .husky
git config core.hooksPath .git/hooks/
Enter fullscreen mode Exit fullscreen mode

Discussion (2)

Editor guide
toplenboren profile image
Mikhail Gorbunov

Thank you! I'm glad you find the package useful <3

acro5piano profile image
Kay Gosho Author

Thanks for the comment! I love it!