fix(error-messages): improve hints in xref, mdn-annotation, link-to-dfn#5135
fix(error-messages): improve hints in xref, mdn-annotation, link-to-dfn#5135marcoscaceres wants to merge 3 commits intomainfrom
Conversation
f402eba to
a2b73df
Compare
xref.js: invalid xref config value had no hint. Now explains the four valid forms: boolean, profile name, array of shortnames, or object. mdn-annotation.js: hint said 'add a valid key' but didn't say where to find one. Now links directly to SPECMAP.json. link-to-dfn.js: linkless <a> warning had no hint. Now suggests adding a <dfn>, using data-cite, or enabling xref. Also adds docLink import. docs: add error message audit report (2026-03-28-error-message-audit.md) documenting all 8 issues found, 6 already fixed, patterns to follow.
a2b73df to
62ce2a7
Compare
There was a problem hiding this comment.
Pull request overview
Improves author-facing lint/error hints in core modules to make configuration and linking failures more actionable and easier to resolve.
Changes:
- Add a detailed
xrefconfig hint (with docs link) for invalid configuration types. - Improve the MDN annotation missing-key hint by pointing to the MDN key registry.
- Add actionable guidance (and import
docLink) for linkless<a>warnings inlink-to-dfn.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/core/xref.js |
Adds a docLink-backed hint describing valid xref configuration forms. |
src/core/mdn-annotation.js |
Updates the 404 hint text to point users at the MDN spec map URL. |
src/core/link-to-dfn.js |
Adds docLink import and expands the warning hint for linkless anchors, including a scoping note. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/core/link-to-dfn.js
Outdated
| @@ -312,7 +313,14 @@ function showLinkingError(elems) { | |||
| elems.forEach(elem => { | |||
| const msg = `Found linkless \`<a>\` element with text "${elem.textContent}" but no matching \`<dfn>\``; | |||
| const title = "Linking error: not matching `<dfn>`"; | |||
There was a problem hiding this comment.
The warning title reads "not matching <dfn>", which is grammatically off and inconsistent with the message (“no matching <dfn>”). Consider changing it to “no matching <dfn>”.
| const title = "Linking error: not matching `<dfn>`"; | |
| const title = "Linking error: no matching `<dfn>`"; |
There was a problem hiding this comment.
Fixed title in 4a94f64 ('not matching' → 'no matching'). Also corrected the scoping note — data-dfn-for on an ancestor does NOT scope link resolution (that's data-link-for), so the old message was misleading. Kept the detection heuristic using data-dfn-for since that's still the right context to flag; just fixed what the message says.
| if (res.status === 404) { | ||
| const msg = `Could not find MDN data associated with key "${key}".`; | ||
| const hint = "Please add a valid key to `respecConfig.mdn`"; | ||
| const hint = `Could not find MDN data for key "${key}". Browse available keys at https://w3c.github.io/mdn-spec-links/SPECMAP.json and set respecConfig.mdn to the matching key.`; |
There was a problem hiding this comment.
This hint suggests setting respecConfig.mdn, but the config also supports an object form (e.g., respecConfig.mdn.key). To avoid confusing users who already use the object form, consider mentioning both, and format the config keys/URL as markdown (e.g., backticks and a clickable link).
| const hint = `Could not find MDN data for key "${key}". Browse available keys at https://w3c.github.io/mdn-spec-links/SPECMAP.json and set respecConfig.mdn to the matching key.`; | |
| const hint = `Could not find MDN data for key "${key}". Browse available keys at [\`SPECMAP.json\`](https://w3c.github.io/mdn-spec-links/SPECMAP.json) and set \`respecConfig.mdn\` or \`respecConfig.mdn.key\` to the matching key.`; |
There was a problem hiding this comment.
This hint is superseded by PR #5137 which rewrites it with docLink syntax, mentions both mdn: true and mdn.key, and links directly to SPECMAP.json. No change here to avoid conflicts.
There was a problem hiding this comment.
Superseded by PR #5137 which rewrites this hint with docLink, mentions both mdn: true and mdn.key, and links to SPECMAP.json.
There was a problem hiding this comment.
Also, the hint is repeating title here. When both are shown together, it's just noise.
- Fix title: 'not matching' → 'no matching' (consistent with msg text) - Fix hint: data-dfn-for does NOT scope link resolution (data-link-for does). Old message incorrectly said links were scoped to the context. New message correctly explains the distinction and shows how to explicitly scope a link with [=Iface/term=] or data-link-for.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
Improves three error/warning messages that were either missing hints or had hints too vague to act on. Found during an error message quality audit across ~85
showError/showWarningcalls.src/core/xref.jsInvalid
xrefconfig value had no hint at all. Now explains all four valid forms:src/core/mdn-annotation.jsHint said "Please add a valid key to
respecConfig.mdn" but gave no indication of where to find valid keys. Now links directly to the source of truth:src/core/link-to-dfn.jsLinkless
<a>warning had no hint. Authors seeing "no matching<dfn>" had no guidance on what to do. Now suggests three actionable paths:Also adds
docLinkto the imports inlink-to-dfn.jsto enable the linked hint text.🤖 Generated with Claude Code