From 23167b144942ee7531f7a007c5c71ca12979792a Mon Sep 17 00:00:00 2001 From: teyrebaz33 Date: Tue, 11 Aug 2026 02:36:00 +0300 Subject: [PATCH] fix(lint-mdx): handle multi-line tags in alt-attribute check The alt-attribute check in checkMintlifyComponents only looked at the single line containing ' 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 tag until the tag closes (or end of file), matching the multi-line lookback pattern already used by the adjacent -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. --- scripts/lint-mdx.js | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/scripts/lint-mdx.js b/scripts/lint-mdx.js index 07c42575b..43978a798 100755 --- a/scripts/lint-mdx.js +++ b/scripts/lint-mdx.js @@ -327,13 +327,23 @@ function checkMintlifyComponents(content, filePath) { } } - // Check for img without alt + // Check for img without alt (img tag may span multiple lines) if (line.includes(" should have `alt` attribute", - }); + let tagText = line; + let hasAlt = tagText.includes("alt="); + let k = i; + while (!hasAlt && !tagText.includes(">") && k < lines.length - 1) { + k++; + tagText += lines[k]; + hasAlt = tagText.includes("alt="); + } + if (!hasAlt) { + issues.push({ + line: i + 1, + severity: "warning", + message: " should have `alt` attribute", + }); + } } }