Skip to content

perf(hooks): scope pre-commit lint and typecheck to changed files - #1634

Merged
realcodesiman merged 1 commit into
mainfrom
chore/lefthook-precommit-perf
Nov 3, 2026
Merged

realcodesiman merged 1 commit into
mainfrom
chore/lefthook-precommit-perf

Conversation

@realcodesiman

@realcodesiman realcodesiman commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • The pre-commit hook ran ultracite fix over the whole repo and turbo check-types over all 64 workspaces at turbo's default concurrency of 10 (builder alone may take an 8 GB heap), pinning CPU/RAM on every commit that touched a .ts file.
  • Scope both jobs to what the commit changed, matching how n8n, next.js, cal.com, novu and tldraw do it (lint staged files only; run turbo only for affected packages). CI still type-checks the full repo, so nothing can merge untyped.
  • Fix a pre-existing cache gap: root tsconfig.base.json (extended by packages/database and packages/business) was invisible to turbo, so editing it hit cache and was never re-type-checked.

Changes

  • lefthook.yml
    • ultracite fix {staged_files} instead of the whole repo
    • turbo check-types --filter="...[HEAD]" --concurrency=2: changed workspaces plus every dependent, two tsc at a time (same limit as the root check-types script)
    • skip: [merge, rebase] on both jobs: a merge from main stages everything main changed, which CI already checked
  • turbo.json: "globalDependencies": ["tsconfig.base.json"]

Verification

  • Clean tree: filter selects 0 workspaces (was 64)
  • Edit in packages/realtime-protocol: filter selects 46 workspaces incl. business, database, all integrations, builder, worker, realtime; dependents are not missed
  • Edit in root tsconfig.base.json: 0 workspaces before, 64 after this change
  • ultracite fix <files> with unmatched files exits 0; lefthook validate passes
  • This PR's own commit: hook finished in 0.78s, typecheck skipped (no .ts staged)

Test plan

  • Commit a change in a shared package and confirm dependents are type-checked
  • Merge main into a branch and confirm the hook skips
  • CI check-types green (cache keys change once due to globalDependencies)

The pre-commit hook ran `ultracite fix` over the whole repo and
`turbo check-types` over all 64 workspaces at turbo's default concurrency
of 10 (builder alone may take an 8 GB heap), pinning CPU and RAM on every
commit that touched a .ts file.

- ultracite fix now receives {staged_files} only
- typecheck runs `--filter="...[HEAD]"` (changed workspaces plus their
  dependents) with `--concurrency=2`, matching the root check-types script
- both jobs skip merge and rebase; CI type-checks the full repo
- declare root tsconfig.base.json as a turbo globalDependency: it is
  extended by packages/database and packages/business but invisible to
  turbo, so edits to it hit cache and were never re-type-checked
@github-actions github-actions Bot added the improvement Refactor or performance improvement label Nov 3, 2026
@realcodesiman
realcodesiman merged commit 7eb6597 into main Nov 3, 2026
16 checks passed
@realcodesiman
realcodesiman deleted the chore/lefthook-precommit-perf branch November 3, 2026 05:22
hello-jackytruong referenced this pull request in hello-jackytruong/ChatWorkAI Nov 22, 2026
…634)

The pre-commit hook ran `ultracite fix` over the whole repo and
`turbo check-types` over all 64 workspaces at turbo's default concurrency
of 10 (builder alone may take an 8 GB heap), pinning CPU and RAM on every
commit that touched a .ts file.

- ultracite fix now receives {staged_files} only
- typecheck runs `--filter="...[HEAD]"` (changed workspaces plus their
  dependents) with `--concurrency=2`, matching the root check-types script
- both jobs skip merge and rebase; CI type-checks the full repo
- declare root tsconfig.base.json as a turbo globalDependency: it is
  extended by packages/database and packages/business but invisible to
  turbo, so edits to it hit cache and were never re-type-checked
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement Refactor or performance improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant