lint-staged logo

lint-staged

Open Source

Run linters and formatters only against staged files — fast pre-commit checks for any size codebase.

Visit websiteGitHub

Pricing

Free / Open source

Type

Automation

Languages

JavaScript

// VERDICT

Reach for lint-staged when you want pre-commit checks that are fast because they only touch staged files. Skip it when you don't use Git hooks, want full-repo checks each time, or have no linters to run.

Best for

Running linters/formatters only on staged files at commit time - keeping pre-commit hooks fast by checking just what changed, typically paired with Husky.

Avoid when

You don't use Git hooks, you want to check the whole repo every time, or you don't run linters/formatters.

CI/CD fit

Runs in the pre-commit hook (with Husky) · scoped to staged files

Languages

JavaScript

Team fit

Git-based teams · Teams wanting fast commit-time checks · QA shifting checks left

Setup

Easy

Maintenance

Low

Learning

Beginner

Licence

Free / Open source

// BEST FOR

  • Running linters/formatters only on staged files
  • Keeping pre-commit hooks fast
  • Pairing with Husky for the hook itself
  • Auto-fixing and re-staging changed files
  • Consistent commit-time quality on changed code
  • Avoiding slow whole-repo checks on every commit

// AVOID WHEN

  • You don't use Git hooks
  • You want to check the entire repo each time
  • You don't run linters/formatters
  • Client-side hooks are discouraged
  • CI-only gating is your model
  • Minimal tooling is the goal

// QUICK START

npm install -D lint-staged
// package.json: "lint-staged": { "*.{js,ts}": ["eslint --fix", "prettier --write"] }
// call from .husky/pre-commit: npx lint-staged

// ALTERNATIVES TO CONSIDER

ToolChoose it when
HuskyYou need the Git-hook manager that runs lint-staged.
ESLintYou want the linter lint-staged runs on changed files.
PrettierYou want the formatter lint-staged runs on changed files.

// FEATURES

  • Runs commands only on Git-staged files
  • Configurable per file pattern (e.g., *.ts)
  • Parallel execution of independent commands
  • Auto re-stages auto-fixed changes
  • Pairs naturally with Husky pre-commit hooks

// PROS

  • Pre-commit checks stay fast on large codebases
  • Auto-fix workflow integrates seamlessly
  • Battle-tested standard pattern

// CONS

  • Edge cases with partially-staged files can confuse
  • Debugging hook failures can be opaque
  • Doesn't catch issues in unchanged-but-affected files

// EXAMPLE QA WORKFLOW

  1. Install lint-staged

  2. Configure commands per file glob

  3. Wire it into a Husky pre-commit hook

  4. Run linters/formatters on staged files

  5. Auto-fix and re-stage changes

  6. Keep commands fast; CI runs full checks

// RELATED QA.CODES RESOURCES