Skip to content

fix(rules): eeat/about-page and contact-page recognise in-page #about and #contact sections #1208 - #1218

Merged
nc9 merged 2 commits into
mainfrom
fix/eeat-inpage-about-contact-1208
Oct 28, 2026
Merged

nc9 merged 2 commits into
mainfrom
fix/eeat-inpage-about-contact-1208

Conversation

@nc9

@nc9 nc9 commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Closes #1208.

When no About/Contact page is found, a crawled page with an element whose id matches the page slugs (as if the path /<id>, localised slugs included) AND a same-page #fragment link to it counts as the section. About: 200+ words passes, fewer is info. Contact: mailto:/tel: link or a form on the page passes, otherwise info. Real pages take precedence; linkedUncrawledCheck (pub#740) is unchanged and runs after the section check. Rule solutions, both docs pages and CHANGELOG updated.

Tests: new tests/eeat-inpage-sections.test.ts (pass, thin, no fragment link, no element, localised ids, unrelated id, precedence); existing eeat tests unchanged. scripts/test-suites.ts --run rules passes (8010). make validate passes.

Skill: the squirrelscan agent skill needs no change.

@claude

claude Bot commented Oct 28, 2026

Copy link
Copy Markdown

Review of #1218. The approach is sound: the section needs both a matching id and a same-page link to it, and a real page still wins. I found no critical or high issues.

  • (medium) packages/rules/src/shared/inpage-section.ts:62: hasContactMethod looks at the whole document (doc.querySelector(...)), not at the section. A homepage with a footer mailto: and an empty <section id="contact"> passes, so the "section needs an email, phone or form" check can't fail on most real sites. The docs say "the section, or the page holding it", but the JSDoc and the info message say "the section". Check inside el first. If you want a page-wide fallback, say so in the docs and add a test for it.
  • (medium) inpage-section.ts:60: the word count uses el.textContent. AGENTS.md says rules that judge words a visitor reads should use getRenderedProseText. textContent counts <script>, <style> and <template> content, and glues table cells together, so a thin About section holding inline JSON or script can pass the 200-word bar. Add a test for that case.
  • (low) docs/rules/eeat/contact-page.mdx:27: the existing paragraph still says "A contact form is not detected", but the new section check counts a form. Reword it so it says forms count only for an in-page section.
  • (low) inpage-section.ts:44-57: this runs two querySelectorAll calls per crawled page and a regex test per [id] element. It only runs when no real About or Contact page exists, so it is bounded. A page with tens of thousands of ids still gets no time budget or cap. Test the id patterns only on ids that are in linked, and cap the number of anchors you collect.
  • (low) inpage-section.ts:50: getPathname("https://x.invalid/" + id) fails on ids with ?, # or /. An id like about/x or about?x is read as a path or query, which is a looser match than "as if the path were /". It also needs a comment, because the .invalid host is non-obvious. Percent-encode the id first, or test the patterns against /${encodeURIComponent(id)}.
  • (nit) Tests: there is no contact precedence test (a real /contact page next to an in-page section). There is no test for a # link with a different-case id, and none for the section on a non-root page, which exercises describeSectionPage.
  • (nit) about-page.ts: findInPageSection runs eagerly in the main flow while the contact rule runs it lazily. The about rule only computes it when there is no aboutPage, which is fine. Moving it into the else branch would match the contact rule.

Docs and the CHANGELOG look consistent with the code.

@nc9

nc9 commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

Round 1. Medium 1: kept page-wide contact method on purpose, it is the issue's spec ("the section, or the page holding it"); JSDoc and docs now say so, test added (footer mailto + empty section passes). Medium 2: word count uses getRenderedProseText, script-content test added. Low: contact docs paragraph reworded; id patterns tested only on linked ids, fragment anchors capped at 500; id encoded as /<encodeURIComponent(id)> (no .invalid host), slash/query ids test. Nits: contact precedence, different-case link id, non-root page tests added; about rule computes the section lazily in the else branch.

@claude

claude Bot commented Oct 28, 2026

Copy link
Copy Markdown

