Honestly, I’m putting this here mostly for my own reference on future projects 🙂
Â
I can’t imagine a project where this functionality would be undesirable. I’ve been a long-time user of formatOnSave in VSCode - but there always seems to be a barrier or misalignment with team members working on the same project. I’m sure we could commit a .vscode folder - but there is something unnerving about that.
Â
Enter Git Hooks…
It’s pretty satisfying, watching Git do the work for you. Basically, everything you need to know is here:
Â
But the implementation I’m most interested in boils down to this magic command:
npx mrm@2 lint-staged
Â
…and voila! You’ve got squeaky clean code coming straight into your
git push
🎉