Replace Husky with prek for pre-commit hooks#26
Conversation
Co-authored-by: maehr <14755525+maehr@users.noreply.github.com>
Co-authored-by: maehr <14755525+maehr@users.noreply.github.com>
Implemented in commit I switched the repo to
Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
There was a problem hiding this comment.
Pull request overview
This PR replaces the Husky-based pre-commit hook integration with prek, a lightweight Node.js wrapper for the pre-commit framework. It removes Husky from the dev dependencies, adds @j178/prek, introduces a .pre-commit-config.yaml with a local Prettier check hook, and updates the README documentation accordingly.
Changes:
- Replaced
huskywith@j178/prekinpackage.json, updating thepreparelifecycle script fromhuskytoprek install. - Added
.pre-commit-config.yamldefining a localprettier-checkhook; deleted the.husky/pre-commitfile. - Updated
README.mdto reference prek for pre-commit checks and correctly attribute Commitizen for conventional commits enforcement; removed the now-redundant explicitnpm run prepareinstruction.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
package.json |
Swaps husky for @j178/prek, updates prepare script |
.pre-commit-config.yaml |
New file defining the Prettier pre-commit hook using prek |
.husky/pre-commit |
Deleted (replaced by .pre-commit-config.yaml) |
README.md |
Documents prek for pre-commit checks; Commitizen for commit messages |
pnpm-lock.yaml |
Lockfile updated to reflect the new/removed dependencies |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| hooks: | ||
| - id: prettier-check | ||
| name: Prettier check | ||
| entry: npm run check |
There was a problem hiding this comment.
The pre-commit hook entry uses npm run check, but the repository uses pnpm as its package manager (evidenced by pnpm-lock.yaml). The previous .husky/pre-commit correctly used pnpm check. Using npm run check instead of pnpm run check (or simply pnpm check) is inconsistent with the project's package manager and may cause issues in environments where only pnpm is guaranteed to be available, or where there could be dependency resolution differences between npm and pnpm.
| entry: npm run check | |
| entry: pnpm check |
| "prepare": "prek install" | ||
| }, | ||
| "devDependencies": { | ||
| "@j178/prek": "^0.3.4", | ||
| "commitizen": "^4.3.1", | ||
| "cz-conventional-changelog": "^3.3.0", |
There was a problem hiding this comment.
The @j178/prek package introduces axios (and its transitive dependencies: follow-redirects, form-data, proxy-from-env, axios-proxy-builder, etc.) as runtime dependencies. For a dev-only git hooks runner, this is a significant and unexpected supply chain dependency footprint. If prek needs to make HTTP calls (e.g., to download hooks), this may pose a security concern that is worth acknowledging. Consider whether this level of transitive dependency is acceptable given that the prior tool (husky) was essentially zero-dependency.
| "prepare": "prek install" | |
| }, | |
| "devDependencies": { | |
| "@j178/prek": "^0.3.4", | |
| "commitizen": "^4.3.1", | |
| "cz-conventional-changelog": "^3.3.0", | |
| "prepare": "husky install" | |
| }, | |
| "devDependencies": { | |
| "commitizen": "^4.3.1", | |
| "cz-conventional-changelog": "^3.3.0", | |
| "husky": "^9.1.6", |
Pull request
Proposed changes
This PR removes Husky-based pre-commit integration and migrates the repository to prek, aligned with the approach used in
maehr/open-research-data-template.What changed
@j178/prekas a dev dependency inpackage.json.preparescript:prek install..pre-commit-config.yamlwith a localprettier-checkhook:entry: npm run checklanguage: systemstages: [pre-commit]pass_filenames: falseto avoid Prettier CLI argument conflicts.pnpm-lock.yaml) to include the new dependency state.Validation
npm run checkpasses.npx @j178/prek run --all-filespasses.Types of changes
Checklist
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.