Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9ba0286

Browse files
authored
Chore: cleanup redundant alt attribute check (#101)
* chore: Remove check for no alt attribute* Remove code comment* Update test
1 parentadd9f62 commit9ba0286

File tree

2 files changed

+1
-14
lines changed

2 files changed

+1
-14
lines changed

‎src/rules/no-empty-alt-text.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// TODO: Clean up when https://github.com/DavidAnson/markdownlint/pull/993 is merged
21
module.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
constImageRegex=newRegExp(/<img(.*?)>/,"gid");
22-
consthtmlAltRegex=newRegExp(/alt=['"]/,"gid");
2321
consthtmlEmptyAltRegex=newRegExp(/alt=['"]['"]/,"gid");
2422
for(consttokenofhtmlTagsWithImages){
2523
constlineRange=token.map;
@@ -35,20 +33,13 @@ module.exports = {
3533
constemptyAltMatches=[
3634
...imageTag[0].matchAll(htmlEmptyAltRegex),
3735
][0];
38-
constnoAltMatches=[...imageTag[0].matchAll(htmlAltRegex)];
39-
4036
if(emptyAltMatches){
4137
constmatchingContent=emptyAltMatches[0];
4238
conststartIndex=emptyAltMatches.indices[0][0];
4339
onError({
4440
lineNumber:lineNumber+i,
4541
range:[imageTagIndex+startIndex+1,matchingContent.length],
4642
});
47-
}elseif(noAltMatches.length===0){
48-
onError({
49-
lineNumber:lineNumber+i,
50-
range:[imageTagIndex+1,imageTag[0].length],
51-
});
5243
}
5344
}
5445
}

‎test/no-empty-alt-text.test.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,15 @@ describe("GH003: No Empty Alt Text", () => {
1919
'<img alt="" src="https://user-images.githubusercontent.com/abcdef.png">',
2020
"<img alt='' src='https://user-images.githubusercontent.com/abcdef.png'>",
2121
'<img src="cat.png" alt="" /> <img src="dog.png" alt="" />',
22-
'<img src="dog.png" />',
23-
'<img alt src="dog.png" />',
24-
"<img alt><img alt>",
2522
];
2623

2724
constresults=awaitrunTest(strings,noEmptyStringAltRule);
28-
2925
constfailedRules=results
3026
.map((result)=>result.ruleNames)
3127
.flat()
3228
.filter((name)=>!name.includes("GH"));
3329

34-
expect(failedRules).toHaveLength(8);
30+
expect(failedRules).toHaveLength(4);
3531
for(construleoffailedRules){
3632
expect(rule).toBe("no-empty-alt-text");
3733
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp