Skip to content

Lefthook prettier hook not running on staged .md files #2194

@justin808

Description

@justin808

Problem

The pre-commit hook for Prettier is not running on staged .md files despite the glob pattern in .lefthook.yml including them.

Evidence

When committing CONTRIBUTING.md, the pre-commit hook output shows:

│  prettier (skip) no matching staged files

The .lefthook.yml configuration includes .md in the glob pattern:

    prettier:
      glob: "**/*.{js,jsx,ts,tsx,json,md,yml,yaml}"
      run: bin/lefthook/prettier-format all-changed
      stage_fixed: true

This caused CI to fail with:

[warn] CONTRIBUTING.md
[warn] Code style issues found in the above file. Run Prettier with --write to fix.

Expected Behavior

When staging .md files, the Prettier pre-commit hook should run and format them.

Root Cause Hypothesis

The issue might be that:

  1. Lefthook's glob matching doesn't correctly match CONTRIBUTING.md against **/*.{js,jsx,ts,tsx,json,md,yml,yaml}
  2. The bin/lefthook/prettier-format all-changed script's regex pattern might not be correctly matching files in the root directory
  3. There could be a mismatch between lefthook's glob evaluation and the actual staged files

Workaround

Run pnpm start format manually before committing, or ensure Prettier runs on all files.

Related

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions