limit-typecheck-hook-by-glob: Skip typecheck hook unless relevant files changed #4

Open
std-bot wants to merge 1 commit from task/limit-typecheck-hook-by-glob into main
First-time contributor

Assigned idea

The Lefthook config runs bun run typecheck in both pre-commit and pre-push. Add glob filters so typechecking only runs when TypeScript/JavaScript or TS config files change, avoiding unnecessary hook time on docs-only or non-code commits.

Approach: 1) Edit lefthook.yml and add a glob pattern to the pre-commit job named typecheck so it only triggers when relevant files are staged (e.g., **/*.{ts,tsx,js,jsx,mjs}, tsconfig*.json, and other typecheck-affecting config files as appropriate for the repo).
2) Optionally apply the same glob gating to the pre-push jobs named typecheck and typecheck-test if you want pushes that only change docs/config unrelated to typing to skip these checks.
3) Keep existing formatting/lint/package-lock hooks unchanged.

Verification: 1) Confirm lefthook.yml includes a glob: entry under the pre-commit job with name: typecheck.
2) Stage a non-matching change (e.g., edit a .md file only) and run lefthook run pre-commit; verify the typecheck job is not executed.
3) Stage a matching change (e.g., edit a .ts file) and run lefthook run pre-commit; verify bun run typecheck executes.

Risk: If the glob patterns are too narrow, typechecking may be skipped when it should run (e.g., changes to config files that impact typechecking but aren’t included). Mitigate by including tsconfig and other typecheck-relevant config files in the patterns.

Agent context

Task slug: limit-typecheck-hook-by-glob
Branch: task/limit-typecheck-hook-by-glob

## Assigned idea The Lefthook config runs `bun run typecheck` in both pre-commit and pre-push. Add `glob` filters so typechecking only runs when TypeScript/JavaScript or TS config files change, avoiding unnecessary hook time on docs-only or non-code commits. Approach: 1) Edit `lefthook.yml` and add a `glob` pattern to the `pre-commit` job named `typecheck` so it only triggers when relevant files are staged (e.g., `**/*.{ts,tsx,js,jsx,mjs}`, `tsconfig*.json`, and other typecheck-affecting config files as appropriate for the repo). 2) Optionally apply the same `glob` gating to the `pre-push` jobs named `typecheck` and `typecheck-test` if you want pushes that only change docs/config unrelated to typing to skip these checks. 3) Keep existing formatting/lint/package-lock hooks unchanged. Verification: 1) Confirm `lefthook.yml` includes a `glob:` entry under the `pre-commit` job with `name: typecheck`. 2) Stage a non-matching change (e.g., edit a `.md` file only) and run `lefthook run pre-commit`; verify the `typecheck` job is not executed. 3) Stage a matching change (e.g., edit a `.ts` file) and run `lefthook run pre-commit`; verify `bun run typecheck` executes. Risk: If the `glob` patterns are too narrow, typechecking may be skipped when it should run (e.g., changes to config files that impact typechecking but aren’t included). Mitigate by including tsconfig and other typecheck-relevant config files in the patterns. ## Agent context Task slug: limit-typecheck-hook-by-glob Branch: task/limit-typecheck-hook-by-glob <!-- std-ts:idea-pr-body -->
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin task/limit-typecheck-hook-by-glob:task/limit-typecheck-hook-by-glob
git switch task/limit-typecheck-hook-by-glob

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch main
git merge --no-ff task/limit-typecheck-hook-by-glob
git switch task/limit-typecheck-hook-by-glob
git rebase main
git switch main
git merge --ff-only task/limit-typecheck-hook-by-glob
git switch task/limit-typecheck-hook-by-glob
git rebase main
git switch main
git merge --no-ff task/limit-typecheck-hook-by-glob
git switch main
git merge --squash task/limit-typecheck-hook-by-glob
git switch main
git merge --ff-only task/limit-typecheck-hook-by-glob
git switch main
git merge task/limit-typecheck-hook-by-glob
git push origin main
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
snorkel/root-repository-maintenance-49850203909049!4
No description provided.