Skip to content

fix(rules): legal pages skipped by no-contextual-inbound, conventional labels exempt in link-text #981 #839 - #1006

Merged
nc9 merged 2 commits into
mainfrom
fix/981-839-231-rule-noise
Oct 22, 2026
Merged

nc9 merged 2 commits into
mainfrom
fix/981-839-231-rule-noise

Conversation

@nc9

@nc9 nc9 commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Closes #981
Closes #839

Two small commits, different rules.

#981 links/no-contextual-inbound: skips legal pages (privacy, terms, imprint, /legal, /legal-notice, /aviso-legal, ... in the languages the EEAT privacy and terms slug sets cover) matched on the last path segment under any prefix, so /en/legal, /impressum, /datenschutz, /agb are not reported. A non-legal footer-only page and a slug that merely contains a legal word (/legalese-guide) still are. The existing fixtures used /legal as the footer-only page; they now use /pricing (rule test and the audit-engine site-query golden).

#839 a11y/link-text: new shared/conventional-link-labels.ts (whole-text match after NFKC, case folding, edge punctuation strip; union across en, es, fr, de, pt, it, nl, ja, zh, ko, ru). The six account phrases leave the generic list (54 to 48 phrases) and the conventional set is checked first. click here, read more, learn more, here, more, link, this, go, continue still reported. links/anchor-text and a11y/identical-links-same-purpose checked: neither lists these labels as generic, no change needed (noted in the docs page).

#231 not changed here: the wording and rating-scope fixes already landed in #611 (security/sri and content/meta-in-body use the (s) form, rating-scope has no product name). The only unticked criterion is re-running the production identity projection, which is not code. Left open.

Tests: no-contextual-inbound (rule + audit-engine golden) 42 pass, conventional-link-labels-839.test.ts 62 pass (a test per language), naming-rules-hidden-993 pass. tsgo --noEmit in packages/rules clean. tangly check --strict passes.

Docs updated for both rules, CHANGELOG bullet per fix. Agent skill: no change needed.

@claude

claude Bot commented Oct 22, 2026

Copy link
Copy Markdown

Reviewed the diff for links/no-contextual-inbound, a11y/link-text and the new shared/conventional-link-labels.ts. I found no blocking problems. I only read the code; I did not run the tests or look at CI.

  • (low) packages/rules/src/links/no-contextual-inbound.ts: the PR description says legal pages are matched on the last path segment. The patterns are end-anchored regexes tested against the whole pathname, so they behave the same way. I checked EEAT_PAGE_PATTERNS and they are anchored. /legalese-guide is correctly not matched. A test that includes a query string or fragment would pin down getPathname behaviour, e.g. /privacy?lang=en.
  • (low) packages/rules/src/links/no-contextual-inbound.ts: the eight extra legal patterns repeat the (?:\/|\.html?)?$ suffix by hand. A small helper or a single regex built from a slug list would be shorter and harder to get wrong.
  • (low) packages/rules/src/shared/conventional-link-labels.ts: some entries are duplicated across languages and groups (entrar, sitemap, contact, support, privacy). The Set absorbs them, so this is harmless.
  • (low) packages/rules/src/shared/conventional-link-labels.ts: the set now exempts sign up, register and login everywhere, including as in-body CTAs. That is the intended trade-off, and the file notes the set can only remove findings. Mentioning it in case you want it called out in the rule docs.
  • (nit) packages/rules/src/a11y/link-text.ts: link-text normalizes the text twice, once with its own [.,!?;:'"] strip and again inside isConventionalLinkLabel. This is correct today because the conventional set is checked on the already-stripped string. Passing the raw text to isConventionalLinkLabel would avoid any drift between the two normalizations.
  • (nit) packages/rules/src/shared/conventional-link-labels.ts: .replace(/[\s ]+/g, " ") mixes a literal non-breaking space into the character class. Use \u00a0 so the character is visible in the source.

Test coverage looks good: there is a new 839 test file, the fixtures moved from /legal to /pricing, and the golden was updated.

@nc9
nc9 force-pushed the fix/981-839-231-rule-noise branch from 42a3ad5 to 5729429 Compare October 22, 2026 02:29
@claude

claude Bot commented Oct 22, 2026

Copy link
Copy Markdown

Review of #1006 (conventional link labels for `link-text`, legal-page skip for `no-contextual-inbound`).

I read the source diff. I did not run the tests.

  • (low) `packages/rules/src/shared/conventional-link-labels.ts`: several labels repeat across language blocks (`entrar`, `sitemap`, `contact`, `privacy`, `support`, `precisamos`-style duplicates). The `Set` deduplicates them, so nothing breaks. Still, it is easy to lose track of which language owns a label, so consider a comment or a dedupe check in the tests.
  • (low) `link-text.ts`: `isGenericLinkText` only matters for phrases that are in both lists. The old `sign up`, `register`, `login`, `log in` and `sign in` entries were removed from `GENERIC_LINK_TEXT`, so the shared-set check is now partly redundant for those. This is harmless. The `48 generic phrases` count in the docs matches the removal of 6 entries, which looks right.
  • (low) `link-text.ts`: the two normalisations differ. The generic check strips `[.,!?;:'"]` and the conventional check uses NFKC plus `\p{P}\p{S}`. The result is correct, because the conventional set only removes findings. A single shared normaliser would be simpler to reason about.
  • (nit) `no-contextual-inbound.ts`: the import from `@squirrelscan/utils/constants` sits between two imports from `@squirrelscan/utils`. Merge the `@squirrelscan/utils` imports.
  • (nit) `LEGAL_PATH_PATTERNS` is built on every module load and `isLegalPage` runs per URL. That cost is negligible. The patterns are end-anchored, so `/legal/foo` subpages are not skipped. That is probably intended, and the docs say so.
  • (nit) The non-Latin and accented label entries rely on NFKC and lowercasing. Accented and unaccented forms are both listed, but combining-mark variants are only handled through NFKC composition. The tests look like they cover the main cases.

Tests cover both rules, including the golden test. The change is limited to removing findings, so false-positive risk is low. No correctness, security or performance blockers found.

@nc9
nc9 merged commit 2dbf520 into main Oct 22, 2026
15 checks passed
@nc9
nc9 deleted the fix/981-839-231-rule-noise branch October 22, 2026 02:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant