1- // TODO: Clean up when https://github.com/DavidAnson/markdownlint/pull/993 is merged
21module . exports = {
32 names : [ "GH003" , "no-empty-alt-text" ] ,
43 description : "Please provide an alternative text for the image." ,
@@ -19,7 +18,6 @@ module.exports = {
1918 ) ;
2019
2120 const ImageRegex = new RegExp ( / < i m g ( .* ?) > / , "gid" ) ;
22- const htmlAltRegex = new RegExp ( / a l t = [ ' " ] / , "gid" ) ;
2321 const htmlEmptyAltRegex = new RegExp ( / a l t = [ ' " ] [ ' " ] / , "gid" ) ;
2422 for ( const token of htmlTagsWithImages ) {
2523 const lineRange = token . map ;
@@ -35,20 +33,13 @@ module.exports = {
3533 const emptyAltMatches = [
3634 ...imageTag [ 0 ] . matchAll ( htmlEmptyAltRegex ) ,
3735 ] [ 0 ] ;
38- const noAltMatches = [ ...imageTag [ 0 ] . matchAll ( htmlAltRegex ) ] ;
39-
4036 if ( emptyAltMatches ) {
4137 const matchingContent = emptyAltMatches [ 0 ] ;
4238 const startIndex = emptyAltMatches . indices [ 0 ] [ 0 ] ;
4339 onError ( {
4440 lineNumber : lineNumber + i ,
4541 range : [ imageTagIndex + startIndex + 1 , matchingContent . length ] ,
4642 } ) ;
47- } else if ( noAltMatches . length === 0 ) {
48- onError ( {
49- lineNumber : lineNumber + i ,
50- range : [ imageTagIndex + 1 , imageTag [ 0 ] . length ] ,
51- } ) ;
5243 }
5344 }
5445 }
0 commit comments