You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/rules/img-uses-alt.md
+7-1Lines changed: 7 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,15 +4,21 @@ Enforce that an `img` element contains the `alt` prop. The alt attribute specifi
4
4
5
5
## Rule details
6
6
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.
8
8
9
9
### Succeed
10
10
```jsx
11
11
<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`} />
12
15
```
13
16
14
17
### Fail
15
18
```jsx
16
19
<img src="foo"/>
17
20
<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
0 commit comments