🚀 Feature: Add a git pre-push script #1243
Labels
status: in discussion
Not yet ready for implementation or a pull request
type: feature
New enhancement or request
Bug Report Checklist
main
branch of the repository.Overview
I propose that create-typescript-app set up a pre-push hook via Husky for you that runs some of the lint scripts before you push to GitHub. This will save you time and context switching when there are lint errors. It will slow down
git push
, but that's much more palatable (at least to me) than slowing downgit commit
.Additional Info
create-typescript-app sets up a pre-commit hook that runs prettier for you. pre-commits aren't my favorite (in my mind
git commit
should be instant) but prettier is pretty fast so this doesn't bother me too much.I'm finding it a bit annoying when I push to a PR branch only to find out through CI that I have a spelling mistake. Maybe spelling could run as a pre-commit when you have it enabled, but this could be a slippery slope to slow commits.
I find pre-push hooks to be a more palatable alternative. When I'm pushing to GitHub, my expectation is that I'm about to context switch anyway, so I don't mind waiting a few seconds if it's going to save me a round-trip to the GitHub Actions UI to find out about some failing linter.
Here's what I've set up in my repo:
And the script:
This runs all the
lint*
scripts in parallel (cool!) except forlint:packages
, which is kinda slow. In my repo, running this pre-push takes ~3 seconds. (eslint is the slowest step.)So, what about adding a pre-push hook by default?
The text was updated successfully, but these errors were encountered: