Skip to content

Commit a95a56f

Browse files
committed
Rename rule and deprecate old one
1 parent 5295b93 commit a95a56f

File tree

5 files changed

+35
-42
lines changed

5 files changed

+35
-42
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ linters:
3333
enabled: true
3434
GitHub::Accessibility::ImageHasAlt:
3535
enabled: true
36-
GitHub::Accessibility::LandmarkHasLabel:
36+
GitHub::Accessibility::NavigationHasLabel:
3737
enabled: true
3838
GitHub::Accessibility::LinkHasHref:
3939
enabled: true
@@ -58,7 +58,7 @@ linters:
5858
- [GitHub::Accessibility::AvoidBothDisabledAndAriaDisabled](./docs/rules/accessibility/avoid-both-disabled-and-aria-disabled.md)
5959
- [GitHub::Accessibility::AvoidGenericLinkText](./docs/rules/accessibility/avoid-generic-link-text.md)
6060
- [GitHub::Accessibility::DisabledAttribute](./docs/rules/accessibility/disabled-attribute.md)
61-
- [GitHub::Accessibility::LandmarkHasLabel](./docs/rules/accessibility/landmark-has-label.md)
61+
- [GitHub::Accessibility::NavigationHasLabel](./docs/rules/accessibility/navigation-has-label.md)
6262
- [GitHub::Accessibility::LinkHasHref](./docs/rules/accessibility/link-has-href.md)
6363
- [GitHub::Accessibility::NestedInteractiveElements](./docs/rules/accessibility/nested-interactive-elements.md)
6464
- [GitHub::Accessibility::IframeHasTitle](./docs/rules/accessibility/iframe-has-title.md)

docs/rules/accessibility/landmark-has-label.md

Lines changed: 0 additions & 28 deletions
This file was deleted.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Navigation Has Label
2+
3+
## Rule Details
4+
5+
This rule enforces that a navigation landmark (a `<nav>` or a `role="navigation"`) has an accessible name. This rule is helpful to enforce for sites (like GitHub) where multiple navigation is common.
6+
7+
The navigation landmark element should have an `aria-label` attribute, or `aria-labelledby` to distinguish it from other elements.
8+
9+
## Resources
10+
11+
- [ARIA Landmarks Example](https://www.w3.org/WAI/ARIA/apg/example-index/landmarks/index.html)
12+
13+
## Examples
14+
### **Incorrect** code for this rule 👎
15+
16+
```erb
17+
<!-- incorrect -->
18+
<nav>
19+
<h1>This is a text</h1>
20+
</nav>
21+
```
22+
23+
### **Correct** code for this rule 👍
24+
25+
```erb
26+
<!-- correct -->
27+
<nav aria-labelledby="title_id"t>
28+
<h1 id="title_id">This is a text</h1>
29+
</nav>
30+
```

lib/erblint-github/linters/github/accessibility/landmark_has_label.rb renamed to lib/erblint-github/linters/github/accessibility/navigation_has_label.rb

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,12 @@ module ERBLint
66
module Linters
77
module GitHub
88
module Accessibility
9-
class LandmarkHasLabel < Linter
9+
class NavigationHasLabel < Linter
1010
include ERBLint::Linters::CustomHelpers
1111
include LinterRegistry
1212

1313
MESSAGE = "The navigation landmark should have a unique accessible name via `aria-label` or `aria-labelledby`."
1414

15-
class ConfigSchema < LinterConfig
16-
property :counter_enabled, accepts: [true, false], default: false, reader: :counter_enabled?
17-
end
18-
self.config_schema = ConfigSchema
19-
2015
def run(processed_source)
2116
tags(processed_source).each do |tag|
2217
next if tag.closing?
@@ -30,10 +25,6 @@ def run(processed_source)
3025
end
3126

3227
end
33-
34-
if @config.counter_enabled?
35-
counter_correct?(processed_source)
36-
end
3728
end
3829
end
3930
end

test/linters/accessibility/landmark_has_label_test.rb renamed to test/linters/accessibility/navigation_has_label_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
require "test_helper"
44

5-
class LandmarkHasLabelTest < LinterTestCase
5+
class NavigationHasLabelTest < LinterTestCase
66
def linter_class
7-
ERBLint::Linters::GitHub::Accessibility::LandmarkHasLabel
7+
ERBLint::Linters::GitHub::Accessibility::NavigationHasLabel
88
end
99

1010
def test_warns_if_navigation_landmark_has_no_label

0 commit comments

Comments
 (0)