Skip to content

Commit 7ca9787

Browse files
author
Ethan Cohen
committed
Alt must be populated on img-uses-alt.
1 parent 1f42630 commit 7ca9787

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "eslint-plugin-jsx-a11y",
3-
"version": "0.3.0",
3+
"version": "0.3.1",
44
"description": "A static analysis linter of jsx and their accessibility with screen readers.",
55
"keywords": [
66
"eslint",

src/rules/img-uses-alt.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ module.exports = context => ({
2222

2323
const hasAltProp = hasAttribute(node.attributes, 'alt');
2424

25-
if (hasAltProp === false) {
25+
// alt must have a value.
26+
if (hasAltProp === false || hasAltProp === null) {
2627
context.report({
2728
node,
2829
message: errorMessage

tests/src/rules/img-uses-alt.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ ruleTester.run('img-uses-alt', rule, {
4848
],
4949
invalid: [
5050
{ code: '<img />;', errors: [ expectedError ], parserOptions },
51+
{ code: '<img alt />;', errors: [ expectedError ], parserOptions },
5152
{ code: '<img alt={undefined} />;', errors: [ expectedError ], parserOptions },
5253
{ code: '<img alt={`${undefined}`} />;', errors: [ expectedError ], parserOptions },
5354
{ code: '<img alt="" />;', errors: [ expectedError ], parserOptions },

0 commit comments

Comments
 (0)