intermediate
lint-staged
Run fast checks only on staged files to reduce local feedback time without weakening full-project CI gates.
lint-staged runs commands only against Git staged files—ideal for fast Prettier/ESLint fixes before commit without scanning the entire monorepo.
{
"lint-staged": {
"*.{ts,tsx}": ["eslint --fix", "prettier --write"]
}
}
Some checks need project-wide context: TypeScript project references, import boundaries, or rules that analyze the whole graph. Those belong in CI or explicit `pnpm lint` scripts, not staged-only paths.
On interviews: staged scope limits, partial staging with formatting write-backs, performance tuning, and why lint-staged is convenience not proof.
Common pitfalls: relying on staged ESLint for type errors; inconsistent fixes when only part of a file is staged; hiding monorepo-wide regressions.
The trade-off is local speed versus incomplete correctness guarantees.
Checklist:
- Use for fast auto-fixable checks.
- Keep project-wide typecheck in CI.
- Handle partially staged hunks carefully.
- Document what hooks do not cover.