Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions scripts/lint-mdx.js
Original file line number Diff line number Diff line change
Expand Up @@ -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("<img") && !line.includes("alt=")) {
issues.push({
line: i + 1,
severity: "warning",
message: "<img> 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: "<img> should have `alt` attribute",
});
}
}
}

Expand Down