Skip to content

feat(rules): link-text and anchor-text recognise generic phrases in 10 more languages #840 - #1019

Closed
nc9 wants to merge 2 commits into
mainfrom
feat/840-generic-link-phrases
Closed

nc9 wants to merge 2 commits into
mainfrom
feat/840-generic-link-phrases

Conversation

@nc9

@nc9 nc9 commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Closes #840

a11y/link-text and links/anchor-text now recognise generic link text in the page language, chosen by the primary subtag of <html lang>, with English always checked.

  • New shared/generic-link-phrases.ts: lists for es, fr, de, pt, it, nl, ja, zh (simplified and traditional), ko, ru. Whole-text match after the same normalisation as the conventional labels (NFKC, case folding, edge and full-width punctuation removed); CJK is never split into words.
  • No or unknown lang (including en) checks English only; one language's phrase is not applied on another language's page.
  • The conventional account and legal labels from fix(rules): legal pages skipped by no-contextual-inbound, conventional labels exempt in link-text #981 #839 #1006 win in every language, in both rules (anchor-text gains the guard too).
  • anchor-text keeps testing the link's text only, as before; link-text keeps its accessible-name path.

Tests: generic-link-phrases-840.test.ts (52): per language a reported generic phrase and a non-reported descriptive link, for both rules; punctuation, case and region subtags; English on a non-English page; no/unknown lang; whole-text only; conventional labels in 13 language/label pairs; CJK no word split. With anchor-text.test.ts and the 839 tests: 121 pass. tsgo --noEmit in packages/rules clean, tangly check --strict passes.

Docs: new "Generic phrases in other languages" section in a11y/link-text, and a sentence in links/anchor-text; CHANGELOG bullet. Agent skill: no change needed.

The phrase lists are conservative, my own picks per language (about 15 each), and open to native-speaker edits, especially ja, zh, ko and ru. Review trims: the ambiguous pager and wizard words (de weiter, fr suite, ru продолжить, it altro, nl verder) are left out; three-letter language codes (deu, fra, jpn ...) map to their primary tag; only the primary <html lang> is read (a nested lang, or other-language text on a page, is not detected), and the docs say so.

@claude

claude Bot commented Oct 22, 2026

Copy link
Copy Markdown

Review of #1019 (localised generic link text).

The design is sound: whole-text matching, English always checked, and conventional labels win. The tests are thorough. I read the diff and spot-checked the helpers. I did not run the test suite.

  • (low) links/anchor-text.ts:64 Conventional labels are now exempted for every phrase, including the English ones. Before this PR, English generic anchors were not filtered this way. This is probably harmless, since the English list has no conventional labels, but the behaviour change isn't covered by a test or mentioned in the docs. Either note it or limit the exemption to the new language lists.
  • (low) a11y/link-text.ts The isGeneric helper receives a lowercased text or accessibleName as raw. That is fine, because normalizeLinkLabel case-folds. The parameter name is misleading, though.
  • (low) generic-link-phrases.ts Some entries are ambiguous as whole-text matches. Examples are Italian "vai" and "altro", Portuguese "clique", and German "weiter" and "link". They are plausibly generic as link text, so this is only a false-positive risk, and the severity is info or low.
  • (nit) hasGenericPhrases is exported but unused in this diff.
  • (nit) The zh list mixes Simplified and Traditional characters, and 了解更多 appears in both groups. It is harmless because the set deduplicates. Splitting the lists would still read better.
  • (nit) Test coverage: there is no case for a lang value with whitespace or underscore variants inside the rule tests. The helper test covers this.

@claude

claude Bot commented Oct 22, 2026

Copy link
Copy Markdown

Reviewed the diff; I didn't run the tests or CI.

  • (low) packages/rules/src/shared/generic-link-phrases.ts: hasGenericPhrases is exported but nothing in the diff calls it. Remove it, or add a test for it.
  • (low) packages/rules/src/links/anchor-text.ts: isConventionalLinkLabel(raw) now also runs for the English GENERIC_ANCHORS match. The English generic phrases aren't conventional labels, so this should change nothing. The call is also redundant with the guard inside isGenericInPageLanguage, and the English check could skip it.
  • (nit) packages/rules/src/a11y/link-text.ts: the normalizedName and normalizedText helpers in this rule use [.,!?;:'"], while generic-link-phrases.ts uses normalizeLinkLabel. The two paths normalise differently (NFKC and full-width punctuation only on the language path), so English with full-width punctuation still won't match. Fine for now, but a shared normaliser would be cleaner.
  • (nit) The language phrase lists include very short or ambiguous words, such as ici, qui, here-style words, mehr, plus, больше and クリック. They match the whole text only, so the false-positive risk is low. Native-speaker review of ja, zh, ko and ru is still worthwhile, as the PR says.

Tests cover both rules, region subtags, no or unknown lang, whole-text matching, conventional labels and CJK. I found no correctness or security problems.

nc9 added a commit that referenced this pull request Oct 22, 2026
…nt, skip reasons, link phrases (#1034)

Batch of six reviewed PRs landed through one branch and one CI run:
- #1032 Bun 1.4.4 pin (CA blocklist for the eight compromised eMudhra intermediates, NSS 3.131.1 roots)
- #1030 nested CSS evidence for the style reader (repro from #1014 by @dbdefault)
- #1025 page-intrinsic skips use a not-applicable reason so priors resolve
- #1019 generic link phrases in ten more languages for link-text and anchor-text
- #1021 content/word-count skips noindex pages
- #1023 retirement of abandoned crawls uses the crawl lease
Plus a test fix for the residency probe on Bun 1.4.4 linux-x64.

Closes #840
Closes #946
Closes #1011
Closes #1013
Refs #841

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

nc9 commented Oct 22, 2026

Copy link
Copy Markdown
Contributor Author

Landed through integration PR #1034 (squash merge 4dc22a9 on main), released in v0.0.128. Closing as superseded.

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

a11y/link-text and links/anchor-text only recognise English generic phrases

1 participant