Pre commit hook suite - #152
Merged
elizabetheonoja-art merged 3 commits intoJul 18, 2026
Merged
Conversation
…for-code-quality Add pre-commit quality hook suite
elizabetheonoja-art
merged commit Jul 18, 2026
604b8fc
into
Utility-Protocol:main
0 of 2 checks passed
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.
Motivation
Provide a repository-managed pre-commit layer to catch common issues earlier and keep fast, staged-file-scoped checks local to developers.
Prevent trivial mistakes (merge markers, leaked secrets, lint regressions, lockfile drift) from reaching CI while avoiding expensive full-suite runs on every local commit.
Description
Add a Git entrypoint at .githooks/pre-commit that delegates to an npm-runable checker via npm run precommit:check.
Add a staged-file-aware runner scripts/pre-commit.mjs that discovers staged files, scans text files for merge markers and secret-like values, runs targeted eslint for staged source files, runs targeted vitest only for staged test files, and triggers lockfile sync when package.json or package-lock.json changes.
Wire up package.json with prepare and precommit:check npm scripts to install the hook path and run the checker locally via npm.
Add documentation docs/pre-commit-hooks.md describing architecture and rollout guidance and add unit tests tests/unit/preCommit.test.ts for planning and text-scan behaviors.
Testing
Ran npm run precommit:check and the staged-file-scoped checks completed successfully after adjustments to test targeting.
Ran targeted lint with npm run lint -- scripts/pre-commit.mjs tests/unit/preCommit.test.ts and fixed minor warnings so lint passes on the new files.
Ran the new unit tests with npm test -- tests/unit/preCommit.test.ts and they passed.
An initial attempt to run the full test suite (npm test -- --passWithNoTests) exposed unrelated pre-existing failures in tests/components/AssetHeatmapLayer.test.tsx and tests/unit/keyCache.test.ts, so the hook was scoped to staged test files to avoid blocking unrelated work; the scoped pre-commit checks pass.
Closes #126