Skip to content

feat(lint+autofix): default glob covers YAML+JSON, not just markdown#44

Merged
topcoder1 merged 1 commit into
mainfrom
feat/prettier-extended-glob
May 11, 2026
Merged

feat(lint+autofix): default glob covers YAML+JSON, not just markdown#44
topcoder1 merged 1 commit into
mainfrom
feat/prettier-extended-glob

Conversation

@topcoder1
Copy link
Copy Markdown
Owner

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

  • Input name stays `markdown_glob` — callers that override don't break.
  • `changed_only: true` (default) means baseline YAML/JSON drift in repos isn't rewritten until a PR happens to touch those files.
  • Repos that want to opt out specific files can add them to `.prettierignore`.

Test plan

  • actionlint clean
  • brace-expansion helper unit-tested
  • After merge: every fleet repo with autofix wired (40 + finsight) gets the broader scope on the next PR

🤖 Generated with Claude Code

…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##*\}}"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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:

Suggested change
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##*\}}"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

@claude
Copy link
Copy Markdown

claude Bot commented May 10, 2026

Flagged 1 issue inline (duplicated in both workflow files): expand_braces uses ##*\} for suffix, which silently breaks any user-supplied glob with two brace groups (e.g. {src,lib}/**/*.{ts,tsx}) — emitting bare directory names instead of valid globs. Default single-group glob is unaffected.

@topcoder1 topcoder1 merged commit f69b972 into main May 11, 2026
4 checks passed
@topcoder1 topcoder1 deleted the feat/prettier-extended-glob branch May 11, 2026 01:01
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.

1 participant