[go: up one dir, main page]

DEV Community

Kay Gosho
Kay Gosho

Posted on

I've replaced husky with simple-git-hooks

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.

https://github.com/typicode/husky

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.

https://typicode.github.io/husky/

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 husky.sh 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!

https://github.com/toplenboren/simple-git-hooks

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

Top comments (6)

Collapse
 
vanduc1102 profile image
Duc Nguyen • Edited

I moved away husky because of this issue github.com/typicode/husky/issues/991 ,

Having RUN yarn install --ignore-scripts is not a good idea for me.

Not sure why they dont fix the issue.

Collapse
 
acro5piano profile image
Kay Gosho

That's a good point. Husky is too complicated for people to predict its behavior.

Collapse
 
derekroberts profile image
Derek Roberts

Thanks for the quick and useful read! Your section reverting husky git hooks saved lots of time. :)

Collapse
 
acro5piano profile image
Kay Gosho

Thanks for your comment! I'm happy it was useful for you ;)

Collapse
 
toplenboren profile image
Mikhail Gorbunov

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

Collapse
 
acro5piano profile image
Kay Gosho

Thanks for the comment! I love it!