Skip to content

fix: scope pre-commit hook to staged files only#79

Draft
tellaho wants to merge 1 commit intomainfrom
tho/lefthook-staged-files
Draft

fix: scope pre-commit hook to staged files only#79
tellaho wants to merge 1 commit intomainfrom
tho/lefthook-staged-files

Conversation

@tellaho
Copy link
Copy Markdown
Collaborator

@tellaho tellaho commented Apr 2, 2026

Summary

  • Use lefthook's {staged_files} template so biome format/check and git add only touch explicitly staged files
  • Add glob filter to the format command so it only runs on file types biome handles
  • Prevents unrelated changes from being pulled into commits when working across multiple agents/branches in parallel

Test plan

  • Commit a non-JS file (e.g. lefthook.yml) — format step skips gracefully
  • Commit a .tsx file — format/check still runs and re-stages only that file

🤖 Generated with Claude Code

Use lefthook's {staged_files} template so biome format/check and
git add only touch explicitly staged files, preventing unrelated
changes from being pulled into commits during parallel workflows.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@tellaho tellaho requested a review from wesbillman as a code owner April 2, 2026 07:37
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6f660cb18e

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

commands:
format:
run: npx biome format --write . && npx biome check --fix . && git add -u
glob: "*.{js,jsx,ts,tsx,json,css}"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Expand Biome hook glob to include supported JS extensions

The new glob narrows formatting to *.{js,jsx,ts,tsx,json,css}, but this repo already contains scripts/check-file-sizes.mjs, and Biome’s own Lefthook recipe includes cjs, mjs, and jsonc in the staged-file pattern (https://biomejs.dev/recipes/git-hooks/). With the current pattern, staged .mjs/.cjs files are skipped by the auto-fix step while the unchanged check command (just checkbiome check .) still validates them, so commits can now fail on files that used to be auto-formatted. Please broaden the glob (or use --files-ignore-unknown=true without a restrictive glob) to avoid this regression.

Useful? React with 👍 / 👎.

@wesbillman
Copy link
Copy Markdown
Collaborator

What is the scenario this happens in @tellaho ? I'm not sure I've run into this but I always use worktrees when working on goose2

@tellaho tellaho marked this pull request as draft April 2, 2026 21:54
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