As a developer, I highly recommend to use prettier in your editor. And today I’d like to go a step further, force and automate code formatting for all your team. No need to discuss the code style any more, don’t waste time on the arguments about space or tab, whether or not add a new line. And it’s much neat for code diff and review.
It’s very easy, only 2 steps.
- Install pretty-quick and husky. pretty-quick runs prettier on your changed files and husky gives the hook for precommit.
1 | yarn add pretty-quick husky --dev |
- add this script to your package.json:
1 | { |
Now every time when any team member commit, the changed files will be prettified.