Skip to content

links/anchor-mismatch: false positives on translated stores (inflections, counts, nav chrome) #2092

Closed

Description

@deniskern

Version: squirrel v0.0.180 (release notes up to v0.0.183 checked, no related change), Shopify store with Shopify Markets locales (/da-dk/, /en/, …).

Observed: links/anchor-mismatch produced one group with ~1,480 link pairs to ~200 target pages, almost all on a translated locale. Samples, all correct, translated theme UI labels:

  • "Sadler / Til cykelsadlerne" -> /da-dk/collections/cykelsadel, target title "Køb cykelsadel: …". Sadler and cykelsadlerne are inflections of sadel/cykelsadel; exact word comparison finds no match.
  • "Beklaedning (15)" -> /da-dk/collections/bekleidung: a category pill with a trailing product count and a German handle that Shopify keeps untranslated in every locale.
  • "Mere om klubben" -> /da-dk/pages/club: a translated "learn more" label in a content block.

Expected: anchors are compared with the target's title/H1 in the link's locale rather than the untranslated URL handle; matching tolerates inflection and compounds (stemming or prefix overlap of ≥4–5 chars for words of 5+ chars); trailing counts like (15) are stripped; links inside header, footer and nav landmarks are skipped (site chrome, not editorial anchors).

Why it matters: on multilingual Shopify stores handles stay in the default language, so nearly every translated anchor fails the slug comparison and the group drowns the few real mismatches.

Repro: crawl any Shopify Markets store on a non-default locale path with the default config and filter links/anchor-mismatch.

Triage

Partly confirmed. Today links/anchor-mismatch (packages/rules/src/links/anchor-mismatch.ts) already skips links flagged isChrome (nav, header, footer, aside), so your fourth point depends on the theme: links in a content block (like "Mere om klubben") are not chrome and still count. The comparison uses the target's title, H1 and URL slug. tokensMatch accepts only a prefix with at most 3 trailing characters, so Sadler vs sadel and cykelsadlerne vs cykelsadel fail. Nothing strips a trailing count such as (15), and the rule has no page language, so a handle that stays German in every locale cannot be judged by slug.

Related closed issues on the same rule: #1598, #1626, #1729.

Acceptance Criteria

  • An anchor that is an inflection of a target title/H1 word (Sadler, cykelsadlerne vs cykelsadel) is not reported
  • A trailing count on an anchor (Beklaedning (15)) is stripped before comparison
  • On a locale path (/da-dk/), the anchor is compared with the target's title and H1 in that locale, and an untranslated slug alone does not cause a finding
  • Links inside header, footer and nav landmarks stay excluded, with a test
  • A genuine mismatch on a translated page is still reported (regression test)
  • Tests cover the Danish and German samples from this report

Generated by Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugrulessize: M

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions