rushstack
rushstack copied to clipboard
Add @rushstack/prettier-git
Summary
Implements a wrapper around prettier that formats either staged files, or files changed since a specified Git revision. Can also be run in CI mode with --check to error if any files modified since a specified Git revision do not match the formatting produced by prettier, in which case the diff will be rendered for each impacted file.
Details
This PR is parked here as a reference, I don't currently have plans to finish the cleanup work and get it checked in any time soon.
How it was tested
Impacted documentation
CC @elliot-nelson
It looks like this was already in motion -- just curious, what's the main difference between this tool and pretty-quick that motivated creating the new wrapper? (I guess question for @dmichon-msft )
I wrote the code here a couple years ago now. The main motivations:
- Support for partially staged files. If you have a file with both staged and unstaged changes, rather than erroring out like
pretty-quickdoes, it will format the staged version and write the result directly to the index, so that you can keep your unstaged changes unstaged. - More customizability with respect to which files to operate on, namely the ability to format all files modified since some arbitrary Git revision