Skip to content

ci: add Lefthook pre-commit hooks for auto-formatting#25

Merged
OrbFrontend merged 1 commit into
OrbFrontend:mainfrom
glitchbunny0:feat/lefthook-hooks
May 7, 2026
Merged

ci: add Lefthook pre-commit hooks for auto-formatting#25
OrbFrontend merged 1 commit into
OrbFrontend:mainfrom
glitchbunny0:feat/lefthook-hooks

Conversation

@glitchbunny0
Copy link
Copy Markdown
Contributor

Why

CI catches formatting/lint issues, but contributors only find out after pushing. This adds local pre-commit hooks so formatting is auto-fixed before the commit even happens.

What

Adds Lefthook — a fast, language-agnostic git hooks manager. Config in one file (lefthook.yml), installs automatically via npm install.

Pre-commit hooks

Language Tool Action
Python (.py) Black Auto-format staged files
Python (.py) Flake8 Lint check (blocks commit on errors)
JavaScript (frontend/) Biome Auto-format staged files

Hooks run in parallel and only on staged files that match — fast.

Setup

npm install

That's it. The prepare script in package.json runs lefthook install automatically.

No Node.js?

This is fully optional. Contributors without Node.js skip npm install and run the existing scripts/format_backend.sh / scripts/format_frontend.sh manually. CI still catches everything.

Changes

File Change
package.json New — Lefthook + Biome as dev dependencies, prepare script
lefthook.yml New — hook config: Black + Flake8 + Biome on pre-commit
.gitignore Added node_modules/, package-lock.json
CONTRIBUTING.md Added "Auto-formatting on commit" section

Bonus

There's a commented-out conventional commit validator in lefthook.yml. Uncomment it to enforce type(scope): message format on commit messages.

Adds Lefthook to automatically format and lint staged files on commit:

- Python: Black (format) + Flake8 (lint) on .py files
- JavaScript: Biome (format) on frontend/ .js files
- Optional conventional commit validation (commented out)

Setup: run `npm install` — the prepare script installs hooks
automatically. Contributors without Node.js can skip this; CI still
catches formatting issues via the existing scripts.
@OrbFrontend
Copy link
Copy Markdown
Owner

Nice one. Thanks for this.

@OrbFrontend OrbFrontend merged commit 0385444 into OrbFrontend:main May 7, 2026
3 checks passed
OrbFrontend added a commit to hpnyaggerman/Orb that referenced this pull request May 16, 2026
ci: add Lefthook pre-commit hooks for auto-formatting
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