DEV Community

Discussion on: Who pushed failing tests again? Git Hooks with Husky 🐶

Collapse
 
theaccordance profile image
Joe Mainwaring

Excellent write up about Husky and how to leverage git hooks! My teams follow this implementation on projects with the exception of the stricter steps like linting & test validation.

Instead, we leverage a slightly different strategy:

  • No code is directly committed to our master/main branch on a project
  • Developers work in feature branches and have their code accepted through pull requests
  • Pull requests must pass CI/CD steps around linting and test validation before they can be merged.

We found this more flexible for our use case and ensures that all pushed commits still have prettier's formatting applied. Devs can push WIP code as a "save state" to their feature branches without always having to have their solutions fully complete.

Collapse
 
balastrong profile image
Leonardo Montini

Hey Joe, thanks for the comment!

Yes, going with CI pipelines is indeed a valid option, I also mentioned it in the conclusion, but if you cannot set them up (cost, private repos, internal policies) then git hooks might help :)