chore: format committed files using Prettier#495
Open
skirtles-code wants to merge 1 commit intostackblitz-labs:mainfrom
Open
chore: format committed files using Prettier#495skirtles-code wants to merge 1 commit intostackblitz-labs:mainfrom
skirtles-code wants to merge 1 commit intostackblitz-labs:mainfrom
Conversation
aprendendofelipe
approved these changes
Apr 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds automatic formatting of code when committing to git.
simple-git-hooksis used to add a pre-commit git hook to runlint-staged.lint-stagedis used to run Prettier. It will only run on staged files, i.e. those included in the commit.The formatting is already checked as part of the CI. This just helps contributors to avoid the headache of changes failing the CI due to trivial formatting problems.
Why use
simple-git-hooks?It's the most common choice in the Vite & Vue ecosystems, so that's what I'm used to.
Why the
postinstall?That ensures
simple-git-hookswill run for everypnpm install, so that the git hook is kept in sync. You'll see something similar in projects likevuejs/coreandvitejs/vite.While the config doesn't tend to change often, contributors tend not to run
simple-git-hooksmanually, so if the config does change it can be problematic getting contributors to run it.The docs for
simple-git-hooksadvise against usingpostinstall, but that only applies if thepackage.jsonis published to npm, which it isn't in this case.Why is
simple-git-hooks: falseinallowBuilds?simple-git-hookshas its ownpostinstallscript that runs when the package is first installed. But it doesn't run for every subsequentpnpm install, which can lead to the config getting out of sync. As noted earlier, we have our ownpostinstallscript to handle that, so we don't need thepostinstallscript fromsimple-git-hooksitself.Why
--ignore-unknown?When running Prettier for the whole project, e.g. via
pnpm run format, it'll ignore any files with unknown extensions.But as we're only formatting staged files, Prettier will be a little stricter and will throw an error for any files with unknown extensions. The
--ignore-unknownoption tells it to ignore those files.This is the same as the example configuration at: