Skip to content

Conversation

@interim17
Copy link
Contributor

@interim17 interim17 commented Jan 21, 2026

Problem

Closes #414 and #251

Solution

Installed lefthook and 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 lefthook doesn'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 lefthook you 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 lefthook over husky are that it can be used in polyglot projects although in this case we are just using it in node context.

  • New feature (non-breaking change which adds functionality)

@interim17 interim17 marked this pull request as ready for review January 21, 2026 22:28
@interim17 interim17 changed the title i rFeature/lefthook feature/lefthook Jan 21, 2026
@interim17 interim17 requested review from Copilot, meganrm and rugeli and removed request for meganrm January 21, 2026 22:28
Copy link
Contributor

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 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 lefthook as a dev dependency and configured it to install via the prepare npm script
  • Created lefthook.yml configuration 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",
Copy link

Copilot AI Jan 21, 2026

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.

Copilot uses AI. Check for mistakes.
jobs:
- name: format
glob: "**/*.{ts,tsx}"
run: yarn format {staged_files}

This comment was marked as off-topic.

Copy link
Contributor Author

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}
Copy link

Copilot AI Jan 21, 2026

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

Suggested change
run: yarn lint {staged_files}
run: yarn lint

Copilot uses AI. Check for mistakes.
@interim17 interim17 marked this pull request as draft January 21, 2026 23:46
Base automatically changed from feature/vitest to main January 22, 2026 18:30
Copy link
Collaborator

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 Output view can be cleaned up using execution_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!

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.

3 participants