Skip to content

fix(rules): content-in-js-bundle: all-rendered audit is skipped; real eager-MDX control and severity decision #1329 - #1354

Closed
nc9 wants to merge 4 commits into
mainfrom
fix/content-in-js-1329
Closed

nc9 wants to merge 4 commits into
mainfrom
fix/content-in-js-1329

Conversation

@nc9

@nc9 nc9 commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Closes #1329

AC1: an audit where EVERY page was browser-rendered used to collect no sentences, search nothing and pass with "No page content found". The collected page signal now records contentRendered, and the rule returns one skipped check saying every page was browser-rendered and that --http checks it. Both engines covered; some-rendered audits still search the plain pages. Tests in content-in-js-bundle-1200.test.ts.

AC2 (positive control, run on a real site): a real TanStack Start site with 132 MDX files, built in a scratch copy (the site repo untouched) with an eager glob that imports every module: entry chunk 1,474 KB, 124 of 132 files' first paragraphs found inside it, estimated prose share 47%. The same site with the bodies rendered on the server: 603 KB entry chunk, 0 pages' content, prose share 37%. Method and caveat in the docs: the paragraphs came from the MDX sources and were searched with the rule's own matcher (buildNeedleIndex / findNeedles / estimateProseShare), not read off rendered pages.

AC3 (decision): keep the single-page finding info. The prose share does not separate the cases (47% vs 37% for ordinary app code) and is below a 50% line, so it cannot drive a warning; the page count does (124 here vs 1 to 2 for hard-coded route components), and that is the existing sitewide warning. Stated in the docs.

AC4: the docs link #669 as the visibility dependency (whether info checks reach the JSON and LLM reports), worded so it stays true after #1344 ships.

Docs: docs/rules/perf/content-in-js-bundle.mdx; CHANGELOG under Unreleased. Skill: none.

nc9 added 2 commits October 30, 2026 21:23
@claude

claude Bot commented Oct 30, 2026

Copy link
Copy Markdown

Reviewed the diff. I found no blocking issues.

  • (low) packages/rules/src/performance/content-in-js-bundle.ts: the new allRendered line is a single line over 130 characters. Wrap it so it passes oxfmt. This is style only. The rule files are not format-checked in CI, but the file's neighbours are wrapped.
  • (low) content-in-js-bundle.ts: the allRendered early return sits before the judged check and any no-scripts handling. An all-rendered audit therefore reports skipped even when no scripts were fetched at all. That is arguably right, and the message is accurate. The ordering is intentional but undocumented, so a one-line comment would help.
  • (nit) contentRendered is a true | undefined field. Old cached records without it read as not rendered, so the rule falls back to the old behaviour. That is safe, and the doc comment already says so.
  • (nit) The partial-rendered test asserts some(non-pass). Asserting the specific check name (content-in-js-bundle or -sitewide) would pin the behaviour more tightly.

--http is a real flag (completion.ts lists it), so the message is accurate. Both the resident and streaming engines are covered. The rule's severity and its perRuleTally key are unchanged, so no golden pin should move. I did not run the tests.

The CHANGELOG bullet is under Unreleased and Fixed, and the docs are updated.

🤖 Generated with Claude Code

…MDX site and the single-page severity decision #1329

Signed-off-by: Nik Cubrilovic <[email protected]>
@nc9 nc9 changed the title fix(rules): content-in-js-bundle: an all-rendered audit is skipped, not a clean pass (part of #1329) fix(rules): content-in-js-bundle: all-rendered audit is skipped; real eager-MDX control and severity decision #1329 Oct 30, 2026
@claude

claude Bot commented Oct 30, 2026

Copy link
Copy Markdown

Review of #1354: the change is small and does what #1329 asks. I did not run the tests or the checks.

  • (low) packages/rules/src/performance/content-in-js-bundle.ts: the new allRendered = ...every(...) line in the collected-signals branch is well over the formatter's line width. Run oxfmt --check on the file from the repo root, per AGENTS.md.
  • (low) packages/rules/tests/content-in-js-bundle-1200.test.ts: the new "some rendered" test only asserts that some non-pass content-in-js-bundle* check exists. It would also pass if the plain pages were judged wrongly. Pinning the exact check name (content-in-js-bundle or -sitewide) would make it bite. AGENTS.md also asks that you revert the fix once and watch the all-rendered test fail.
  • (low) Collected-signal records cached before contentRendered existed have no flag, so an all-rendered audit that reads them still gets the old "No page content found" pass. This is probably fine, since it is only a cache edge case. A one-line note would help, because the contentSentences doc comment already describes the same absent-field case.
  • (nit) The docs say the sitewide warning "reaches every format". I did not check that against the report code. If it is not guaranteed, soften the wording.
  • (nit) The positive-control numbers in the docs (132 MDX files, 124 found, 47% vs 37%) come from a private site build and cannot be reproduced from the repo. The docs do state the method and the caveat, so this is only a note.

No correctness, security or untrusted-input concerns. The new code is a boolean scan over the pages, so there is no regex or DOM risk. Docs and CHANGELOG are updated.

@claude

claude Bot commented Oct 30, 2026

Copy link
Copy Markdown

Reviewed the diff. I found nothing that should block the merge, and I did not run the tests.

  • (low) packages/rules/src/performance/content-in-js-bundle.ts: the all-rendered skip runs before the early exits that don't need page sentences (no scripts fetched, rule options). An all-rendered audit with no same-origin scripts now reports "skipped / --http" where it used to report whatever that earlier path returned. Check that this is the message you want there.
  • (low) packages/rules/src/performance/content-in-js-bundle.ts: records cached before contentRendered existed read as not all rendered. An all-rendered audit replayed from an old cache falls back to the old "No page content found" pass. That's an acceptable one-time degradation, but a line in the code comment would help.
  • (nit) packages/rules/tests/content-in-js-bundle-1200.test.ts: there is no direct test that buildCollectedPageSignal sets contentRendered only when rendered === true, and leaves it absent otherwise. The engine test covers it indirectly.
  • (nit) The allRendered = ...every(...) line in the collected-signals branch is over 120 characters. packages/rules isn't formatted in CI, so this doesn't block anything.

The docs and CHANGELOG changes follow the repo conventions. The AC2 and AC3 reasoning is stated honestly, including the caveat that the matcher functions ran on the built chunks rather than an end-to-end audit.

@nc9

nc9 commented Oct 30, 2026

Copy link
Copy Markdown
Contributor Author

Landed in v0.0.145 as df5e36e8 7c1ebb79 36f970f0 a99872b3 via #1377. Release: https://github.com/squirrelscan/squirrelscan/releases/tag/v0.0.145. Closing this original.

nik

@nc9 nc9 closed this Oct 30, 2026
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.

perf/content-in-js-bundle: all-rendered audits read as clean; calibrate single-page severity with a real MDX positive control

1 participant