Review of #1218. I read the diff and the EEAT_PAGE_PATTERNS regexes. I did not run the tests. The approach is sound: the section needs both a matching id and a same-page #fragment link, real pages take precedence, and the linkedUncrawledCheck ordering is preserved. I found nothing blocking.

  • (low) packages/rules/src/shared/inpage-section.ts:62 hasContactMethod looks at the whole document (doc.querySelector(...)), not the section. Any mailto:, tel: or unrelated <form> (a newsletter or search form, say) on a page with an empty #contact passes. The docs and the InPageSection comment disclose the page-wide mailto/tel behaviour. A footer mailto: is a deliberate test case. A bare <form> anywhere on the page is the weak spot. Consider scoping forms to the section, and keeping the page-wide fallback for mailto/tel only.
  • (low) inpage-section.ts:50-55 The [id] scan is unbounded, but the anchor scan is capped at 500. It also runs for every crawled page that has a fragment link, with no deadline or yield. It is linear, so it is probably fine, but the AGENTS.md guidance on untrusted input suggests a cap on the [id] scan, for example .slice(0, N). Alternatively, iterate the linked ids and use getElementById or a selector.
  • (low) about-page.ts let section ... plus an assignment inside the else if condition is hard to read, and lint rules such as no-cond-assign may flag it. Compute section before the branch, or in a helper.
  • (nit) about-page.ts An about page that is crawled but has an unrelated section id still goes through the normal path, which is right. There is no test for the reverse: a thin /about page next to a rich #about section. It is a one-line addition.
  • (nit) Case-sensitive matching (#About against id=about) matches browser behaviour and is tested. The [id] scan does not dedupe duplicate ids, so the first match wins, which is acceptable.
  • (nit) Docs and CHANGELOG are updated. The CHANGELOG bullet mentions only about-page in its link; the contact-page docs link could be added too.

@claude

claude Bot commented Oct 28, 2026

Copy link
Copy Markdown

Review of #1218. I read the diff only and did not run the tests or lint.

The change looks correct overall. Requiring both a matching id and a same-page #fragment link keeps stray ids from counting, and real pages still take precedence. The tests cover the main false-positive shapes: no link, no element, a case mismatch, ids holding / or ?, and script text inside a section.

  • (medium) packages/rules/src/shared/inpage-section.ts (hasContactMethod): it is computed from the whole document (doc.querySelector(...)), not from the section. A page with a mailto: link in the footer and an empty or irrelevant #contact element passes. A test pins this and the docs describe it, so it looks deliberate. It is lenient, though. It can pass a section that offers no way to make contact. Consider counting the page-wide link only when the section is small, or at least saying in the check message that the method was found elsewhere on the page.
  • (low) packages/rules/src/shared/inpage-section.ts: findInPageSection returns the first matching element only. If a page has two elements matching the same slug, for example a nav item with id="about" before the real <section id="about">, the first, thin one decides the verdict. Consider picking the candidate with the most words. Duplicate ids are invalid HTML, but real pages have them.
  • (low) packages/rules/src/shared/inpage-section.ts: the querySelectorAll("[id]") pass has no cap, unlike the link scan, which is capped at MAX_FRAGMENT_LINKS. It also runs for every crawled page that has any fragment link, and when the whole crawl has no match it is O(pages × elements). Iterating only the linked ids with getElementById or an attribute selector would bound it and be cheaper. Per AGENTS.md, site-controlled input should be bounded.
  • (low) packages/rules/src/eeat/about-page.ts: else if ((section = findInPageSection(...))) assigns inside a condition, and let section is declared far above its use. This will likely trip no-cond-assign in oxlint. It would be clearer to compute const section = aboutPage ? null : findInPageSection(...) before the branch.
  • (nit) about-page.ts: section.wordCount >= 200 duplicates the page-level threshold. Reuse the existing constant if there is one.
  • (nit) The mailto: selector uses the i attribute flag. A test with MAILTO: or Tel: would confirm linkedom supports it.
  • (nit) The PR text does not say whether streaming-rules-canonical-golden was run. These are site rules with no new ids, so the pins should not move, but confirm the synthetic site has no #about or #contact section.

I have no (high) or (critical) findings.

@nc9
nc9 force-pushed the fix/eeat-inpage-about-contact-1208 branch from 5b534c0 to f812e7d Compare October 28, 2026 05:31
@claude

claude Bot commented Oct 28, 2026

Copy link
Copy Markdown

Reviewed the diff. The approach is sound: the section needs both a matching id and a same-page fragment link, real pages take precedence, and the regex and DOM work is bounded. I found no blocking issues. I only read the diff and did not run the tests or lint.

  • (low) packages/rules/src/shared/inpage-section.ts:57 querySelectorAll("[id]") is not capped, unlike the fragment links, which stop at 500. The linked.has(id) check keeps the per-element work cheap, but a page with a huge number of ids is still walked in full for every crawled page that has a # link. Consider building the linked lookup first and querying only those ids, or capping the element scan.
  • (low) inpage-section.ts:70 hasContactMethod looks at the whole document, so an empty <section id="contact"> passes if a footer has a mailto link. The docs describe this, but it makes the check weaker than 'the section has a way to make contact'. The tests pin the behaviour, so it is a deliberate choice. Consider checking inside the section first and falling back to the page only on a thin section.
  • (nit) about-page.ts assigns section inside the else if condition. That is easy to misread and may trip no-cond-assign in oxlint. Computing it before the chain would be clearer, but only on the no-page path.
  • (nit) Missing test: a section whose id matches the pattern but whose fragment link is on a different crawled page than the element. The current behaviour (no match) looks right, so a test would just pin it.
  • (nit) CHANGELOG.md and the docs look consistent with the code. I did not check whether the PR needs a .secrets.baseline update or the docs:check run. The description says make validate passes.

@nc9
nc9 merged commit 1e3cb34 into main Oct 28, 2026
15 checks passed
@nc9
nc9 deleted the fix/eeat-inpage-about-contact-1208 branch October 28, 2026 05:47
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.

eeat/about-page and eeat/contact-page: recognise in-page #about and #contact sections on single-page sites

1 participant