Skip to content

Commit bdc24df

Browse files
committed
[added] "picture" to the list of redundant words in img[alt]
1 parent 9a28109 commit bdc24df

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

lib/__tests__/index-test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,12 @@ describe('tags', () => {
177177
<img src="cat.gif" alt="image of a cat"/>;
178178
});
179179
});
180+
181+
it('dissallows the word "picture" in the alt attribute', () => {
182+
expectWarning(assertions.tags.img.REDUNDANT_ALT.msg, () => {
183+
<img src="cat.gif" alt="picture of a cat"/>;
184+
});
185+
});
180186
});
181187

182188
describe('a', () => {

lib/assertions.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,12 +213,12 @@ exports.tags = {
213213

214214
REDUNDANT_ALT: {
215215
// TODO: have some way to set localization strings to match against
216-
msg: 'Screen-readers already announce `img` tags as an image, you don\'t need to use the word "image" in the description',
216+
msg: 'Screen-readers already announce `img` tags as an image, you don\'t need to use the word "image" or "picture" in the description',
217217
test (tagName, props, children) {
218-
if (isHiddenFromAT(props))
218+
if (isHiddenFromAT(props) || !hasAlt(props))
219219
return true;
220220

221-
return !(hasAlt(props) && props.alt.match('image'));
221+
return !(props.alt.match('image') || props.alt.match('picture'));
222222
}
223223
}
224224
}

0 commit comments

Comments
 (0)