Skip to content

Commit 6e1aa6d

Browse files
author
Ethan Cohen
committed
Update img-uses-alt doc.
1 parent 7ca9787 commit 6e1aa6d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

docs/rules/img-uses-alt.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,21 @@ Enforce that an `img` element contains the `alt` prop. The alt attribute specifi
44

55
## Rule details
66

7-
This rule takes no arguments. However, note that passing props as spread attribute without alt explicitly defined will cause this rule to fail. Explicitly pass down alt prop for rule to pass.
7+
This rule takes no arguments. However, note that passing props as spread attribute without alt explicitly defined will cause this rule to fail. Explicitly pass down alt prop for rule to pass. Alt must have an actual value to pass.
88

99
### Succeed
1010
```jsx
1111
<img src="foo" alt="Foo eating a sandwich." />
12+
<img src="foo" alt={"Foo eating a sandwich."} />
13+
<img src="foo" alt={altText} />
14+
<img src="foo" alt={`${person} smiling`} />
1215
```
1316

1417
### Fail
1518
```jsx
1619
<img src="foo" />
1720
<img {...props} />
21+
<img {...props} alt /> // Has no value
22+
<img {...props} alt={undefined} /> // Has no value
23+
<img {...props} alt={`${undefined}`} /> // Has no value
1824
```

0 commit comments

Comments
 (0)