Skip to content

Commits and Pre-commit Hooks

This document explains our commit workflow, including the use of Lefthook and Biome for pre-commit hooks to ensure code quality and consistency.


Lefthook

  • Lefthook is a fast and flexible Git hooks manager.
  • It is used to run scripts automatically at various points in the Git workflow (e.g., before committing or pushing code).
  • Our configuration ensures that certain checks and formatting steps are always run before code is committed.
  • The configuration for Lefthook can be found in the .lefthook.yml file at the root of the repository.

Biome

  • Biome is a code formatting and linting tool, similar to Prettier and ESLint, but faster and with a unified configuration.
  • Biome is run as part of the pre-commit hook to automatically format and lint your code before it is committed.
  • This helps maintain a consistent code style and catch common issues early.

How it Works

  • When you run git commit, Lefthook triggers the pre-commit hook.
  • The pre-commit hook runs Biome (and potentially other checks or scripts) on your staged files.
  • If Biome finds issues it can fix automatically, it will do so and update your staged files.
  • If there are errors that cannot be fixed automatically, the commit will be blocked until you resolve them.

What Developers Should Expect

  • You may notice that some files are automatically reformatted or fixed when you commit.
  • If your commit is blocked, check the output in your terminal for details on what needs to be fixed.
  • Always stage any changes made by Biome before retrying your commit.

Summary

  • Lefthook and Biome help enforce code quality and consistency automatically.
  • Most formatting and linting issues are fixed for you before code is committed.
  • Review the .lefthook.yml and Biome configuration files for more details or to customize the workflow.