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

Appearance settings

Commit b344b1a

Browse filesBrowse files
authored
Update regex logic for flagging alt text (#38)
1 parent 22916a1 commit b344b1a
Copy full SHA for b344b1a

File tree

Expand file treeCollapse file tree

2 files changed

+8
-4
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+8
-4
lines changed

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

Copy file name to clipboardExpand all lines: src/rules/no-default-alt-text.js
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
// Regex to match alt text that is the same as the default image filename
22
// e.g. "Screen Shot 2020-10-20 at 2 52 27 PM"
33
// e.g. "Screenshot 2020-10-20 at 2 52 27 PM"
4+
// e.g. "Clean Shot 2020-10-20 @45x"
5+
// e.g. "image"
46
const defaultMacOsScreenshotMarkdownRegex =
5-
/^Screen ?[S|s]hot \d{4}-\d{2}-\d{2} at \d \d{2} \d{2} [A|P]M$/gi;
7+
/^(Screen|Clean) ?[S|s]hot \d{4}-\d{2}-\d{2}/gi;
68
const imageMarkdownRegex = /^image$/i;
79

810
const defaultMacOsScreenshotHtmlRegex =
9-
/alt="Screen ?[S|s]hot \d{4}-\d{2}-\d{2} at \d \d{2} \d{2} [A|P]M"/gi;
11+
/alt="(Screen|Clean) ?[S|s]hot \d{4}-\d{2}-\d{2}/gi;
1012
const imageHtmlRegex = /alt="image"/i;
1113

1214
module.exports = {

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

Copy file name to clipboardExpand all lines: test/no-default-alt-text.test.js
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ describe("GH001: No Default Alt Text", () => {
3333
"![ScreenShot 2022-06-26 at 7 41 30 PM](https://user-images.githubusercontent.com/abcdef.png)",
3434
"![Screen shot 2022-06-26 at 7 41 30 PM](https://user-images.githubusercontent.com/abcdef.png)",
3535
"![Screenshot 2022-06-26 at 7 41 30 PM](https://user-images.githubusercontent.com/abcdef.png)",
36+
"![Clean Shot 2022-06-26 at 7 41 30 PM](https://user-images.githubusercontent.com/abcdef.png)",
3637
"![image](https://user-images.githubusercontent.com/abcdef.png)",
3738
"![Image](https://user-images.githubusercontent.com/abcdef.png)",
3839
];
@@ -44,7 +45,7 @@ describe("GH001: No Default Alt Text", () => {
4445
.flat()
4546
.filter((name) => !name.includes("GH"));
4647

47-
expect(failedRules).toHaveLength(6);
48+
expect(failedRules).toHaveLength(7);
4849
for (const rule of failedRules) {
4950
expect(rule).toBe("no-default-alt-text");
5051
}
@@ -56,6 +57,7 @@ describe("GH001: No Default Alt Text", () => {
5657
'<img alt="ScreenShot 2022-06-26 at 7 41 30 PM" src="https://user-images.githubusercontent.com/abcdef.png">',
5758
'<img alt="Screen shot 2022-06-26 at 7 41 30 PM" src="https://user-images.githubusercontent.com/abcdef.png">',
5859
'<img alt="Screenshot 2022-06-26 at 7 41 30 PM" src="https://user-images.githubusercontent.com/abcdef.png">',
60+
'<img alt="Clean Shot 2022-06-26 at 7 41 30 PM" src="https://user-images.githubusercontent.com/abcdef.png">',
5961
'<img alt="Image" src="https://user-images.githubusercontent.com/abcdef.png">',
6062
'<img alt="image" src="https://user-images.githubusercontent.com/abcdef.png">',
6163
];
@@ -67,7 +69,7 @@ describe("GH001: No Default Alt Text", () => {
6769
.flat()
6870
.filter((name) => !name.includes("GH"));
6971

70-
expect(failedRules).toHaveLength(6);
72+
expect(failedRules).toHaveLength(7);
7173
for (const rule of failedRules) {
7274
expect(rule).toBe("no-default-alt-text");
7375
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.