Skip to content

fix(mdn): improve key-not-found error hint#5137

Open
marcoscaceres wants to merge 3 commits intomainfrom
fix/mdn-key-hint
Open

fix(mdn): improve key-not-found error hint#5137
marcoscaceres wants to merge 3 commits intomainfrom
fix/mdn-key-hint

Conversation

@marcoscaceres
Copy link
Copy Markdown
Contributor

The hint for a missing MDN key sent users to a raw JSON URL (unreadable) and wasn't using docLink so nothing was clickable.

Changes

  • Uses docLink so [shortName] and [mdn] link to their documentation pages
  • Explains that mdn: true uses shortName as the key automatically — the most common fix
  • Links to the GitHub-rendered SPECMAP.json instead of the raw URL (syntax highlighted, Ctrl+F searchable)
  • Removes redundant repetition of the key from the hint (it's in the error message)

Before

Hint: Please add a valid key to `respecConfig.mdn`

After

Hint: If using `mdn: true`, check that [shortName] is set correctly — the MDN key
defaults to the spec's shortName. Otherwise, search for your spec's URL in the
[MDN spec links map] to find the correct key, then set [mdn] to it.

(with shortName, MDN spec links map, and mdn as clickable links)

🤖 Generated with Claude Code

Previous hint sent users to a raw JSON URL (non-clickable, hard to read).

New hint:
- Uses docLink so [shortName] and [mdn] are clickable links to the docs
- Explains that mdn: true uses shortName as the key (common confusion)
- Links to GitHub-rendered SPECMAP.json (syntax highlighted, searchable
  with Ctrl+F) instead of the raw URL
- Removes the duplicate of the error message from inside the hint
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Improves the developer-facing hint shown when an MDN annotation key can’t be found, making it more actionable and adding clickable documentation links.

Changes:

  • Uses docLink so references to [shortName] and [mdn] render as clickable links to ReSpec docs.
  • Expands the 404 “key not found” hint to explain the common mdn: true / shortName default behavior.
  • Links to the GitHub-rendered SPECMAP.json instead of a raw JSON URL.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 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.

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 = docLink`If using \`mdn: true\`, check that ${"[shortName]"} is set correctly — the MDN key defaults to the spec's shortName. Otherwise, search for your spec's URL in the [MDN spec links map](https://github.com/w3c/mdn-spec-links/blob/main/SPECMAP.json) to find the correct key, then set ${"[mdn]"} to it.`;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can check mdn === true and provide a more specific message?

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.

3 participants