You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
examples/git-hooks: the pre-commit hook lints and format-checks the whole repo on every commit; scope it to the staged packages #401
area: cliTouches CLI / executable / bin entry pointspriority: mediumShould be addressed in the normal course of developmentstatus: implementedBuilt and deployed, but not yet fully tested/verifiedtype: enhancementAn improvement to existing functionality without adding a new feature
examples/git-hooks/pre-commit runs npm run lint --if-present and npm run format:check --if-present unconditionally. In a single-package repo that is a few seconds. In a workspace whose lint script fans out to every package (scopra's is lint:backend && lint:frontend && lint:modules, about 60 packages), each commit pays the full sweep: about four minutes per commit on a loaded box, so a 13-commit path-scoped landing on 2026-10-26 spent close to an hour inside the hook. The hook is also check-only, so none of that time produces a fix.
Proposal
Keep the hook check-only and keep its fallback behaviour, but let it scope to what is being committed:
The hook computes the staged file list with git diff --cached --name-only --diff-filter=ACMR.
If the repo defines lint:staged and/or format:check:staged scripts, the hook calls those with the staged paths as arguments (npm run lint:staged --if-present -- <paths>), so the repo decides how to map files to packages (a workspace repo can map each path to its owning package and run that package's own scripts, which is the model where every package carries its own configs and scripts).
If those scripts are absent, today's behaviour stays: lint and format:check over the whole repo.
precommit:local stays last and unchanged.
docs/conventions/lint-format-precommit.md would document the two optional scripts. The post-merge CI autofix job is unaffected; it still runs the full sweep on next.
Why not lint-staged
A dependency on lint-staged changes the install footprint of every onboarded repo and moves the file-to-tool mapping into another config file. Two optional npm scripts keep the hook a thin shell and leave the mapping in the repo's own scripts, which is where the per-package tooling already lives.
Acceptance
A commit touching files in one workspace package runs only that package's lint and format check.
A repo without the staged scripts behaves exactly as today.
The hook is still check-only and never re-stages.
Reference consumer updated and the convention doc carries the new scripts.
#414 adds optional lint:staged / format:check:staged scripts. When a repo defines them, the hook passes the staged paths to them. Without them it falls back to the whole-repo lint / format:check. It stays check-only. The convention doc has an example. Reference consumers still need the scripts added; that happens per repo after this ships.
area: cliTouches CLI / executable / bin entry pointspriority: mediumShould be addressed in the normal course of developmentstatus: implementedBuilt and deployed, but not yet fully tested/verifiedtype: enhancementAn improvement to existing functionality without adding a new feature
Activity
Shinrai commentedon Nov 1, 2026
#414 adds optional
lint:staged/format:check:stagedscripts. When a repo defines them, the hook passes the staged paths to them. Without them it falls back to the whole-repolint/format:check. It stays check-only. The convention doc has an example. Reference consumers still need the scripts added; that happens per repo after this ships.cldmv-bot commentedon Nov 1, 2026
Marked
status: implemented— resolved by #414, merged intonext. This issue closes automatically when that work ships to the default branch.release: v4.35.0 - scope the pre-commit check to staged files through…