Add git pre-commit hooks to run tools? #1347
Labels
DX
Impacts developer experience
enhancement
New feature or request
low priority
does not impact production code
needs feedback
Requires a greater consensus to make an informed decision
Is your feature request related to a problem? Please describe.
Recently after pushing a commit to a PR, I only discovered after the workflows had run that there were CS issues found by php-cs-fixer -- because I hadn't thought to run that before pushing my commit. I'm remembering to do that now, but...
Describe the solution you'd like
It would be nice if php-cs-fixer would run automatically when I try to make a commit, and either (1) block it if anything needs fixing, or (2) fix it automatically. This can be accomplished by a git pre-commit hook, but that's not something that lives in the repository, so it would only happen on my machine, and anyone else that wanted it would have to set it up for themselves.
At the moment I'm only considering adding php-cs-fixer to the hook and not the integration tests since they take so long. However, the unit tests could potentially be added as well since they run fairly quickly.
Describe alternatives you've considered
Fortunately, there are libraries that allow git hooks to be shared in the repo.
Personally, the only experience I have is with the
husky
+lint-staged
NPM tools, and that is a valid option as it can work for more than just JS files.However, there are also PHP-based tools that can do this:
So my questions are:
The text was updated successfully, but these errors were encountered: