lint-staged
Run linters and formatters only against staged files — fast pre-commit checks for any size codebase.
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
Maintenance
Learning
Licence
// 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
// 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
Install lint-staged
Configure commands per file glob
Wire it into a Husky pre-commit hook
Run linters/formatters on staged files
Auto-fix and re-stage changes
Keep commands fast; CI runs full checks