Skip to content
⚡ Get Pretty Quick
JavaScript
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
__mocks__ test: add git tests Jan 8, 2018
bin chore: use shared prettier config (#88) Oct 13, 2019
img docs: add images to project Jan 8, 2018
src fix: handling of submodules and .git path (#90) (#92) Nov 5, 2019
.babelrc fix: upgrade dependencies (#85) Oct 13, 2019
.eslintrc.yml chore: use shared prettier config (#88) Oct 13, 2019
.gitignore feat: do the thing Jan 7, 2018
.travis.yml
LICENSE docs: make license live forever (#87) Oct 13, 2019
README.md docs: formatting (#75) Oct 13, 2019
package.json chore: update package.json (#89) Oct 13, 2019
yarn.lock fix: handling of submodules and .git path (#90) (#92) Nov 5, 2019

README.md

pretty-quick

Travis Prettier npm semantic-release License

Get Pretty Quick

Runs Prettier on your changed files.

demo

Supported source control managers:

  • Git
  • Mercurial

Install

With yarn:

yarn add --dev prettier pretty-quick

With npm:

npm install --save-dev prettier pretty-quick

Usage

With yarn:

yarn pretty-quick

With npx:

npx pretty-quick

With npm:

  1. Add "pretty-quick": "pretty-quick" to the "scripts" section of package.json.
  2. npm run pretty-quick

Pre-Commit Hook

You can run pretty-quick as a pre-commit hook using husky.

For Mercurial have a look at husky-hg

yarn add --dev husky

In package.json, add:

"husky": {
  "hooks": {
    "pre-commit": "pretty-quick --staged"
  }
}

demo

CLI Flags

--staged (only git)

Pre-commit mode. Under this flag only staged files will be formatted, and they will be re-staged after formatting.

Partially staged files will not be re-staged after formatting and pretty-quick will exit with a non-zero exit code. The intent is to abort the git commit and allow the user to amend their selective staging to include formatting fixes.

--no-restage (only git)

Use with the --staged flag to skip re-staging files after formatting.

--branch

When not in staged pre-commit mode, use this flag to compare changes with the specified branch. Defaults to master (git) / default (hg) branch.

--pattern

Filters the files for the given minimatch pattern.
For example pretty-quick --pattern "**/*.*(js|jsx)" or pretty-quick --pattern "**/*.js" --pattern "**/*.jsx"

--verbose

Outputs the name of each file right before it is proccessed. This can be useful if Prettier throws an error and you can't identify which file is causing the problem.

--bail

Prevent git commit if any files are fixed.

--check

Check that files are correctly formatted, but don't format them. This is useful on CI to verify that all changed files in the current branch were correctly formatted.

Configuration and Ignore Files

pretty-quick will respect your .prettierrc, .prettierignore, and .editorconfig files, so there's no additional setup required. Configuration files will be found by searching up the file system. .prettierignore files are only found from the repository root and the working directory that the command was executed from.

You can’t perform that action at this time.