fix(lint-mdx): detect multi-line opening tags in component attribute check - #1796
Open
teyrebaz33 wants to merge 2 commits into
Open
fix(lint-mdx): detect multi-line opening tags in component attribute check#1796teyrebaz33 wants to merge 2 commits into
teyrebaz33 wants to merge 2 commits into
Conversation
The alt-attribute check in checkMintlifyComponents only looked at the single line containing '<img', so when an <img> tag's attributes were spread across multiple lines (a common JSX formatting style used throughout docs/), a present alt= attribute on a later line was never seen and the linter reported a false-positive missing-alt warning. This affected 5 warnings across 3 files that already had a valid alt attribute: - docs/base-account/improve-ux/sponsor-gas/paymasters.mdx (2) - docs/base-account/reference/ui-elements/brand-guidelines.mdx (2) - docs/snippets/BasePayButton.mdx (1) The check now accumulates lines starting at the <img> tag until the tag closes (or end of file), matching the multi-line lookback pattern already used by the adjacent <Frame>-wrapping check in the same file. Verified with node scripts/lint-mdx.js all: warnings drop from 75 to 70 (exactly the 5 false positives), errors unchanged at 1246. Also verified against a synthetic missing-alt case and a synthetic multi-line-with-alt case to confirm the check still catches real violations and doesn't over-suppress.
…check The opening-tag check in checkMintlifyComponents matched tags against a regex applied only to the current line. When a tag's name was on its own line with attributes spread across the following lines (e.g. <Card on one line, title=... on the next), the regex never matched, so the tag was silently skipped entirely - no required-attribute check, no CardGroup cols check, no parent/child stack tracking. Found 5 such multi-line tags across 2 files, all with valid required attributes that were never actually being checked before this fix: - docs/base-account/quickstart/ai-tools-available-for-devs.mdx (3 <Card> tags, lines 10, 47, 67) - docs/apps/resources/templates.mdx (2 <Card> tags, lines 22, 28) The check now accumulates lines starting at a lone opening-tag line until a '>' is found, then matches the existing regex against the accumulated text. isSelfClosing was also updated to check the accumulated text instead of only the first line, since a multi-line tag's closing '/>' would otherwise never be seen. Verified with node scripts/lint-mdx.js all: totals unchanged at 1246 errors / 70 warnings (all 5 tags already had valid required attributes, so this closes a detection gap without surfacing new findings). Also verified against a synthetic multi-line <Card> missing title=, which is now correctly flagged (previously would have been silently skipped).
Collaborator
🟡 Heimdall Review Status
|
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.
Fixes #1795
Problem
The opening-tag check in scripts/lint-mdx.js only matched tags against a regex applied to a single line. When a tag's name was on its own line with attributes spread across following lines, the regex never matched and the tag was silently skipped - no required-attribute check, no CardGroup cols check, no parent/child stack tracking.
Fix
The check now accumulates lines starting at a lone opening-tag line until a closing > is found, then matches the existing regex against the accumulated text. isSelfClosing was also updated to check the accumulated text instead of only the first line.
Scope
Found and fixed for 5 real multi-line tag instances across 2 files:
Verification