Skip to content

feat(lint): replace HTML code tags and links in descriptions + notes#29508

Draft
caugner wants to merge 15 commits into
mainfrom
replace-html-code-tags-in-description-and-notes
Draft

feat(lint): replace HTML code tags and links in descriptions + notes#29508
caugner wants to merge 15 commits into
mainfrom
replace-html-code-tags-in-description-and-notes

Conversation

@caugner

@caugner caugner commented Apr 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Extend the linter to replace raw HTML in description and notes fields with Markdown, with auto-fix support:

  • <code>…</code> → backtick-quoted code (`…`)
  • <a href='…'>text</a> → Markdown links ([text](…))

Code tags are unwrapped before links, so an anchor wrapping a <code> tag converts correctly in a single pass. In descriptions, both rules run before the canonical-description rules (constructor, event, …) so those still win.

Scope: only description and notes are covered, since those are the fields the build converts from Markdown to HTML. Some value_to_set fields (in api/PaymentRequest.json, api/PaymentResponse.json, api/PaymentMethodChangeEvent.json, api/PaymentRequestUpdateEvent.json, api/MerchantValidationEvent.json) still contain <code> HTML, but they are intentionally out of scope: value_to_set is not Markdown-rendered, and arguably should contain neither HTML nor Markdown at all.

Test results and supporting details

  • New unit tests cover the replaceCodeTagsWithBackticks / replaceLinkTagsWithMarkdown helpers, the no_code_tag_in_description / no_link_tag_in_description rules, the notes checks, and the walk-based notes fixer (including the nested-<code>-in-link case).
  • Applied the fixer to the affected data (7 links across Notification.json, ResizeObserverEntry.json, ServiceWorkerRegistration.json). The bug links previously used HTML <a> and escaped the links linter; as Markdown they now conform to it unchanged.

Related issues

@github-actions github-actions Bot added infra Infrastructure issues (npm, GitHub Actions, releases) of this project data:webext Compat data for Browser Extensions. https://developer.mozilla.org/Add-ons/WebExtensions data:api Compat data for Web APIs. https://developer.mozilla.org/docs/Web/API linter Issues or pull requests regarding the tests / linter of the JSON files. size:l [PR only] 101-1000 LoC changed labels Apr 17, 2026
@github-actions

github-actions Bot commented Apr 17, 2026

Copy link
Copy Markdown
Contributor

Tip: Review these changes grouped by change (recommended for most PRs), or grouped by feature (for large PRs).

@github-actions github-actions Bot added the merge conflicts 🚧 This PR needs to merge latest "main" branch to resolve a merge conflict or other issue. label May 7, 2026
@github-actions

github-actions Bot commented May 7, 2026

Copy link
Copy Markdown
Contributor

This pull request has merge conflicts that must be resolved before it can be merged.

@github-actions github-actions Bot removed the merge conflicts 🚧 This PR needs to merge latest "main" branch to resolve a merge conflict or other issue. label May 7, 2026
caugner and others added 7 commits July 8, 2026 19:21
When a description triggers both `no_code_tag_in_description` and a
canonical-form rule (`constructor`, `event`, …), the fixer applies
errors in array order with last write winning. Pushing the code-tag
error last overwrote the canonical expectation, so a single `fix` pass
produced a non-canonical result that only converged on a second pass.
Push the code-tag check first so canonical rules win in one pass.
Every consumer imports the helper directly from `lint/utils.js`; the
re-export from `test-descriptions.js` was never used.
The existing tests exercised only the pure `fixNotes` helper. Add
round-trip tests for the default export covering string and array
notes, array-valued support statements, and the `/browsers/` skip.
Guard the `fixNotesFixer` walk against `"mirror"` support statements,
which lack a `notes` property, and replace the nonexistent
`CompatStatement` import (from `../../types/types.js`) with
`InternalCompatStatement` from `../../types/index.js` in the notes and
descriptions tests.
Add a `replaceLinkTagsWithMarkdown` helper and wire it into the
descriptions and notes linters/fixers alongside the existing code-tag
conversion, via a new `no_link_tag_in_description` rule and a matching
notes check. Convert code tags before links so an anchor wrapping a
`<code>` tag is unwrapped first, and push the link rule ahead of the
canonical-description rules so those still win in a single fix pass.
@caugner caugner changed the title feat(lint): replace code tags in descriptions + notes feat(lint): replace HTML code tags and links in descriptions + notes Jul 9, 2026
caugner added 3 commits July 9, 2026 13:26
The array branch of `checkNotes` reassigned `errors` on each iteration,
so only the last note's `validateHTML` results were reported. Push the
per-note errors instead so invalid HTML in any note is surfaced.
The descriptions fixer reuses its linter's `processData`, but the notes
linter logs rather than returning structured errors, so the notes fixer
applies `fixNotes` over its own walk. Document the intentional asymmetry.
Both replacers match only the canonical lowercase, single-attribute tag
forms; note that other casing or attributes are left untouched and are
handled elsewhere as invalid HTML.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

data:api Compat data for Web APIs. https://developer.mozilla.org/docs/Web/API data:webext Compat data for Browser Extensions. https://developer.mozilla.org/Add-ons/WebExtensions infra Infrastructure issues (npm, GitHub Actions, releases) of this project linter Issues or pull requests regarding the tests / linter of the JSON files. size:l [PR only] 101-1000 LoC changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant