I've replaced husky with simple-git-hooks

Kay Gosho - Apr 11 '21 - - Dev Community

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
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player