A couple of companies ago, I had a report that wanted to prettify our whole codebase. His idea? Prettier in pre-commit hooks! That way, you write, commit and it’s pretty. Pretty awesome right…
Nope.
This works in a narrow use case. You write a change and commit everything you just wrote. This is, in my experience is not at all how I use git. I’ll make a bunch of changes and commit…some of them. There’s 2 reasons I do this:
I’ll never commit some changes like adding logs, custom builds, removing flaky tests
I break up my changes into lots of small commits. Often times my creation process is super messy. I don’t really know what I’m doing until it’s done. But once it’s done, then it’s clear how to break the change up into bite size commits to make a clean history that’s easier to bisect and analyze for future developers.
Prettier sadly works on not the diff bu…