Speed Up Pre-commit Checks by 10x
Setting up lint-staged for fast pre-commit code checks is a typical request from teams using React 18 with TypeScript, where every commit triggers ESLint on all 500+ files and takes 30 seconds of waiting. Developers start using git commit --no-verify to avoid the wait. Code quality drops, bugs slip into production. The solution is lint-staged. It runs linters and formatters only on files that are in the staging area. At TrueTech, we configure such pipelines in 30–60 minutes, and checking three changed files takes less than a second. This speeds up pre-commit checks by 10–30 times, and the team starts trusting hooks again. This saves up to 20 hours per month on waiting for linters — essentially returning one workday to the team. At an average developer rate of $50/hour, that's savings of $1,000 to $5,000 per month for a 5-person team.
lint-staged documentation recommends: "Run linters against staged git files and don't let 💩 slip into your code base!"
Why lint-staged works faster
| Approach | Time per commit (500 files) | Checked files | Bypass probability |
|---|---|---|---|
| Normal script (all files) | ~30 seconds | All | High (--no-verify) |
| lint-staged (only staged) | <1 second | Only changed | Low |
| Manual formatting | N/A | N/A | Very high |
How we configure lint-staged
We use lint-staged 15.x, Husky 9.x, ESLint 9.x, Prettier 3.x. The configuration is stored in lint-staged.config.mjs — it's more convenient than package.json and allows dynamic functions. Typical case: a React 18 + TypeScript project. The only non-obvious part is typecheck.
Setting up typecheck inside lint-staged
Installation:
npm install --save-dev lint-staged Usually together with Husky. .husky/pre-commit:
npx lint-staged Configuration:
export default { '**/*.{ts,tsx,js,jsx}': [ 'eslint --fix --max-warnings 0', 'prettier --write', ], '**/*.{css,scss}': [ 'stylelint --fix', 'prettier --write', ], '**/*.{json,md,yml,yaml}': [ 'prettier --write', ], '**/*.{ts,tsx}': [ 'eslint --fix', 'prettier --write', () => 'node scripts/typecheck-staged.mjs', ], }; Example wrapper function for typecheck
// scripts/typecheck-staged.mjs import { execSync } from 'node:child_process'; try { execSync('tsc --noEmit --incremental', { stdio: 'inherit' }); } catch { process.exit(1); } Debugging
# See what will be run without actually running npx lint-staged --debug --dry-run What's included in the setup
We document the work sequence in a brief and keep it in the client's Git repository:
- Audit current pipeline: measure pre-commit time, identify bottlenecks, and count
--no-verifyfrequency. - Select tooling for the stack: ESLint, Prettier, Stylelint, tsc, custom secrets checks.
- Develop lint-staged and Husky configuration: specific globs, command order, error handling.
- Integrate typecheck wrapper and CI smoke test: the pipeline fails if the hook doesn't run.
- Knowledge transfer to the team: 30-minute workshop and 5–7 page changelog in Confluence.
| Stage | Description |
|---|---|
| Current process analysis | Study your project, stack, and pipeline |
| Installation and configuration | Set up lint-staged, Husky, ESLint, Prettier, Stylelint |
| Typecheck integration | Write wrapper function for tsc |
| Custom checks | File size, secrets, etc. |
| Documentation and training | Describe the process for the team |
| Post-implementation support | First weeks, adjustments on request |
Timeline and Budget
Project evaluation takes one working day. The actual setup takes 2 to 5 days depending on complexity. Cost is calculated individually based on the number of tools, need for custom checks, and CI/CD integration. Contact us for a detailed estimate.
Why Choose Us
We guarantee quality: over 10 years of experience and 100+ code quality pipeline deployments. We don't just configure tools; we integrate them into your CI/CD, considering infrastructure specifics. Our engineers know how lint-staged interacts with other hooks and pipelines. Order lint-staged setup from TrueTech — speed up pre-commit checks by 10x and return real development time to your team.
We pay special attention to monorepo configurations: Nx, Turborepo, and Yarn Workspaces require careful configuration assembly — otherwise linters duplicate work and typecheck fails in loops. In such projects, we split rules per package: library code is checked via tsc --build, applications via legacy tsc with --incremental. Additionally, we enable incremental ESLint and Prettier caches via the --cache option, reducing time by 40–60% on repeated commits. For teams with 20+ developers, we add skip-worktree for config files so local IDE settings don't leak into PRs.
After deployment, we conduct two retrospective measurements — after one week and after one month. The first shows how often developers moved away from --no-verify (usually from 45% down to 3–5%), the second shows real time saved: 12–20 hours per team per month. All metrics are recorded in a Grafana dashboard if already deployed, or in a 25–30 row Google Sheet. Contact us for a free project evaluation — typically first response within 4 business hours.







