Convert Figma logo to code with AI

prettier logopretty-quick

⚡ Get Pretty Quick

2,213
83
2,213
24

Top Related Projects

49,046

Prettier is an opinionated code formatter.

⚡ Get Pretty Quick

🚫💩 — Run linters on git staged files

32,324

Git hooks made easy 🐶 woof!

13,476

Check syntax in Vim/Neovim asynchronously and fix files, with Language Server Protocol (LSP) support

Quick Overview

Pretty-Quick is a tool that runs Prettier, a code formatter, on your changed files. It integrates with Git to identify modified files and applies Prettier formatting only to those files, making it ideal for pre-commit hooks or CI/CD pipelines. This focused approach saves time by avoiding unnecessary formatting of unchanged files.

Pros

  • Saves time by only formatting changed files
  • Integrates seamlessly with Git
  • Can be used in pre-commit hooks or CI/CD pipelines
  • Supports various Prettier configurations

Cons

  • Requires Prettier to be installed separately
  • May not catch formatting issues in unchanged files
  • Limited to Prettier's supported languages and file types
  • Can potentially conflict with other Git hooks or CI/CD steps

Code Examples

  1. Basic usage in a pre-commit hook:
// In your package.json
{
  "husky": {
    "hooks": {
      "pre-commit": "pretty-quick --staged"
    }
  }
}
  1. Running Pretty-Quick manually:
npx pretty-quick
  1. Using Pretty-Quick in a CI/CD pipeline:
# In your .gitlab-ci.yml or similar
lint:
  script:
    - npx pretty-quick --check

Getting Started

  1. Install Pretty-Quick and Prettier:

    npm install --save-dev pretty-quick prettier
    
  2. Add a script to your package.json:

    {
      "scripts": {
        "format": "pretty-quick"
      }
    }
    
  3. Run Pretty-Quick:

    npm run format
    

For pre-commit hook setup, consider using Husky or your preferred Git hook manager.

Competitor Comparisons

49,046

Prettier is an opinionated code formatter.

Pros of Prettier

  • More comprehensive and feature-rich, offering a wide range of formatting options
  • Highly configurable with extensive documentation and community support
  • Can be used as a standalone tool or integrated into various development environments

Cons of Prettier

  • Slower performance when formatting large codebases
  • Requires more setup and configuration compared to Pretty Quick
  • May have a steeper learning curve for new users due to its extensive options

Code Comparison

Prettier configuration:

{
  "semi": false,
  "singleQuote": true,
  "trailingComma": "es5",
  "printWidth": 100
}

Pretty Quick usage:

const prettyQuick = require('pretty-quick')

prettyQuick()

Key Differences

  • Pretty Quick is built on top of Prettier, focusing on speed and simplicity
  • Pretty Quick is designed specifically for Git-based projects, formatting only changed files
  • Prettier offers more granular control over formatting rules, while Pretty Quick aims for a simpler setup

Use Cases

  • Choose Prettier for projects requiring fine-tuned formatting control and extensive customization
  • Opt for Pretty Quick in Git-based projects where speed and simplicity are priorities, especially in CI/CD pipelines

Community and Ecosystem

  • Prettier has a larger community and more extensive ecosystem of plugins and integrations
  • Pretty Quick benefits from Prettier's ecosystem while providing a streamlined experience for specific use cases

⚡ Get Pretty Quick

Pros of pretty-quick

  • Faster execution due to optimized file selection
  • Integrates well with Git, focusing on changed files
  • Supports various version control systems

Cons of pretty-quick

  • May miss formatting issues in unchanged files
  • Requires additional setup compared to running Prettier directly
  • Limited customization options for file selection

Code Comparison

pretty-quick:

const prettyQuick = require('pretty-quick');

prettyQuick({
  staged: true,
  pattern: ['**/*.js', '**/*.jsx'],
});

Prettier:

const prettier = require('prettier');

const options = prettier.resolveConfig.sync(process.cwd());
prettier.format(source, options);

Summary

pretty-quick is a wrapper around Prettier that focuses on optimizing performance by selectively formatting files. It's particularly useful in Git workflows and CI/CD pipelines. However, it may not catch all formatting issues and requires additional setup. The choice between pretty-quick and Prettier depends on specific project needs and workflow preferences.

🚫💩 — Run linters on git staged files

