From 7d9f7cb93a9d116d119f069bd142f94cab33a1d6 Mon Sep 17 00:00:00 2001 From: Bryan Fawcett Date: Sat, 12 Sep 2026 03:17:23 +0800 Subject: [PATCH] fix(lint): exempt ERB-templated Rails fixtures from yamllint campfire's test/fixtures/*.yml are ERB TEMPLATES, not YAML documents. users.yml opens with <% password_digest = BCrypt::Password.create("secret123456") %> and only becomes valid YAML after Rails renders it, so yamllint reports a hard syntax error and always will - there is no version of that file that is both a working fixture and parseable YAML. Seven files in that repo are ERB-templated YAML; the rest only parse because their ERB happens to sit inside quoted scalars, which is luck rather than correctness. The ActionText fixtures alongside them are HTML blobs that tests assert on byte-for-byte, so rewrapping their 300-char lines would be a test change disguised as a formatting change. Same class as the lockfile exemption: content that is generated or templated rather than authored. This will recur in every Rails repo, and the narrower rule - skip any YAML containing `<%` - cannot be expressed in yamllint's path-based ignore. Also records the worst hazard found so far in ADOPTING-LINT.md: a file with a .md extension that is not Markdown gets SILENTLY CORRUPTED. mzizi-registry ships components/registry/n8-assurance/accessibility- audit.md, which is SQL, installed into consumers as documentation. Its `/* ... */` banner parses as Markdown emphasis, so `prettier --write` rewrites `/*` to `/_` - turning a shipped artifact into invalid SQL and then PASSING the gate. Unlike every other trap here, this one does not fail loudly; it changes your file and goes green. Co-Authored-By: Claude Opus 5 (1M context) --- .yamllint.yaml | 13 +++++++++++++ ADOPTING-LINT.md | 12 ++++++++++++ 2 files changed, 25 insertions(+) diff --git a/.yamllint.yaml b/.yamllint.yaml index dc117fc..61cc7b6 100644 --- a/.yamllint.yaml +++ b/.yamllint.yaml @@ -24,6 +24,19 @@ ignore: | **/package-lock.json **/yarn.lock + # Rails fixtures are ERB TEMPLATES, not YAML documents. campfire's + # test/fixtures/users.yml opens with + # <% password_digest = BCrypt::Password.create("secret123456") %> + # and only becomes valid YAML after Rails renders it, so yamllint + # reports a hard syntax error and always will. The ActionText fixtures + # alongside them are HTML blobs that tests assert on byte-for-byte, so + # rewrapping their long lines would be a test change, not a formatting + # change. Seven files in that repo are ERB-templated YAML; the others + # only parse because their ERB happens to sit inside quoted scalars, + # which is luck rather than correctness. + test/fixtures/ + **/test/fixtures/ + rules: # 140-char limit. Workflow files have legitimately long shell URLs # (the actionlint download script, action references) and issue- diff --git a/ADOPTING-LINT.md b/ADOPTING-LINT.md index 9626c94..4c8b92a 100644 --- a/ADOPTING-LINT.md +++ b/ADOPTING-LINT.md @@ -164,6 +164,18 @@ fine, so rewrite an affected comment as a run of single-line `{/* ... */}` comments: same text, valid MDX, prettier leaves it alone. Always diff an `.mdx` file after `--write`. +**A file with a `.md` extension that is not Markdown will be silently +corrupted.** `mzizi-registry` ships +`components/registry/n8-assurance/accessibility-audit.md`, which is +actually SQL - it is installed into consumers as documentation. Its +`/* ... */` banner parses as Markdown emphasis, so MD037 fires and +`prettier --write` rewrites `/*` to `/_` and `*/` to `_/`. The autofix +does not fail the gate: it rewrites a shipped artifact into invalid SQL +and then passes green. The fix is to wrap the body in a fenced code +block, which leaves the content byte-for-byte unchanged, satisfies both +tools, and makes the installed document render as code. Before running +`--fix` over a repo, look at what its `.md` files actually contain. + **A `.md` file containing MDX comments cannot satisfy both toolchains, and `--fix` will corrupt it.** Mintlify starters leave `{/* ... */}` in a file named `AGENTS.md`. Mintlify parses that file as MDX, where an HTML