Skip to content

fix(typos-format): --write-changes runs with no extension filter #2650

Description

@kyle-sexton

Problem

plugins/typos-format/hooks/typos-format.sh:280 invokes:

"$TYPOS_BIN" "${TYPOS_CONFIG_ARGS[@]}" --write-changes --force-exclude --format json "$TYPOS_ARG"

--write-changes mutates the file, and the invocation carries no extension filter — any file reaching this hook is rewritten in place.

Compounding it, the same file records at :223 that --write-changes emits nothing for a correction it applies (verified against the tool's behavior, per the comment). So a mutation here is silent by the tool's own design, and the only thing bounding blast radius is whatever the hook's matcher and --force-exclude happen to admit.

Why this is filed at low priority

typos correcting a genuine misspelling is usually right, and --force-exclude does honor exclusions. This is a defense-in-depth gap, not an active break: the concern is a file type where an apparent typo is load-bearing — a fixture, a golden file, a test asserting on exact strings, an encoded blob, a vendored artifact.

Suggested direction

Either constrain the hook to an explicit extension allowlist, or document why unrestricted write is correct here and what the exclusion config is expected to carry. Both are cheap; the current state leaves the reader unable to tell which was intended.

Verification

Line numbers verified against 065877c8. Surfaced during an unrelated fleet-wide sweep of tree-mutating surfaces.

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: lowNice-to-have, cosmetic, or speculative; opportunistic.work-class: scopedA briefed fix or small feature; blast radius bounded by the brief, tests exist.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions