Conversation
Contributor
|
56cdf09 was deployed to: https://fred-pr1886.review.mdn.allizom.net/ |
caugner
force-pushed
the
lint-external-link-whitespace
branch
from
September 10, 2026 12:19
725d701 to
797a75c
Compare
caugner
added this pull request to stack #1887
September 10, 2026 12:20
fred/no-external-link-whitespace rule + strip whitespace in external linksfred/no-external-link-whitespace rule
Flag `<a>` elements with the `external` class inside `html` templates
whose content starts or ends with whitespace, and offer an autofix that
strips it. Whitespace before `</a>` renders as a space, which pushes the
external-link icon onto its own line when the text wraps.
Prettier does not reintroduce the whitespace once removed (it emits the
`>${text}</a\n>` form), so the rule and formatter are stable together.
Start at `warn` so the rule can land before the existing violations are fixed; a follow-up elevates it to `error`.
caugner
force-pushed
the
lint-external-link-whitespace
branch
from
September 10, 2026 12:49
797a75c to
ea168f4
Compare
caugner
removed this pull request from stack #1887
September 14, 2026 15:09
Contributor
Author
|
Closing in favor of one-time fixes. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Add a custom ESLint rule
fred/no-external-link-whitespacethat flags<a>elements with theexternalclass insidehtmltemplates whose content starts or ends with whitespace, with an autofix that strips it.RuleTesterunit tests inbuild/eslint-fred.jsandtest/unit/build/eslint-fred.test.js.eslint.config.jsaswarn, so it can land before the 14 existing violations are fixed.Motivation
Ensure the external-link icon stays attached to the last word of the link. Whitespace before
</a>renders as a space, so when the link text wraps, the icon drops onto its own line. Prettier introduces this whitespace whenever it wraps the link text onto its own line, so a lint rule is needed to keep it out.Additional details
Prettier does not reintroduce the whitespace once removed: it formats a whitespace-free anchor as
>${text}</a\n>, so the rule and the formatter are stable together.Rari does not add whitespace to external links, and a scan of a fresh en-US content build found only one external link out of about 30k with trailing whitespace, so the templates in this repo are the main source.
Related issues and pull requests