-
Notifications
You must be signed in to change notification settings - Fork 0
feature/lefthook #417
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?
feature/lefthook #417
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 adds lefthook as a Git hooks manager to enforce code quality checks before commits. The implementation runs format, lint, typecheck, and test commands automatically during the pre-commit phase.
Changes:
- Added
lefthookas a dev dependency and configured it to install via thepreparenpm script - Created
lefthook.ymlconfiguration file with parallel pre-commit jobs for formatting, linting, type checking, and testing
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| package.json | Added lefthook dependency and prepare script to install Git hooks |
| lefthook.yml | Configured pre-commit hooks to run code quality checks in parallel |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "serve": "gatsby serve", | ||
| "format": "prettier \"src/**/*{.tsx, .ts}\" --write", | ||
| "formatCheck": "prettier \"src/**/*{.tsx, .ts}\" --check", | ||
| "lint": "eslint \"src/**/*{.tsx, .ts}\" --quiet --fix", |
Copilot
AI
Jan 21, 2026
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.
The glob pattern in the lint script has a space before the file extensions which may not match files correctly. It should be \"src/**/*.{tsx,ts}\" without spaces around the comma.
| jobs: | ||
| - name: format | ||
| glob: "**/*.{ts,tsx}" | ||
| run: yarn format {staged_files} |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
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.
it is defined
|
|
||
| - name: lint | ||
| glob: "**/*.{ts,tsx}" | ||
| run: yarn lint {staged_files} |
Copilot
AI
Jan 21, 2026
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.
The lint script in package.json uses its own glob pattern and doesn't accept file arguments. This will cause the staged_files parameter to be ignored. Consider updating the lint script to accept file arguments: eslint --quiet --fix
| run: yarn lint {staged_files} | |
| run: yarn lint |
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.
I ran a bunch of experiments (switching commands with npx, adding fail_text as a job field, tweaking parameters etc. Here's update:
- for today's work, I wasn't able to fully fix vscode GUI popup readability issue. I did get the popup to show real text instead of empty lines, but it still feels a bit misleading.
- good news: the vscode
Show Command Outputview can be cleaned up usingexecution_info, this removes the extra blocks and special characters. Now the outputs looks much better.
these are the changes in this file that seemed useful during testing (I didn't submit a sub-pr since the changes are small and not yet optimal):
output:
- summary
- failure
- execution_info
pre-commit:
...keep unchanged...
let me know what you think. I can work on this more and open a sub-pr if I find a better fix!
Problem
Closes #414 and #251
Solution
Installed
lefthookand added config file with pre-commit checks for format, lint, typecheck, and testing.We can adjust how strict we want pre-commit checks to be....
Some people find that
lefthookdoesn't play nice with the VSCode git GUI unless the window has been launched from the terminal, due to PATH variables being unavaiable (command npx not found, etc) I launched mine from terminal, and it worked fine.With
lefthookyou may prefer committing from the CLI since the print out from lefthook is visible that way (tests running, etc). Without that readout it sometimes seems to be slow or just hanging if you commit from the VS code GUI.We can go deeper on how to configure it: pre-commit vs pre-push or other options.
Advantages of
lefthookoverhuskyare that it can be used in polyglot projects although in this case we are just using it in node context.