Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate prettier with pre-commit hooks #207

Merged
merged 7 commits into from
May 17, 2024
Merged

Integrate prettier with pre-commit hooks #207

merged 7 commits into from
May 17, 2024

Conversation

giovannibenussi
Copy link
Contributor

@giovannibenussi giovannibenussi commented May 15, 2024

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.

@penberg penberg merged commit 84a483e into main May 17, 2024
3 checks passed
@penberg penberg deleted the add-prettier branch May 17, 2024 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants