talira

lint-staged

Run tasks like formatters and linters against files staged in Git

open sourceMITfree

lint-staged runs formatters, linters and any other shell tasks on only the files staged in Git, matched by glob patterns, so checks before a commit stay fast and broken code doesn't reach the repository. It backs up the original state with a git stash before running tasks, stages any changes the tasks make, and is usually run from a pre-commit hook set up with Husky.

Problems it solves

  • run ESLint and Prettier only on the files I'm committing
  • stop badly formatted code from being committed
  • make pre-commit checks fast in a big repository

Features

  • runs tasks on staged files only, filtered by glob
  • any shell command: linters, formatters, tests
  • backs up the original state before running
  • stages changes made by tasks
  • JS configuration files

Alternatives

The same job

These do what lint-staged does.

  1. pretty-quick Runs Prettier on only the files you changed, with a pre-commit mode
  2. Lefthook Fast and powerful Git hooks manager for any type of projects.
  3. commitlint Lint commit messages against your team's commit convention
  4. pre-commit A framework for managing and maintaining multi-language pre-commit hooks.
  5. pre-commit (npm) Installs a git pre-commit hook that runs your npm scripts before each commit
  6. detect-secrets An enterprise friendly way of detecting and preventing secrets in code.

Compare lint-staged with the top 3