Socket
Socket
Sign inDemoInstall

pretty-quick

Package Overview
Dependencies
41
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    pretty-quick

Get Pretty Quick


Version published
Maintainers
1
Install size
422 kB
Created

Package description

What is pretty-quick?

The pretty-quick npm package is a tool that runs Prettier, an opinionated code formatter, on your changed files. It integrates with version control systems like Git to format only the files that have been modified. This can be particularly useful as a pre-commit hook to ensure code style consistency without having to format the entire codebase on every commit.

What are pretty-quick's main functionalities?

Running on Changed Files

Run Prettier on all files that have changed since the last commit. This is the basic usage and can be integrated into pre-commit hooks.

npx pretty-quick

Running with Specific Options

Run Prettier on all changed files but filter them by a specific pattern. In this case, only JavaScript files will be formatted.

npx pretty-quick --pattern "**/*.js"

Staging Changes

Run Prettier on all staged files and re-stage the changes automatically. This is useful for ensuring that only formatted code gets committed.

npx pretty-quick --staged

Other packages similar to pretty-quick

Readme

Source

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.

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.

Keywords

FAQs

Last updated on 17 Jan 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc