Skip to content

Commit 866cb92

Browse files
Dieter Luypaertbeefancohen
authored andcommitted
redundant-alt only with word boundary (#165)
1 parent 2ceb034 commit 866cb92

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

__tests__/src/rules/img-redundant-alt-test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ ruleTester.run('img-redundant-alt', rule, {
5757
{ code: '<UX.Layout>test</UX.Layout>' },
5858
{ code: '<img alt={imageAlt} />' },
5959
{ code: '<img alt />' },
60+
{ code: '<img alt="Photography" />;' },
61+
{ code: '<img alt="ImageMagick" />;' },
6062
].map(parserOptionsMapper),
6163
invalid: [
6264
{ code: '<img alt="Photo of friend." />;', errors: [expectedError] },

src/rules/img-redundant-alt.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ module.exports = {
6060

6161
if (typeof value === 'string' && isVisible) {
6262
const hasRedundancy = redundantWords
63-
.some(word => Boolean(value.match(new RegExp(`(?!{)${word}(?!})`, 'gi'))));
63+
.some(word => Boolean(value.match(new RegExp(`(?!{)\\b${word}\\b(?!})`, 'i'))));
6464

6565
if (hasRedundancy === true) {
6666
context.report({

0 commit comments

Comments
 (0)