Skip to content

Commit b2fc801

Browse files
authored
fix: update require-alt-text rule to ignore commented images (#385)
1 parent 18c7d77 commit b2fc801

2 files changed

Lines changed: 2 additions & 1 deletion

File tree

src/rules/require-alt-text.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { findOffsets } from "../util.js";
2222
// Helpers
2323
//-----------------------------------------------------------------------------
2424

25-
const imgTagPattern = /<img[^>]*>/giu;
25+
const imgTagPattern = /(?<!<!--[\s\S]*?)<img[^>]*>/giu;
2626

2727
/**
2828
* Creates a regex to match HTML attributes

tests/rules/require-alt-text.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ ruleTester.run("require-alt-text", rule, {
4444
'<img src="image.png" aria-hidden="true"/>',
4545
'<img src="image.png" ARIA-HIDDEN="TRUE" />',
4646
'<p><img src="image.png" alt="Descriptive text" /></p>',
47+
'<!-- <img src="image.png" /> -->',
4748
],
4849
invalid: [
4950
{

0 commit comments

Comments
 (0)