talira

pretty-quick

Runs Prettier on only the files you changed, with a pre-commit mode

open sourceMITfree

pretty-quick runs Prettier on the files you've changed in Git or Mercurial, instead of the whole project. With --staged it works as a pre-commit hook (for example through simple-git-hooks), formatting only staged files and re-staging them, and failing on partially staged files so you can fix your staging. Other flags compare changes against a branch, filter files by glob pattern, or skip re-staging. It lives in the Prettier organization on GitHub.

Problems it solves

  • run Prettier only on the files I changed before committing
  • format staged files with Prettier in a pre-commit hook
  • Prettier on the whole repository is too slow, I only want changed files

Features

  • runs Prettier on changed files only
  • --staged pre-commit mode that formats and re-stages staged files
  • compare changes with a branch
  • filter files with glob patterns
  • Git and Mercurial

Limitations

  • Partially staged files aren't re-staged in --staged mode; it exits non-zero so the commit stops.1

Alternatives

The same job

These do what pretty-quick does.

  1. lint-staged Run tasks like formatters and linters against files staged in Git
  2. Prettier An opinionated code formatter that reprints your code in one consistent style
  3. shfmt Shell script formatter, with a Go shell parser and interpreter library (mvdan/sh)
  4. Biome One fast toolchain that formats and lints JavaScript, TypeScript, JSON, CSS, HTML, GraphQL, YAML and Markdown.
  5. eslint-plugin-prettier Run Prettier as an ESLint rule

Compare pretty-quick with the top 3