Repository navigation
Conversation
Frank3K
force-pushed
the
chore/lefthook-pre-commit
branch
from
November 14, 2026 00:12
60189a3 to
8798e1b
Compare
Frank3K
force-pushed
the
chore/lefthook-pre-commit
branch
from
November 21, 2026 20:06
7b891af to
066ddac
Compare
The hook config in package.json used the husky v4 format, which husky 7+ ignores, so the hook has not run since mid-2021. scripts/pre-commit.sh also never popped the stash it created for unstaged changes. - Replace husky with lefthook. Its postinstall script installs the hooks on `npm install`. lefthook.yml formats staged TypeScript sources with clang-format and then runs `eslint --fix`, re-staging the results. Unstaged changes in partially staged files are left untouched. - Replace the clang-format npm package (clang-format 15, x86_64-only on macOS) with clang-format-node, pinned to 4.0.5 (clang-format 23.1.5), which ships native binaries for Apple Silicon. - Add `npm run format:check` and run it in the unit-tests workflow. - Remove scripts/pre-commit.sh and the husky v4 config block.
Whitespace-only changes from running `npm run format` with the clang-format version now pinned via clang-format-node.
Frank3K
force-pushed
the
chore/lefthook-pre-commit
branch
from
November 21, 2026 20:11
066ddac to
219c167
Compare
Frank3K
marked this pull request as ready for review
November 21, 2026 20:16
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Summary
The repo's pre-commit hook hasn't run since mid-2021.
package.jsonstill has a husky v4"husky": {"hooks": …}block. husky 7 and later ignore that block, and there was no.husky/directory orpreparescript. The script it pointed to (scripts/pre-commit.sh) also had a bug: it rangit stash -kfor unstaged changes but never popped the stash.This PR restores the hook with lefthook instead of husky, which hasn't had a release since 9.1.7. It also fixes clang-format on Apple Silicon.
Changes
Pre-commit hook (
lefthook.yml)clang-format -ionpackages/*/src/**/*.ts, excluding*.d.ts. This is the same scope asnpm run format.eslint --fixon staged files.eslint.config.mjsdecides which files are actually linted.postinstallscript onnpm install, so nopreparescript is needed. On CI (CI=true) they are not installed.LEFTHOOK=0 git commit …to skip the hook once.clang-format
clang-formatnpm package withclang-format-node, pinned to4.0.5, which shipsclang-format 23.1.5. The old package is at 1.8.0, last released in 2023. It bundles clang-format 15 and has only an x86_64 macOS binary, so it fails with
spawn Unknown system error -86on Apple Silicon Macs without Rosetta.clang-format-nodeis built from the official LLVM sources and ships native binaries for eachplatform.
npm run format:check(clang-format --dry-run --Werror) and runs it in the unit-tests workflow after lint.Reformat
style:commit reformats 13 files with clang-format 23.1.5. It only changes whitespace and line breaks (git diff -wshows only re-wrapped lines). Most of it is a re-indent ofdecorators.ts.Removed
scripts/pre-commit.sh, the husky v4 config block, and thehuskydev dependency.Testing
Tested on macOS (Apple Silicon), Node 24:
npm installinstalls.git/hooks/pre-commit.edit stayed in the working tree, and no stash was left behind.
src/features/…) is formatted, and.d.tsfiles are skipped.npm run format:check,npm run lint(0 errors) andnpm run buildpass.Notes for contributors
npm installonce to install the hook.git config core.hooksPathis set, lefthook won't install its hooks. Rungit config --unset core.hooksPath, then runnpm installagain.