Skip to content

Commit 18247e8

Browse files
authored
Set detail not details (#11)
* Set not * Add test
1 parent e02d52a commit 18247e8

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

.eslintrc.js

+1
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ module.exports = {
1313
rules: {
1414
"import/no-commonjs": "off",
1515
"filenames/match-regex": "off",
16+
"i18n-text/no-en": "off",
1617
},
1718
};

no-default-alt-text.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ module.exports = {
2323
if (image.content.match(altTextRegex)) {
2424
onError({
2525
lineNumber: image.lineNumber,
26-
details: `For image: ${image.content}`,
26+
detail: `For image: ${image.content}`,
2727
});
2828
}
2929
}
@@ -35,7 +35,7 @@ module.exports = {
3535
if (line.match(altTextTagRegex)) {
3636
onError({
3737
lineNumber,
38-
details: `For image: ${line}`,
38+
detail: `For image: ${line}`,
3939
});
4040
}
4141
lineNumber++;

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

+23
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ describe("GH001: No Default Alt Text", () => {
7575
expect(rule).toBe(thisRuleName);
7676
}
7777
});
78+
7879
test("HTML example", async () => {
7980
const strings = [
8081
'<img alt="Screen Shot 2022-06-26 at 7 41 30 PM" src="https://user-images.githubusercontent.com/abcdef.png">',
@@ -95,5 +96,27 @@ describe("GH001: No Default Alt Text", () => {
9596
expect(rule).toBe(thisRuleName);
9697
}
9798
});
99+
100+
test("error message", async () => {
101+
const strings = [
102+
"![Screen Shot 2022-06-26 at 7 41 30 PM](https://user-images.githubusercontent.com/abcdef.png)",
103+
'<img alt="Screen Shot 2022-06-26 at 7 41 30 PM" src="https://user-images.githubusercontent.com/abcdef.png">',
104+
];
105+
106+
const results = await runTest(strings);
107+
108+
expect(results[0].ruleDescription).toMatch(
109+
/Images should not use the MacOS default screenshot filename as alternate text/
110+
);
111+
expect(results[0].errorDetail).toBe(
112+
"For image: Screen Shot 2022-06-26 at 7 41 30 PM"
113+
);
114+
expect(results[1].ruleDescription).toMatch(
115+
/Images should not use the MacOS default screenshot filename as alternate text/
116+
);
117+
expect(results[1].errorDetail).toBe(
118+
'For image: <img alt="Screen Shot 2022-06-26 at 7 41 30 PM" src="https://user-images.githubusercontent.com/abcdef.png">'
119+
);
120+
});
98121
});
99122
});

0 commit comments

Comments
 (0)