This PR adds support for prettier and also runs it on pre-commit, so we make sure that all commits to the repository are formatted as expected.
Here's what I added:
Prettier: formats the code. I followed the instructions here. The magic is npx prettier . --write which formats the code and saves the changes
lint-staged: runs some script (in our case prettier) only on staged files so it's faster. We format only files that changed.
Husky: allows us to hook to git commands. For example, .husky/pre-commit allows us to run a command when you try to run git commit and cancels it if the command fail.
prettier formats the code, lint-staged runs prettier only on files that were added with git add , and husky run these on every commit.
This PR adds support for prettier and also runs it on pre-commit, so we make sure that all commits to the repository are formatted as expected.
Here's what I added:
prettier
formats the code,lint-staged
runsprettier
only on files that were added withgit add
, andhusky
run these on every commit.