Skip to content

links/anchor-text counts per link, not per (source, target) pair — fires on every card #104

Closed

Description

@nc9

Part of #103 (V-06).

packages/rules/src/links/anchor-text.ts iterates doc.querySelectorAll("a[href]") and pushes one
finding per link. The standard card pattern — an image link, a headline link and a Read more link,
all pointing at the same target — therefore produces two findings: empty-anchor for the image
wrapper and generic-anchor for Read more, while the headline link in the same card names the
target perfectly
.

Nothing is wrong with that markup. It is the recommended pattern: the image and the Read more
affordance are redundant links to a target the card already labels.

Measured: an internal audit pass making exactly this mistake reported 163 findings on a 163-page
site. Recounting per (source page, target) pair took it to 0 real.
A rule that fires on every blog
index and every service grid trains users to ignore the whole links category.

The fix is the counting unit, not the detection: group a page's outgoing links by resolved target,
and evaluate the group. A group passes if any member carries usable text (text content, image
alt, aria-label, aria-labelledby, title, or an accessible SVG name — all already handled per
link).

Note this is narrower than it sounds: genuinely empty single links, and cards where every link is
empty or generic, must still be reported. The accessibility concern about an empty link in the tab
order is real, but it belongs to the a11y category, which has its own rules for it —
links/anchor-text is an SEO rule about whether the destination is described.

Acceptance Criteria

  • links/anchor-text groups a page's outgoing links by resolved target URL before evaluating
  • A target group is reported as empty-anchor only when NO link in the group carries any accessible name (text, image alt, aria-label, aria-labelledby, title, or SVG accessible name)
  • A target group is reported as generic-anchor only when EVERY link in the group has generic text
  • Findings are deduplicated per target: one card produces at most one item
  • Fixture: card with <a><img alt=""></a>, <a>Commercial freezer repairs</a> and <a>Read more</a> all pointing at the same URL — no findings
  • Fixture: single <a><img alt=""></a> with no sibling link to the same target — still reported as empty-anchor
  • Fixture: card where all three links are empty or generic — reported once, not three times
  • Existing tests updated, and a regression test asserts the multi-link card yields zero findings
  • Docs rule page for links/anchor-text updated in docs/ to describe per-target evaluation

Activity

  1. added
    bug
    P2
    size: XS
    rules
    on Aug 19, 2026
  2. nc9 commented on Aug 19, 2026

    @nc9
    ContributorAuthor

    🐹 hamsterwheel claimed this issue.

    • run: loop-mszv1wzc-104
    • branch: loop/104-links-anchor-text-counts-per-link-not-pe
    • started: 2026-08-19T08:59:51.359Z
  3. nc9 commented on Aug 19, 2026

    @nc9
    ContributorAuthor

    🐹 PR opened: #111

    --pr-only: stopping here for human review — merge gate and auto-merge skipped.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2bugrulessize: XS

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions