diff --git a/.eslintrc.js b/.eslintrc.js index ecf4702..8c91c06 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -13,5 +13,6 @@ module.exports = { rules: { "import/no-commonjs": "off", "filenames/match-regex": "off", + "i18n-text/no-en": "off", }, }; diff --git a/no-default-alt-text.js b/no-default-alt-text.js index 747802c..4e15c32 100644 --- a/no-default-alt-text.js +++ b/no-default-alt-text.js @@ -23,7 +23,7 @@ module.exports = { if (image.content.match(altTextRegex)) { onError({ lineNumber: image.lineNumber, - details: `For image: ${image.content}`, + detail: `For image: ${image.content}`, }); } } @@ -35,7 +35,7 @@ module.exports = { if (line.match(altTextTagRegex)) { onError({ lineNumber, - details: `For image: ${line}`, + detail: `For image: ${line}`, }); } lineNumber++; diff --git a/test/no-default-alt-text.test.js b/test/no-default-alt-text.test.js index 8cffe84..796933e 100644 --- a/test/no-default-alt-text.test.js +++ b/test/no-default-alt-text.test.js @@ -75,6 +75,7 @@ describe("GH001: No Default Alt Text", () => { expect(rule).toBe(thisRuleName); } }); + test("HTML example", async () => { const strings = [ 'Screen Shot 2022-06-26 at 7 41 30 PM', @@ -95,5 +96,27 @@ describe("GH001: No Default Alt Text", () => { expect(rule).toBe(thisRuleName); } }); + + test("error message", async () => { + const strings = [ + "![Screen Shot 2022-06-26 at 7 41 30 PM](https://user-images.githubusercontent.com/abcdef.png)", + 'Screen Shot 2022-06-26 at 7 41 30 PM', + ]; + + const results = await runTest(strings); + + expect(results[0].ruleDescription).toMatch( + /Images should not use the MacOS default screenshot filename as alternate text/ + ); + expect(results[0].errorDetail).toBe( + "For image: Screen Shot 2022-06-26 at 7 41 30 PM" + ); + expect(results[1].ruleDescription).toMatch( + /Images should not use the MacOS default screenshot filename as alternate text/ + ); + expect(results[1].errorDetail).toBe( + 'For image: Screen Shot 2022-06-26 at 7 41 30 PM' + ); + }); }); });