Skip to content

Commit 558ee6f

Browse files
committed
Allow exceptions and document it
1 parent ed7a718 commit 558ee6f

File tree

2 files changed

+48
-2
lines changed

2 files changed

+48
-2
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# aria-label is well formatted
2+
3+
## Rule Details
4+
5+
`[aria-label]` content should be formatted in the same way you would visual text. Please use sentence case.
6+
7+
Do not connect the words like you would an ID. An `aria-label` is different from `aria-labelledby`.
8+
An `aria-label` is not an ID, and should be formatted as human-friendly text.
9+
10+
## Config
11+
12+
If you determine that there are valid scenarios for `aria-label` to start with downcase, you may except it in your `.erb-lint.yml` config like so:
13+
14+
```yml
15+
GitHub::Accessibility::AriaLabelIsWellFormatted:
16+
enabled: true
17+
exceptions:
18+
- allowed for some reason
19+
- also allowed for some reason
20+
```
21+
22+
## Examples
23+
24+
### **Incorrect** code for this rule 👎
25+
26+
```erb
27+
<button aria-label="close">
28+
```
29+
30+
```erb
31+
<button aria-label="submit">
32+
```
33+
34+
```erb
35+
<button aria-label="button-1">
36+
```
37+
38+
### **Correct** code for this rule 👍
39+
40+
```erb
41+
<button aria-label="Submit">
42+
````
43+
44+
```erb
45+
<button aria-label="Close">
46+
````

test/linters/accessibility/aria_label_is_well_formatted_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ def test_does_not_warn_when_aria_label_is_excepted_in_config
5252
def test_does_not_warn_if_aria_label_is_in_excepted_list
5353
@file = <<~HTML
5454
<button aria-label="hello" ></button>
55-
55+
<button aria-label="hello world" ></button>
5656
HTML
5757
@linter.config.exceptions = ["hello"]
5858
@linter.run(processed_source)
5959

60-
assert_empty @linter.offenses
60+
assert_equal 1, @linter.offenses.count
6161
end
6262
end

0 commit comments

Comments
 (0)