-
-
Notifications
You must be signed in to change notification settings - Fork 254
Add lefthook for precommit hook #1152
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: master
Are you sure you want to change the base?
Conversation
Deploying rescript-lang-org with
|
| Latest commit: |
9057cd7
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://c5f84193.rescript-lang.pages.dev |
| Branch Preview URL: | https://pre-commit-hook.rescript-lang.pages.dev |
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 pre-commit hook to automatically run code formatting before commits, helping maintain consistent code style across the project.
Key Changes:
- Added lefthook v2.0.4 as a dev dependency
- Created lefthook.yml configuration to run
yarn formaton pre-commit - The hook will automatically stage formatted files
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| package.json | Adds lefthook ^2.0.4 as a dev dependency |
| yarn.lock | Updates lock file with lefthook package and platform-specific binaries |
| lefthook.yml | Creates new lefthook configuration for pre-commit hook with format command |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "chokidar": "^4.0.3", | ||
| "dotenv": "^16.4.7", | ||
| "jsdom": "^26.1.0", | ||
| "lefthook": "^2.0.4", |
Copilot
AI
Nov 26, 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.
Missing postinstall script to install lefthook git hooks. After adding lefthook as a dependency, developers need to run lefthook install to actually install the git hooks. Without this, the pre-commit hook won't be activated.
Consider adding a postinstall script to package.json:
"scripts": {
"postinstall": "lefthook install"
}This ensures the git hooks are automatically installed when developers run yarn install.
| jobs: | ||
| - run: yarn format |
Copilot
AI
Nov 26, 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.
Incorrect syntax for lefthook configuration. The jobs array syntax is not valid for lefthook v2. Job commands should be defined as named keys, not as array items.
The correct syntax should be:
pre-commit:
parallel: true
commands:
format:
run: yarn format
stage_fixed: trueAlternatively, you can use the shorter syntax:
pre-commit:
commands:
format:
run: yarn format
stage_fixed: true| jobs: | |
| - run: yarn format | |
| commands: | |
| format: | |
| run: yarn format |
| @@ -0,0 +1,5 @@ | |||
| pre-commit: | |||
Copilot
AI
Nov 26, 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.
Consider adding a comment at the top of the lefthook configuration file to explain its purpose and how to set it up. For example:
# Lefthook configuration for git hooks
# Runs formatting before commits to ensure code quality
# Install hooks by running: yarn install (or npx lefthook install)This helps other developers understand the purpose of this file and how to use it.
Running
formatwill save a lot of headaches before pushing.