Skip to content

Validate spec URL fragments with @webref/xref - #4713

Open
schalkneethling wants to merge 12 commits into
web-platform-dx:mainfrom
schalkneethling:validate-spec-url-fragments
Open

schalkneethling wants to merge 12 commits into
web-platform-dx:mainfrom
schalkneethling:validate-spec-url-fragments

Conversation

@schalkneethling

Copy link
Copy Markdown
Contributor

Note

This replaces #4320, which GitHub closed when I deleted my fork by mistake. The commits are unchanged from that PR (head 71d6e8f), so earlier review discussion is on #4320.

Progress on #84.

Important

Merge this after #4712. This PR makes unknown fragments fail the build, and main still has the 30 spec URLs that #4712 relinks, so test:specs fails here until #4712 lands. With #4712's data applied, test:specs passes with no errors.

Checks the fragment of every spec URL against the anchors w3c/webref crawls, using the same rules as BCD's spec_url linter (mdn/browser-compat-data#23958): skip fragment-less URLs, strip :~:text= fragments, lookup(url, { series: true, standing: "good" }).

  • Unknown fragments and text fragments fail the build: they're logged as errors and count towards the exit code. To downgrade them to warnings (for example, while working through a webref update that drops anchors), set fragmentErrorsAreFatal in scripts/specs.ts to false.
  • Adds @webref/xref as a dev dependency, at ^1.2.22. That's the version Relink spec URL fragments that webref no longer knows #4712's relinked URLs were verified against. Older versions are missing anchors that current specs define, so they report valid links as unknown.
  • npm run test:specs -- --report writes a self-contained HTML report of every fragment check to reports/spec-fragments.html.

Because @webref/xref isn't pinned to an exact version, a local npm install can pick up a newer release whose crawl no longer has an anchor that the data links to. In that case test:specs fails locally before it fails in CI. CI uses npm ci, which installs the locked version, so workflows only change when the lockfile is updated.

Per tidoust's suggestion, #4712 relinks the stale fragments to current ids rather than asking webref to carry legacy alias ids.

schalkneethling and others added 12 commits September 4, 2026 12:19
Check the fragment of every spec URL against the definition and heading
anchors that w3c/webref crawls, using the same rules as BCD's spec_url
linter (skip fragment-less URLs, strip text fragments, lookup with
series: true and standing: good). Unknown fragments warn without
failing the build while existing data is cleaned up; flip
fragmentErrorsAreFatal to make them errors.

npm run test:specs -- --report additionally writes a self-contained
HTML report of every fragment check to reports/spec-fragments.html.

Progress on web-platform-dx#84

Co-Authored-By: Claude Fable 5 <[email protected]>
Update 28 spec URLs whose fragments are legacy alias ids, renamed
anchors, or moved definitions, so they target ids that w3c/webref
records. Follows the approach suggested in web-platform-dx#84: update links to
current ids rather than asking webref to carry legacy aliases.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Fj5YkGFX6Jy2Db9UWHwxcE
Co-authored-by: François Daoust <[email protected]>
Per review feedback: web-features doesn't use text fragments today and
they break easily as spec prose changes, so treat any :~:text= fragment
as invalid instead of skipping or partially validating it.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012mrFGmopoAXrcD8CLnc8gN
# Conflicts:
#	features/anchor-positioning-transforms.yml
#	features/anchor-positioning.yml
#	features/parse-html-unsafe.yml
Fragment mismatches are now logged as errors and count towards the
exit code. Bump @webref/xref to 1.2.22 so the check uses the anchors
that web-platform-dx#4321 was verified against.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added feature definition Creating or defining new features or groups of features. tools and infrastructure Project internal tooling, such as linters, GitHub Actions, or repo settings labels Dec 3, 2026

This branch has not been deployed

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

Labels

feature definition Creating or defining new features or groups of features. tools and infrastructure Project internal tooling, such as linters, GitHub Actions, or repo settings

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant