Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/azz/pretty-quick
⚡ Get Pretty Quick
https://github.com/azz/pretty-quick
cli git mercurial prettier
Last synced: 2 months ago
JSON representation
⚡ Get Pretty Quick
- Host: GitHub
- URL: https://github.com/azz/pretty-quick
- Owner: prettier
- License: mit
- Created: 2018-01-07T16:23:17.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2024-04-11T14:08:42.000Z (11 months ago)
- Last Synced: 2024-10-29T14:53:58.379Z (4 months ago)
- Topics: cli, git, mercurial, prettier
- Language: TypeScript
- Homepage: https://npm.im/pretty-quick
- Size: 2.54 MB
- Stars: 2,218
- Watchers: 16
- Forks: 83
- Open Issues: 24
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
- awesome-github-star - pretty-quick
- Awesome - `pretty-quick` (Runs `prettier` on your changed files ⚡)
README
# `pretty-quick`
[](https://github.com/prettier/pretty-quick/actions/workflows/ci.yml)
[](https://codecov.io/gh/prettier/pretty-quick)
[](https://github.com/plantain-00/type-coverage)
[](https://www.npmjs.com/package/pretty-quick)
[](https://github.com/prettier/pretty-quick/releases)[](https://conventionalcommits.org)
[](https://renovatebot.com)
[](https://standardjs.com)
[](https://github.com/prettier/prettier)
[](https://github.com/changesets/changesets)> Get Pretty Quick
Runs [Prettier](https://prettier.io) on your changed files.

Supported source control managers:
- Git
- Mercurial## Install
```sh
# npm
npm install -D prettier pretty-quick
``````sh
# yarn
yarn add -D prettier pretty-quick
```## Usage
```sh
# npx
npx pretty-quick# yarn
yarn pretty-quick
```## Pre-Commit Hook
You can run `pretty-quick` as a `pre-commit` hook using [`simple-git-hooks`](https://github.com/toplenboren/simple-git-hooks).
```sh
# npm
npm install -D simple-git-hooks# yarn
yarn add -D simple-git-hooks
```In `package.json`, add:
```jsonc
"simple-git-hooks": {
"pre-commit": "yarn pretty-quick --staged" // or "npx pretty-quick --staged"
}
```## 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](https://github.com/isaacs/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 processed. 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.
### `--no-resolve-config`
Do not resolve prettier config when determining which files to format, just use standard set of supported file types & extensions prettier supports. This may be useful if you do not need any customization and see performance issues.
By default, pretty-quick will check your prettier configuration file for any overrides you define to support formatting of additional file extensions.
Example `.prettierrc` file to support formatting files with `.cmp` or `.page` extensions as html.
```json
{
"printWidth": 120,
"bracketSpacing": false,
"overrides": [
{
"files": "*.{cmp,page}",
"options": { "parser": "html" }
}
]
}
```### `--ignore-path`
Check an alternative file for ignoring files with the same format as [`.prettierignore`](https://prettier.io/docs/en/ignore#ignoring-files).
For example `pretty-quick --ignore-path .gitignore`## Configuration and Ignore Files
`pretty-quick` will respect your [`.prettierrc`](https://prettier.io/docs/en/configuration), [`.prettierignore`](https://prettier.io/docs/en/ignore#ignoring-files), and [`.editorconfig`](http://editorconfig.org/) files if you don't use `--ignore-path` . 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.