-
Notifications
You must be signed in to change notification settings - Fork 18
fix: husky pre commit hook #63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes the husky pre-commit hook configuration to properly handle code formatting and linting during commits. The changes ensure that when code is auto-fixed by the linting and formatting tools, the changes are staged and the commit is rejected with a clear message for the developer to commit again.
- Updated the biome lint command flag from
--fix
to--write
for consistency - Enhanced the pre-commit hook with proper husky setup and auto-staging logic
- Added a blank line formatting fix in the types file
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
package.json | Updated lint:fix script to use --write flag instead of --fix |
.husky/pre-commit | Added complete pre-commit hook implementation with auto-staging and proper error handling |
typescript/src/tools/types.ts | Added blank line formatting in Context type definition |
.husky/pre-commit
Outdated
# Check if anything changed | ||
if ! git diff --quiet; then | ||
# Stage changed files | ||
git diff --name-only | xargs git add |
Copilot
AI
Jul 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This command will fail if there are files with spaces in their names. Use 'git diff --name-only -z | xargs -0 git add' to handle filenames with spaces safely.
git diff --name-only | xargs git add | |
git diff --name-only -z | xargs -0 git add |
Copilot uses AI. Check for mistakes.
.husky/pre-commit
Outdated
# Check if anything changed | ||
if ! git diff --quiet; then | ||
# Stage changed files | ||
git diff --name-only | xargs git add |
Copilot
AI
Jul 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If no files are changed, 'git diff --name-only' will output nothing and xargs may fail. Consider using 'git add -u' instead, or add a check to ensure there are files to stage.
git diff --name-only | xargs git add | |
git diff --name-only | grep -q . && git diff --name-only | xargs git add |
Copilot uses AI. Check for mistakes.
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
pnpm run lint:fix | ||
pnpm run format |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are we running again?
@joshsny This PR's quite stale, do we want to keep it open? |
No description provided.