Skip to content

chore: add precommit via lefthook#124

Open
aahiltn wants to merge 4 commits intomainfrom
aahil/add-precommit
Open

chore: add precommit via lefthook#124
aahiltn wants to merge 4 commits intomainfrom
aahil/add-precommit

Conversation

@aahiltn
Copy link
Contributor

@aahiltn aahiltn commented Feb 5, 2026

Description

Install lefthook via homebrew or chocolatey/scoop.

then try committing.

as of right now, if backend changes were made, runs backend-test on push. otherwise, lints and formats staged files on commit.

How has this been tested?

Checklist

  • I have self-reviewed my code for readability, maintainability, performance, and added comments/documentation where necessary.
  • New and existing tests pass locally with my changes.
  • I have followed the project's coding standards and best practices.
  • Adds Lefthook-based pre-commit and pre-push hooks that lint and format staged Go and TypeScript files on commit and run backend tests on push when backend changes exist.
  • Adds cross-platform justfile tasks to run staged lint/format commands (Windows and Unix handling).
  • Documents Lefthook installation and usage in CONTRIBUTING.md and updates project tooling docs.

Changes by Category

Features

  • lefthook.yml: pre-commit workflow (parallel lint/format + API docs generation) and pre-push workflow (backend test trigger).

Infra

  • justfile: new staged-file targets (lint-be-staged, format-be-staged, lint-fe-staged, format-fe-staged) with OS-specific path handling.
  • CONTRIBUTING.md: Lefthook installation instructions (Homebrew / Chocolatey / Scoop).
  • backend/go.mod: move golang.org/x/sync v0.19.0 to indirect require.

Improvements

  • Minor formatting change in docs/REALTIME.md (bolded Note).
  • Small whitespace cleanup in backend/internal/controllers/users.go.

Author Contribution (lines)

| File | Added | Removed |
| lefthook.yml | 30 | 0 |
| justfile | 34 | 0 |
| backend/go.mod | 1 | 1 |
| CONTRIBUTING.md | 1 | 1 |
| docs/REALTIME.md | 1 | 1 |
| backend/internal/controllers/users.go | 0 | 1 |
| Total | 67 | 4 |

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 5, 2026

📝 Walkthrough

Walkthrough

Adds Lefthook-based pre-commit and pre-push hooks, Justfile targets to run linters/formatters on staged files (backend/frontend), a Lefthook config, minor docs formatting, a Go module visibility change, and a trivial whitespace edit in a controller file.

Changes

Cohort / File(s) Summary
Pre-commit framework & config
lefthook.yml, justfile
Introduces Lefthook configuration and corresponding Justfile targets to run staged-file lint/format tasks for backend (Go) and frontend (TS/TSX), plus a pre-push test target. Includes OS-specific path handling in Justfile commands.
Documentation
CONTRIBUTING.md, docs/REALTIME.md
Adds Lefthook to pre-commit tooling documentation and formats an inline Note as bold in realtime docs.
Go module manifest
backend/go.mod
Moves golang.org/x/sync v0.19.0 from a direct require to an indirect require (no version change).
Small code cleanup
backend/internal/controllers/users.go
Removed an extraneous blank line after an Unauthorized() call.

Sequence Diagram(s)

sequenceDiagram
  participant Dev as Developer
  participant Git as Git
  participant LH as Lefthook
  participant Just as Justfile
  participant Tools as Linters/Formatters/Tests

  Dev->>Git: git commit / git push
  Git->>LH: invoke pre-commit / pre-push
  LH->>Just: run configured job(s) (lint-be-staged, format-be-staged, lint-fe-staged, format-fe-staged, test-be)
  Just->>Tools: execute linter/formatter/test commands (OS-aware, staged files)
  Tools-->>Just: result (pass/fail)
  Just-->>LH: job success/failure
  LH-->>Git: allow or block commit/push
  Git-->>Dev: success or error message
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

Lefthook waits at commit's gate,
Staged files dance to tidy fate,
Linters hum and format sings,
Tests roll in on pre-push wings,
Commits emerge a cleaner state.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding Lefthook as a pre-commit/pre-push tool. It is concise and clearly summarizes the primary objective of the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch aahil/add-precommit

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
CONTRIBUTING.md (1)

35-42: ⚠️ Potential issue | 🟡 Minor

Fix table linting and the Lefthook link.

Line 41 is missing a trailing pipe and the table is not surrounded by blank lines, which triggers markdownlint (MD055/MD058). Also, the Lefthook link lacks a scheme and is likely treated as a relative URL.

Proposed fix
 ### General
-
 | Tool | Description | Installation |
 |------|-------------|--------------|
 | Docker | Containerization | [docker.com](https://www.docker.com/products/docker-desktop/) |
 | Doppler | Secrets management | [doppler.com/docs/install-cli](https://docs.doppler.com/docs/install-cli) |
 | Figma | Design tool | [figma.com](https://www.figma.com/downloads/) |
 | Just | CLI tool build with Rust | [Just](https://github.com/casey/just) |
-| Lefthook | Pre-commit Tooling | [Lefthook](lefthook.dev)
+| Lefthook | Pre-commit Tooling | [Lefthook](https://lefthook.dev/) |
+
 > [!TIP]

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