feat(lint+autofix): default glob covers YAML+JSON, not just markdown#44
Conversation
…markdown
Broadens the default `markdown_glob` from `**/*.md` to
`**/*.{md,yml,yaml,json}`. Repos still get the same `prettier --check`
+ autofix loop, now covering CI workflow YAML, package.json, repo
config, and similar files where prettier's opinion is
uncontroversial. TS/JS source files are deliberately excluded — those
are more contentious and belong to their own opt-in flags.
Backward compatible:
- The input name stays `markdown_glob` (callers that override don't break).
- `changed_only: true` (default) means autofix only touches PR-modified
files, so baseline drift in repos doesn't get rewritten until a PR
happens to modify those files.
- Repos that want to opt out of specific files can add them to a
`.prettierignore` at repo root.
Bug fix bundled: `compgen -G` does pathname expansion (incl. globstar
`**`) but NOT brace expansion. With the new brace-pattern default, the
existing target-resolution code would have matched zero files. Added
an `expand_braces` helper that splits `**/*.{md,yml,yaml,json}` into
the four individual globs, runs compgen against each, and unions the
results (with a SEEN dedup map). Same fix mirrored in both
`lint.yml` and `prettier-autofix.yml`.
Verified locally:
expand_braces "**/*.{md,yml,yaml,json}"
→ **/*.md / **/*.yml / **/*.yaml / **/*.json
expand_braces "**/*.md" → **/*.md (no-op for non-brace input)
**Auto-merge rationale:** widens an existing default; no caller
contracts change. Same-day fleet rollout (40 callers) keeps using
`secrets: inherit` / explicit-pass — those are unrelated. Codex
pre-review skipped (~30 line additive change).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
| local pat="$1" | ||
| if [[ "$pat" == *\{*\}* ]]; then | ||
| local prefix="${pat%%\{*}" | ||
| local suffix="${pat##*\}}" |
There was a problem hiding this comment.
Bug: two-brace-group globs produce silently wrong output.
suffix is computed with ##*\} (strip to the last }), and prefix with %%\{* (strip from the first {). For the default single-group pattern (**/*.{md,yml,yaml,json}) this is fine. But a user override like {src,lib}/**/*.{ts,tsx} yields:
| variable | value |
|---|---|
prefix |
"" (whole string consumed — starts with {) |
suffix |
"" (whole string consumed — ends with }) |
middle |
"src,lib" |
| output | src, lib ← bare directory names, not valid globs |
compgen -G "src" matches a file/dir literally named src, not src/**/*.ts. Prettier silently processes zero matching files (or the wrong ones) with no error.
Fix: strip to the first } for suffix, then recurse (or loop) to expand any remaining brace groups in that suffix:
| local suffix="${pat##*\}}" | |
| local suffix="${pat#*\}}" |
With this change, {src,lib}/**/*.{ts,tsx} → suffix /**/*.{ts,tsx}, output src/**/*.{ts,tsx} / lib/**/*.{ts,tsx}. A second pass through expand_braces (or a recursive call) is then needed to expand the remaining group — or document that only a single brace group is supported and add an [[ "$suffix" == *\{*\}* ]] guard that exits non-zero with a clear error.
| local pat="$1" | ||
| if [[ "$pat" == *\{*\}* ]]; then | ||
| local prefix="${pat%%\{*}" | ||
| local suffix="${pat##*\}}" |
There was a problem hiding this comment.
Same two-brace-group bug as in lint.yml line 263 — suffix="${pat##*\}}" strips to the last }, so a user-provided glob like {src,lib}/**/*.{ts,tsx} silently emits bare src / lib with no path or extension. See the comment on the lint.yml copy for the full analysis and suggested fix.
|
Flagged 1 issue inline (duplicated in both workflow files): |
Summary
Broadens the default `markdown_glob` from `/*.md` to `/*.{md,yml,yaml,json}` in both `lint.yml` and `prettier-autofix.yml`. Repos get the same prettier-check + autofix loop on YAML config, package.json, etc. TS/JS source intentionally excluded — those are more contentious and belong to a separate opt-in.
Bug fix bundled
`compgen -G` does pathname expansion (incl. globstar ``) but NOT brace expansion. With the new brace-pattern default, the existing target-resolution would have matched zero files. Added an `expand_braces` helper that splits `/*.{md,yml,yaml,json}` into individual globs, runs compgen against each, and unions the results.
Verified locally:
```
expand_braces "/*.{md,yml,yaml,json}" → 4 lines
expand_braces "/.md" → 1 line (no-op)
expand_braces "src/**/.{ts,tsx}" → 2 lines
```
Backward compatibility
Test plan
🤖 Generated with Claude Code