Skip to content

Conversation

@jderochervlk
Copy link
Collaborator

Running format will save a lot of headaches before pushing.

@cloudflare-workers-and-pages
Copy link

Deploying rescript-lang-org with  Cloudflare Pages  Cloudflare Pages

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

View logs

Copilot finished reviewing on behalf of jderochervlk November 26, 2025 00:38
Copy link

Copilot AI left a 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 format on 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",
Copy link

Copilot AI Nov 26, 2025

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.

Copilot uses AI. Check for mistakes.
Comment on lines +3 to +4
jobs:
- run: yarn format
Copy link

Copilot AI Nov 26, 2025

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: true

Alternatively, you can use the shorter syntax:

pre-commit:
  commands:
    format:
      run: yarn format
      stage_fixed: true
Suggested change
jobs:
- run: yarn format
commands:
format:
run: yarn format

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,5 @@
pre-commit:
Copy link

Copilot AI Nov 26, 2025

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.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants