Skip to content

fix(rules): placeholder-text reads the title; mojibake reads rendered prose #215 #216 - #885

Merged
nc9 merged 1 commit into
mainfrom
fix/215-216-title-and-mojibake-prose
Oct 17, 2026
Merged

nc9 merged 1 commit into
mainfrom
fix/215-216-title-and-mojibake-prose

Conversation

@nc9

@nc9 nc9 commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Closes #215
Closes #216

Two content-rule follow-ups from #214, in one PR because they touch the same prose helpers and docs.

#215: the title

Ownership decision: content/placeholder-text owns this, because it already has the stringified-value logic and its docs-page guards. core/meta-title judges presence and length only. Both docs pages say so.

The rule adds a placeholder-title check, emitted only when there is a finding. A pass row on every page would dilute the body check's score on the pages that have one.

  • [object X] anywhere in the title: fail, the same as the body family.
  • undefined, null or NaN as a whole separator-delimited segment (|, -, –, —, ·, •, », ›, /, ::, at either end too): warn, the same as the body family.
  • The page is about the word when its <h1> or a <code> element is exactly that word, so MDN's undefined - JavaScript | MDN is not reported. Each value is judged on its own, so undefined | null | Acme on the MDN page still reports null.
  • A broken page whose <h1> is also undefined is reported by the existing body check, which is the same rule, so the title never adds a second rule.

#216: mojibake reads rendered prose

content/mojibake switches from getProseTextExcludingCode to getRenderedProseText, the helper placeholder-text uses. That excludes <template> and code-editor/highlighter containers and puts a break at every block boundary. Ordinary prose reports exactly as before.

The canonical golden counts did not move: the synthetic site has no template, editor markup or mojibake, and every title is real copy. A comment in streaming-rules-canonical-golden.test.ts records that.

Acceptance criteria

#215

  • A <title> with a standalone undefined/null/NaN/[object Object] is reported by exactly one rule
  • MDN's undefined - JavaScript | MDN is not reported
  • The owning rule's docs (placeholder-text) and meta-title's docs say which rule covers the title

#216

  • No report for a sequence only inside <template> or a code-editor container (cm-editor, monaco-editor, hljs, language-*)
  • Mojibake in ordinary prose is reported exactly as before
  • Canonical golden pinned counts: comment records they did not move
  • mojibake.mdx lists the same exclusions as the code

Skill: no change needed.

Tests: placeholder-text.test.ts, mojibake.test.ts, content-no-dom-mutation.test.ts 112/112 pass. Canonical golden passes. Also typecheck (rules), oxlint on changed files (the two remaining warnings are on an existing line), and tangly check --strict. Codex review took 2 rounds; it found P2 edge separators and P3 per-value exemption, both fixed.

… prose #215 #216

content/placeholder-text adds a placeholder-title check: [object X] anywhere
fails, undefined/null/NaN as a whole segment warns, unless the page's h1 or a
<code> names that word. content/mojibake switches to getRenderedProseText.
Canonical golden counts unchanged.

Signed-off-by: Nik Cubrilovic <[email protected]>
@nc9
nc9 force-pushed the fix/215-216-title-and-mojibake-prose branch from 474641d to bcad6fa Compare October 17, 2026 00:46
@nc9
nc9 marked this pull request as ready for review October 17, 2026 00:46
@claude

claude Bot commented Oct 17, 2026

Copy link
Copy Markdown

Review of PR 885: title check in content/placeholder-text, and content/mojibake moved to the rendered-prose reader. I read the diff and checked that CERTAIN_KINDS and OBJECT_TAG_RE behave as the new code assumes. I did not run the tests.

No high or critical findings.

  • (low) placeholder-text.ts (findTitlePlaceholder): the "page about the word" exemption accepts any <h1> whose text equals the value, and any <code> element equal to it. A page with a missing title and <code>null</code> in its body will therefore be suppressed. This is a deliberate trade-off and is documented. A short comment in the code would help the next reader.
  • (low) placeholder-text.ts (findTitlePlaceholder): the first h1 is added to subjects whatever its text, but only an exact match against values suppresses a report. This is correct, but subjects mixes arbitrary h1 text with values. Collecting the h1 only when values.has(h1) would read more clearly.
  • (nit) placeholder-text.ts: the title check runs before the no-body and no-findings branches, and each branch repeats checks.push(...titleCheck). Pushing it once, or building the checks and then appending, would avoid the repetition.
  • (nit) Tests: there is no case for a title containing a tab or newline between segments, or for [object Object] combined with a body finding. The title-only paths are covered well. mojibake.test.ts has no case for the <template> exclusion nested inside a code-editor container.
  • (nit) mojibake.ts: the comment block above the call still describes the old getProseTextExcludingCode rationale first. Reordering it so the new behaviour comes first would be clearer.
  • (nit) mojibake.ts and the changelog: this changes content/mojibake output for existing users. Adding a block boundary at every block element can also hide a mojibake sequence that spans an inline-to-block boundary. The changelog covers the change. The golden test comment says nothing moved, so it is worth confirming the golden suite passes in CI.

The docs and changelog entries match the implemented behaviour.

@nc9
nc9 merged commit 8bcd9e1 into main Oct 17, 2026
16 checks passed
@nc9
nc9 deleted the fix/215-216-title-and-mojibake-prose branch October 17, 2026 01:11
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.

content/mojibake should read the same rendered prose as content/placeholder-text content/placeholder-text: inspect <title> for stringified values

1 participant