Pros of lint-staged

  • More flexible, supporting various linters and formatters beyond just Prettier
  • Allows for custom commands and configurations for different file types
  • Integrates well with other tools in the development ecosystem

Cons of lint-staged

  • Requires more setup and configuration compared to pretty-quick
  • May have a steeper learning curve for beginners
  • Can be slower for large projects due to its broader scope

Code Comparison

lint-staged configuration:

{
  "lint-staged": {
    "*.js": ["eslint --fix", "prettier --write"],
    "*.css": "stylelint --fix"
  }
}

pretty-quick usage:

{
  "scripts": {
    "pretty-quick": "pretty-quick --staged"
  }
}

Summary

lint-staged offers more flexibility and customization options, making it suitable for complex projects with diverse linting and formatting needs. It supports multiple tools and allows for fine-grained control over the pre-commit process.

pretty-quick, on the other hand, is more focused and easier to set up, specifically designed for running Prettier on staged files. It's ideal for projects that primarily use Prettier for code formatting and don't require additional linting tools.

Choose lint-staged if you need a versatile tool that can handle various linters and formatters, and you're willing to invest time in configuration. Opt for pretty-quick if you want a simple, Prettier-focused solution with minimal setup.

32,324

Git hooks made easy 🐶 woof!

Pros of Husky

  • More versatile, allowing for various Git hooks beyond just pre-commit
  • Supports custom scripts and commands for each hook
  • Easier integration with other tools and workflows

Cons of Husky

  • Requires more setup and configuration compared to Pretty-Quick
  • Can be overkill for projects that only need simple pre-commit formatting

Code Comparison

Husky configuration (.huskyrc.json):

{
  "hooks": {
    "pre-commit": "npm run lint && npm test",
    "pre-push": "npm run build"
  }
}

Pretty-Quick usage:

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

Summary

Husky is a more powerful and flexible tool for managing Git hooks, allowing developers to run various scripts and commands at different stages of the Git workflow. It's ideal for projects that require complex pre-commit or pre-push tasks.

Pretty-Quick, on the other hand, is specifically designed to work with Prettier for quick and easy code formatting before commits. It's simpler to set up and use, making it a good choice for projects that primarily need code formatting on commit.

The choice between the two depends on the project's needs. If you require more than just code formatting, Husky is the better option. For simpler projects focused on maintaining consistent code style, Pretty-Quick may be sufficient.

13,476

Check syntax in Vim/Neovim asynchronously and fix files, with Language Server Protocol (LSP) support

Pros of ALE

  • Supports a wide range of programming languages and linters
  • Provides real-time linting and error checking as you type
  • Integrates with various text editors, not limited to Vim

Cons of ALE

  • Can be more resource-intensive due to real-time checking
  • May require more configuration for optimal performance
  • Learning curve can be steeper for new users

Code Comparison

ALE (in Vim configuration):

let g:ale_linters = {
\   'javascript': ['eslint'],
\   'python': ['flake8'],
\}
let g:ale_fixers = {
\   '*': ['remove_trailing_lines', 'trim_whitespace'],
\}

Pretty Quick:

{
  "scripts": {
    "format": "pretty-quick"
  }
}

Key Differences

  • ALE focuses on linting and error checking across multiple languages
  • Pretty Quick is primarily for code formatting using Prettier
  • ALE integrates directly with text editors, while Pretty Quick is typically run as a separate command
  • Pretty Quick is more lightweight and focused on a single task (formatting)
  • ALE provides more comprehensive code analysis but may require more setup

Use Cases

  • Choose ALE for comprehensive, real-time linting and error checking in various languages
  • Opt for Pretty Quick when you need fast, consistent code formatting using Prettier, especially in JavaScript projects

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

pretty-quick

GitHub Actions Codecov type-coverage npm GitHub Release

Conventional Commits Renovate enabled JavaScript Style Guide Code Style: Prettier changesets

Get Pretty Quick

Runs Prettier on your changed files.

demo

Supported source control managers:

  • Git
  • Mercurial

Install

# npm
npm install -D prettier pretty-quick
# yarn
yarn add -D prettier pretty-quick

Usage

# 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.

# npm
npm install -D simple-git-hooks

# yarn
yarn add -D simple-git-hooks

In package.json, add:

"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 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.

{
  "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. For example pretty-quick --ignore-path .gitignore

Configuration and Ignore Files

pretty-quick will respect your .prettierrc, .prettierignore, and .editorconfig 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.

NPM DownloadsLast 30 Days