Skip to content

Investigate: lefthook dprint hook incompatible with YAML files #215

Description

@EVWorth

Context

The dprint command in lefthook.yml includes *.{ts,tsx,js,jsx,json,yml,yaml,md,toml} in its file glob. But dprint.json only configures 4 plugins: typescript, json, markdown, toml. No YAML plugin is loaded.

Symptom

npx dprint check lefthook.yml exits 14 ("No files found to format with the specified plugins"). Any pre-commit that touches a YAML file will hit this.

In practice lefthook's wrapper hides the failure in some paths (the recent lefthook.yml edit in #211 passed the hook despite the dprint exit code), so the bug is masked, not absent.

Reproduction

git add lefthook.yml `.github/workflows/ci.yml`
git commit -m "test"
# dprint hook should fail; instead, lefthook reports `dprint ✔️` and commit proceeds.
# Manually:
npx dprint check lefthook.yml
# -> exit 14, no plugins for .yml

Why it matters

  • Mismatch between glob (intent: format YAML) and config (no plugin) means we expect a YAML formatter that doesn't exist.
  • Adding any new .yml file (e.g. another workflow) under current setup would expose this concretely.
  • Confusing author experience: hook passes when it shouldn't.

Options

A. Install a YAML plugin in dprint.json.

  • Add https://plugins.dprint.dev/markdown-0.18.0.wasm style entry for YAML, or use dprint's built-in yaml support if newer versions cover it. Verify dprint plugin support for YAML first.
  • Pros: matches the hook's stated intent; future-proof for any yml file.
  • Cons: another dependency surface; need to confirm plugin version compatibility.

B. Drop YAML from lefthook's dprint glob.

  • Remove yml,yaml from the glob. dprint won't try to format them.
  • Pros: minimal change; no new dep.
  • Cons: loses any intent of formatting YAML (yaml formatting isn't formalized in the repo anyway).

C. Audit scope: are there any .yml files we actually want formatted?

  • Check .github/workflows/, .github/ISSUE_TEMPLATE/ (none currently), lefthook.yml, dprint.json itself.
  • Drive decision from data.

Recommendation

Start with C (1 minute). If at least one .yml file currently drifts, do A. If no .yml files have any practical format expectation, do B.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions