Skip to content

feat(rules): add content/placeholder-text, template leftovers in visible copy - #214

Merged
nc9 merged 1 commit into
mainfrom
feat/1350-content-placeholder-text
Sep 6, 2026
Merged

nc9 merged 1 commit into
mainfrom
feat/1350-content-placeholder-text

Conversation

@nc9

@nc9 nc9 commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a new per-page audit rule content/placeholder-text: template leftovers and filler copy that reached production. Six families, all judged against visible prose:

Kind Example Status
lorem-ipsum Lorem ipsum dolor sit amet fail
unrendered-template {{ user.name }}, {% for x in y %}, <%= title %>, ${total}, [[slug]] fail
stringified-object [object Object] fail
boilerplate-copy Your Company Name, Insert text here warn
js-artifact Rating: NaN, a table cell reading undefined warn
todo-marker TODO: write this, FIXME(alice) warn

Severity follows certainty. The three failing families are machine-generated and nothing legitimate produces them. The bare words undefined, null and NaN only warn, because an API reference whose defaults column reads null is ordinary and text alone cannot tell it from a value that failed to render.

Every family is also a legitimate thing for a page to quote, so most of the work here is precision:

  • Prose only. A new getRenderedProseText drops script/style/noscript, code/pre/samp/kbd, <template> (linkedom keeps its children in childNodes, so every Vue and Handlebars page reads as full of unrendered syntax without this), and the container classes of in-page code editors. CodeMirror and Monaco render no <pre> or <code> anywhere, which is why shopify.dev's Liquid reference fired before that exclusion.
  • Block boundaries. Text is read with a line break at every block edge, so a value alone in a table cell is seen as alone on its line. .textContent joins <td>Author</td><td>undefined</td> into one word that no word-boundary pattern can see.
  • A value must sit in a value slot: alone on its line, or after a label such as : or >. A comma is not a label, so Accepts a string, null, or undefined is prose. Neither is a pipe, so a TypeScript union is prose.
  • Lorem needs three distinct markers or dolor sit amet. The bigram alone is never enough, or every Lorem ipsum explained heading would fire.
  • Boilerplate matches whole-word phrases, and deliberately omits placeholder text and example text, which are the ordinary way to name this subject.
  • XXX needs a comment sigil, because Super Bowl XXX: the box score fits annotation form exactly. A bare TODO is left alone too: it is the name of a column on every task board ever shipped.

collectTextExcluding in packages/parser gains an optional isBoundary predicate. It is guarded by both separator && and ?., and every existing caller passes three arguments or fewer, so no existing behaviour changes.

Refs squirrelscan/repo#1350

Verification

Rule and helper tests, 62 cases:

bun test packages/rules/tests/placeholder-text.test.ts
 62 pass  0 fail  115 expect() calls

Neighbours and the shared walk:

bun test packages/rules/tests/mojibake.test.ts \
  packages/rules/tests/content-no-dom-mutation.test.ts \
  packages/parser/tests/dom-text.test.ts \
  packages/rules/tests/content-quality-text.test.ts
 106 pass  0 fail   (with placeholder-text)

Full audit-engine golden set green, including the canonical 518-page merge gate. Its two pinned counts move as expected for a page-scoped rule that always speaks: findings 98221 -> 98721 (+500, one passing check per fixture page) and perRuleTally 279 -> 280. healthScore.overall is unmoved at 48, so all 500 checks pass.

tsgo --noEmit clean in packages/rules, packages/parser, packages/audit-engine and apps/cli. make validate clean in docs/.

Smoked through the real CLI against a local fixture page, which reports all six families with the right severities and leaves the <code>, <pre> and <template> content alone.

Smoked against real sites, which is what drove most of the precision work above:

PASS  vuejs.org, handlebarsjs.com, shopify.dev/docs/api/liquid,
      jinja.palletsprojects.com, docs.astro.build, tailwindcss.com,
      en.wikipedia.org/wiki/Null_hypothesis, squirrelscan.com,
      gov.uk, news.ycombinator.com
WARN  en.wikipedia.org/wiki/NaN, MDN's `undefined` reference
      (both list the bare word as a heading or nav entry)
FAIL  en.wikipedia.org/wiki/Lorem_ipsum (it reproduces the filler)

The two warnings are the documented known limit: a page whose subject IS one of these values looks exactly like a page whose values failed to render.

Checklist

  • I added or updated tests for behavioral changes.
  • I did not include secrets, customer data, or incompatible third-party material.
  • Every commit includes a DCO Signed-off-by line (git commit -s).

…ble copy

Six families of "never meant to be read": lorem ipsum, theme boilerplate,
unrendered template syntax ({{ }}, {% %}, <% %>, ${ }, [[ ]]), [object X],
stringified JavaScript values, and TODO/FIXME/XXX markers.

Every family is also a legitimate thing for a page to QUOTE, so precision does
the work:

- prose only, via a new getRenderedProseText that drops script/style/noscript,
  code/pre/samp/kbd, <template>, and the container classes of in-page code
  editors (CodeMirror and Monaco render no <pre> or <code> at all)
- text is read with a line break at every block boundary, so a value alone in a
  table cell is seen as alone on its line
- undefined/null/NaN must sit where a VALUE sits: alone on its line, or after a
  label such as ":" or ">". A comma is not a label, so "Accepts a string, null,
  or undefined" is prose; neither is a pipe, so a TypeScript union is prose
- lorem needs three distinct markers or "dolor sit amet". The bigram alone is
  never enough, or every "Lorem ipsum explained" heading would fire
- boilerplate matches whole-word phrases only, and drops "placeholder text" and
  "example text", which are the ordinary way to name the subject
- TODO/FIXME in annotation form; XXX needs a comment sigil, because "Super Bowl
  XXX:" fits annotation form exactly

Severity follows certainty: lorem, template syntax and [object X] fail, because
nothing legitimate produces them. The bare words warn, because an API reference
whose defaults column reads null is ordinary and text alone cannot tell it from
a value that failed to render.

collectTextExcluding gains an optional isBoundary predicate (default off, no
existing caller affected). Golden findings 98221 -> 98721 (+500, one passing
page check per fixture page) and perRuleTally 279 -> 280.

Smoked against vuejs.org, handlebarsjs.com, shopify.dev's Liquid reference,
jinja, astro, tailwind, MDN and Wikipedia: all clean except pages whose subject
IS one of these values, which warn, and the Lorem ipsum article itself.

Refs squirrelscan/repo#1350

Signed-off-by: Nik Cubrilovic <[email protected]>
@nc9
nc9 force-pushed the feat/1350-content-placeholder-text branch from 9f83168 to f807949 Compare September 6, 2026 23:08
@nc9
nc9 merged commit 50fd6e6 into main Sep 6, 2026
13 checks passed
@nc9
nc9 deleted the feat/1350-content-placeholder-text branch September 6, 2026 23:15
nc9 pushed a commit that referenced this pull request Sep 6, 2026
Rebase onto content/placeholder-text (#214). Three things needed a decision
rather than a mechanical resolution.

Both branches bumped the published counts 279 -> 280 with byte-identical edits,
so git merged them as one change and no conflict was raised. The live loader now
returns 281 rules and 20 content rules while every literal still said 280 and 19.
Corrected across README, docs/index.mdx, docs/rules/index.mdx,
docs/rules/seo/index.mdx and docs/agent-setup/index.mdx; both per-category tables
and all four score-group card sets now sum to 281.

Both branches also added the SAME optional isBoundary parameter to
collectTextExcluding, independently. #214's version emits the separator on
entering a matching element only, on the reasoning that the next block's own
entry closes the previous one. That holds between two blocks, which is all
placeholder-text needs, but not when a block is followed by inline content:
`<h3>Price *</h3><a>terms* apply</a>` still reads back as `*terms*`, emphasis
present in neither element. Kept the symmetric version, which satisfies both
rules, and merged the two test suites into one describe block.

That makes the extracted text carry a closing separator as well, so three
exact-string expectations in placeholder-text.test.ts moved. Only the strings:
each test still asserts what its name says, and every rule-outcome assertion in
that suite is untouched and green.

The golden gate now pins 99221 findings and 281 tally keys, both rules
contributing 500 passing page checks to the 518-page fixture.

Verified: packages/rules content suites 177 pass, packages/parser 41 pass,
audit-engine golden 15 pass across six files, tsgo clean in parser, rules,
audit-engine and apps/cli, root lint clean, docs check clean.

Refs squirrelscan/repo#1352

Signed-off-by: Nik Cubrilovic <[email protected]>
nc9 pushed a commit that referenced this pull request Sep 6, 2026
Rebase onto content/placeholder-text (#214). Three things needed a decision
rather than a mechanical resolution.

Both branches bumped the published counts 279 -> 280 with byte-identical edits,
so git merged them as one change and no conflict was raised. The live loader now
returns 281 rules and 20 content rules while every literal still said 280 and 19.
Corrected across README, docs/index.mdx, docs/rules/index.mdx,
docs/rules/seo/index.mdx and docs/agent-setup/index.mdx; both per-category tables
and all four score-group card sets now sum to 281.

Both branches also added the SAME optional isBoundary parameter to
collectTextExcluding, independently. #214's version emits the separator on
entering a matching element only, on the reasoning that the next block's own
entry closes the previous one. That holds between two blocks, which is all
placeholder-text needs, but not when a block is followed by inline content:
`<h3>Price *</h3><a>terms* apply</a>` still reads back as `*terms*`, emphasis
present in neither element. Kept the symmetric version, which satisfies both
rules, and merged the two test suites into one describe block.

That makes the extracted text carry a closing separator as well, so three
exact-string expectations in placeholder-text.test.ts moved. Only the strings:
each test still asserts what its name says, and every rule-outcome assertion in
that suite is untouched and green.

The golden gate now pins 99221 findings and 281 tally keys, both rules
contributing 500 passing page checks to the 518-page fixture.

Verified: packages/rules content suites 177 pass, packages/parser 41 pass,
audit-engine golden 15 pass across six files, tsgo clean in parser, rules,
audit-engine and apps/cli, root lint clean, docs check clean.

Refs squirrelscan/repo#1352

Signed-off-by: Nik Cubrilovic <[email protected]>
nc9 added a commit that referenced this pull request Sep 6, 2026
…ed HTML in rendered copy (#217)

* feat(rules): add content/unrendered-markup for leaked markdown and escaped HTML

Detects literal markdown (emphasis, links, headings, fences) and visible
escaped HTML or double-encoded entities in the text a visitor actually reads.

Reads prose from the DOM with script-like AND code-like subtrees excluded, so
a docs page displaying markdown source stays clean. That exclusion is the rule,
not a refinement: <code>, <pre>, <samp>, <kbd>, <textarea>, plus whole-token
syntax-highlighter classes and the data-language family.

Precision work, measured against 88 real pages (1 residual, w3schools' HTML
tutorial, which displays source in a bespoke div):

- emphasis requires CommonMark flanking, so CLOUDFLARE_API_TOKEN, 2 * 3 and
  some_file_name.ts are not emphasis; the underscore form also requires a space
  inside, which silences __init__ and __main__
- a markdown link needs a URL-shaped target, so array[i](arg) is not a link
- escaped tags must be lowercase (<Article> is a component name) and at least
  one must carry a closing form or a valued attribute (<meta name> in a
  sentence is documentation)
- entities match a curated list, so Johnson&Johnson; is not an entity
- visible backticks corroborate but never accuse on their own

Regexes are kept linear with bounded, non-adjacent quantifiers and covered by
adversarial 64 KB timing tests.

Refs squirrelscan/repo#1352

Signed-off-by: Nik Cubrilovic <[email protected]>

* fix(rules): address review of content/unrendered-markup

Six findings from a fresh-eyes pass, in descending order of severity.

The heading and fence families were effectively dead on any real page.
collectTextExcluding emits its separator only for EXCLUDED subtrees, so sibling
blocks concatenate with nothing between them and a /m ^ anchor matched only at
offset 0 — which, on a page with a header, is never. Adds an optional isBoundary
predicate to collectTextExcluding (default undefined, so no existing caller
moves) and passes a block-tag predicate. Verified: <p>## Pricing</p> behind a
nav went from silent to reported, as did adjacent list items sharing emphasis.

`rest.includes("=")` called any prose equals sign an attribute, so
`if a<b then c=1>0 holds` was reported at fail. Replaced with a recognised
attribute-name allowlist, the same shape that already keeps Johnson&Johnson;
from reading as an entity. A path in angle brackets is no longer a closing tag.

The reported count, kind list and example included markdown-inline-code, which
the threshold excludes: a page with one bold phrase and five backtick spans
announced six occurrences at warn, and showed a backtick span as the example.
The headline now reports only the evidence that decided the status.

Also: the tag-name bound is derived from the tag sets rather than a literal
{0,9} that blockquote and figcaption already sat exactly on; the emphasis family
honours one match budget instead of one per pattern; a vouching tag past the cap
no longer drops the whole family; isCodeLikeElement makes one pass over
attributes rather than five (19.8ms -> 1.9ms per extraction on a 10k-element
DOM); bare "pre" is gone from the highlighter class tokens.

Tests: the eight "adversarial" fixtures carried a single trigger character each
and could not detect backtracking at all — a deliberately bad link pattern
measured 0.1ms on the old fixture and 5.2s on a dense one. Replaced with 18
dense-trigger fixtures at a 400ms budget, plus assertions that the scan cap
truncates rather than merely finishing fast. The golden pin now checks the
per-rule tally directly instead of inferring "all 500 are passes" from an
unmoved health score.

Re-smoked against 75 reachable real pages: 74 clean. The residual is w3schools'
HTML tutorial, which displays source in a bespoke div. One new false positive
the boundary work introduced (MDN renders a URL fragment on its own line) is
fixed by rejecting slug-shaped headings.

Two rule-count literals the first commit missed: README's per-category table and
the duplicate content card in docs/rules/seo. Both category tables now sum to
280.

Refs squirrelscan/repo#1352

Signed-off-by: Nik Cubrilovic <[email protected]>

* fix(rules): close the closing-edge of the block boundary, and four more

Second review pass. Every finding reproduced before it was fixed.

The boundary was emitted on ENTER only, which moved the gluing bug to the other
edge rather than fixing it: `<h3>Price *</h3><a>terms* apply</a>` still read back
as `*terms*`, emphasis present in neither element, and a split escaped tag
reached `fail` on the same basis. collectTextExcluding now pushes a stack marker
before a boundary element's children so the separator closes after them, and the
escaped-tag pattern no longer accepts a newline inside an attribute list, which
was the second way two blocks could assemble one tag.

Making every block start a line gave the number sign a line start too, so
`<th># of seats</th>` warned as a leaked heading. A single `#` now needs a
capitalised word after it; `##` and deeper have no second reading and are taken
as written, which also restores `## my-package` and `## getting-started` that
the previous slug guard was silencing.

The attribute allowlist had no legacy presentational names, so escaped table and
email HTML - no closing tags, `align`/`bgcolor`/`valign` only - had nothing to
vouch for it and passed clean. Added those, deliberately without single-letter
SVG names, which would resurrect the `a<b then d=1>0` false positive.

Also: sibling `<option>`s glued like `<li>`s, so option/optgroup/caption/legend/
menu join the block tags; the escaped-tag sample now leads with the tag that
actually vouched rather than whichever bare mention came first, moved by index
because moving it by value would delete its duplicates and undercount; and the
`closing` helper moved above its callers, since a const arrow is not hoisted and
packages/* is not linted.

Tests: two of five boundary fixtures passed with the boundary deleted because
they sat at the body's first byte. Replaced with fixtures that all follow chrome,
plus five gluing fixtures that must stay clean and one proving a tag whole within
a single block is still reported.

Re-smoked against 85 real pages, all reachable: 83 clean, worst rule time 10ms.
Both residuals are w3schools tutorials displaying HTML source in a bespoke div,
the known and documented case. MDN's element pages are now clean.

Refs squirrelscan/repo#1352

Signed-off-by: Nik Cubrilovic <[email protected]>

* docs(rules): drop the em-dash from the unrendered-markup solution copy

Rule solutions render in reports and on the docs site, so they are public copy,
where the house style is a colon rather than an em-dash. Also corrects two
comments that described the previous implementation: the attribute read is one
pass now, and the escaped-tag sample is the vouching tag rather than the first.

Refs squirrelscan/repo#1352

Signed-off-by: Nik Cubrilovic <[email protected]>

* fix(rules): reconcile the rule counts and the shared boundary with #214

Rebase onto content/placeholder-text (#214). Three things needed a decision
rather than a mechanical resolution.

Both branches bumped the published counts 279 -> 280 with byte-identical edits,
so git merged them as one change and no conflict was raised. The live loader now
returns 281 rules and 20 content rules while every literal still said 280 and 19.
Corrected across README, docs/index.mdx, docs/rules/index.mdx,
docs/rules/seo/index.mdx and docs/agent-setup/index.mdx; both per-category tables
and all four score-group card sets now sum to 281.

Both branches also added the SAME optional isBoundary parameter to
collectTextExcluding, independently. #214's version emits the separator on
entering a matching element only, on the reasoning that the next block's own
entry closes the previous one. That holds between two blocks, which is all
placeholder-text needs, but not when a block is followed by inline content:
`<h3>Price *</h3><a>terms* apply</a>` still reads back as `*terms*`, emphasis
present in neither element. Kept the symmetric version, which satisfies both
rules, and merged the two test suites into one describe block.

That makes the extracted text carry a closing separator as well, so three
exact-string expectations in placeholder-text.test.ts moved. Only the strings:
each test still asserts what its name says, and every rule-outcome assertion in
that suite is untouched and green.

The golden gate now pins 99221 findings and 281 tally keys, both rules
contributing 500 passing page checks to the 518-page fixture.

Verified: packages/rules content suites 177 pass, packages/parser 41 pass,
audit-engine golden 15 pass across six files, tsgo clean in parser, rules,
audit-engine and apps/cli, root lint clean, docs check clean.

Refs squirrelscan/repo#1352

Signed-off-by: Nik Cubrilovic <[email protected]>

---------

Signed-off-by: Nik Cubrilovic <[email protected]>
Co-authored-by: Nik Cubrilovic <[email protected]>
nc9 added a commit that referenced this pull request Oct 17, 2026
… prose #215 #216 (#885)

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
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