Skip to content

Commit 6180e11

Browse files
author
Adrián Bolonio
committed
Add documentation, Move to accessibility folder, Add config
1 parent 7040e04 commit 6180e11

File tree

4 files changed

+29
-2
lines changed

4 files changed

+29
-2
lines changed

config/accessibility.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,7 @@ require:
33

44
GitHub/Accessibility/ImageHasAlt:
55
Enabled: true
6-
StyleGuide: https://github.com/github/rubocop-github/blob/master/guides/image-has-alt.md
6+
StyleGuide: https://github.com/github/rubocop-github/blob/master/guides/image-has-alt.md
7+
GitHub/Accessibility/NoRedundantImageAlt:
8+
Enabled: true
9+
StyleGuide: https://github.com/github/rubocop-github/blob/master/guides/no-redundant-image-alt.md

guides/no-redundant-image-alt.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# GitHub/Accessibility/NoRedundantImageAlt
2+
3+
## Rule Details
4+
5+
Alt prop should not contain `image` or `picture` as screen readers already announce the element as an image
6+
7+
## Resources
8+
9+
- [W3C WAI Images Tutorial](https://www.w3.org/WAI/tutorials/images/)
10+
- [Primer: Alternative text for images](https://primer.style/design/accessibility/alternative-text-for-images)
11+
12+
## Examples
13+
### **Incorrect** code for this rule 👎
14+
15+
```erb
16+
<%= image_tag "cat.gif", size: "12x12", alt: "Picture of a cat" %>
17+
```
18+
19+
### **Correct** code for this rule 👍
20+
21+
```erb
22+
<!-- good -->
23+
<%= image_tag "cat.gif", size: "12x12", alt: "A black cat" %>
24+
```

test/test_rails_no_redundant_image_alt.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
require_relative "./cop_test"
44
require "minitest/autorun"
5-
require "rubocop/cop/github/rails_no_redundant_image_alt"
5+
require "rubocop/cop/github/accessibility/no_redundant_image_alt"
66

77
class NoRedundantImageAlt < CopTest
88
def cop_class

0 commit comments

Comments
 (0)