erblint-github 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -0
- data/lib/erblint-github/linters/custom_helpers.rb +11 -0
- data/lib/erblint-github/linters/github/accessibility/nested_interactive_elements_counter.rb +0 -1
- data/lib/erblint-github/linters/github/accessibility/no_aria_hidden_on_focusable_counter.rb +41 -0
- metadata +18 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4866db453698b16cc11db6797374c4e60a125aa020fabe51966928d19e0578c0
|
4
|
+
data.tar.gz: ba36e29a32956fe98e545059f803b3113404f206015f963b1215452241f43427
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7becf4d23e09a131db0d379a3b28c47ad548034eb4e387a38ae6fb1f1d47ab6dba33173a0b5dfd39bfc6c999ffe02ea1f8278b42ae5ea82ec6c503bcaf0ffbd
|
7
|
+
data.tar.gz: 98ce947b2b9a76cbe3310b6a4187bce8cadad184f33044aee0761bd4d55f5bb82d8329fe683e26549f2c2144aedfeaa2ebcb39f32a7e20b13d5be044ce92da4f
|
data/README.md
CHANGED
@@ -39,6 +39,8 @@ linters:
|
|
39
39
|
enabled: true
|
40
40
|
GitHub::Accessibility::NestedInteractiveElementsCounter:
|
41
41
|
enabled: true
|
42
|
+
GitHub::Accessibility::NoAriaHiddenOnFocusableCounter:
|
43
|
+
enabled: true
|
42
44
|
GitHub::Accessibility::NoAriaLabelMisuseCounter:
|
43
45
|
enabled: true
|
44
46
|
GitHub::Accessibility::NoPositiveTabIndexCounter:
|
@@ -61,6 +63,7 @@ linters:
|
|
61
63
|
- [GitHub::Accessibility::NestedInteractiveElementsCounter](./docs/rules/accessibility/nested-interactive-elements-counter.md)
|
62
64
|
- [GitHub::Accessibility::IframeHasTitleCounter](./docs/rules/accessibility/iframe-has-title-counter.md)
|
63
65
|
- [GitHub::Accessibility::ImageHasAltCounter](./docs/rules/accessibility/image-has-alt-counter.md)
|
66
|
+
- [GitHub::Accessibility::NoAriaHiddenOnFocusableCounter](./docs/rules/accessibility/no-aria-hidden-on-focusable-counter.md)
|
64
67
|
- [GitHub::Accessibility::NoAriaLabelMisuseCounter](./docs/rules/accessibility/no-aria-label-misuse-counter.md)
|
65
68
|
- [GitHub::Accessibility::NoPositiveTabIndexCounter](./docs/rules/accessibility/no-positive-tab-index-counter.md)
|
66
69
|
- [GitHub::Accessibility::NoRedundantImageAltCounter](./docs/rules/accessibility/no-redundant-image-alt-counter.md)
|
@@ -6,6 +6,8 @@ require "openssl"
|
|
6
6
|
module ERBLint
|
7
7
|
module Linters
|
8
8
|
module CustomHelpers
|
9
|
+
INTERACTIVE_ELEMENTS = %w[button summary input select textarea a].freeze
|
10
|
+
|
9
11
|
def rule_disabled?(processed_source)
|
10
12
|
processed_source.parser.ast.descendants(:erb).each do |node|
|
11
13
|
indicator_node, _, code_node, = *node
|
@@ -89,6 +91,15 @@ module ERBLint
|
|
89
91
|
def simple_class_name
|
90
92
|
self.class.name.gsub("ERBLint::Linters::", "")
|
91
93
|
end
|
94
|
+
|
95
|
+
def focusable?(tag)
|
96
|
+
tabindex = possible_attribute_values(tag, "tabindex")
|
97
|
+
if INTERACTIVE_ELEMENTS.include?(tag.name)
|
98
|
+
tabindex.empty? || tabindex.first.to_i >= 0
|
99
|
+
else
|
100
|
+
tabindex.any? && tabindex.first.to_i >= 0
|
101
|
+
end
|
102
|
+
end
|
92
103
|
end
|
93
104
|
end
|
94
105
|
end
|
@@ -10,7 +10,6 @@ module ERBLint
|
|
10
10
|
include ERBLint::Linters::CustomHelpers
|
11
11
|
include LinterRegistry
|
12
12
|
|
13
|
-
INTERACTIVE_ELEMENTS = %w[button summary input select textarea a].freeze
|
14
13
|
MESSAGE = "Nesting interactive elements produces invalid HTML, and ssistive technologies, such as screen readers, might ignore or respond unexpectedly to such nested controls."
|
15
14
|
|
16
15
|
def run(processed_source)
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../../custom_helpers"
|
4
|
+
|
5
|
+
module ERBLint
|
6
|
+
module Linters
|
7
|
+
module GitHub
|
8
|
+
module Accessibility
|
9
|
+
class NoAriaHiddenOnFocusableCounter < Linter
|
10
|
+
include ERBLint::Linters::CustomHelpers
|
11
|
+
include LinterRegistry
|
12
|
+
|
13
|
+
MESSAGE = "Elements that are focusable should not have `aria-hidden='true' because it will cause confusion for assistive technology users."
|
14
|
+
|
15
|
+
def run(processed_source)
|
16
|
+
tags(processed_source).each do |tag|
|
17
|
+
aria_hidden = possible_attribute_values(tag, "aria-hidden")
|
18
|
+
generate_offense(self.class, processed_source, tag) if aria_hidden.include?("true") && focusable?(tag)
|
19
|
+
end
|
20
|
+
|
21
|
+
counter_correct?(processed_source)
|
22
|
+
end
|
23
|
+
|
24
|
+
def autocorrect(processed_source, offense)
|
25
|
+
return unless offense.context
|
26
|
+
|
27
|
+
lambda do |corrector|
|
28
|
+
if processed_source.file_content.include?("erblint:counter #{simple_class_name}")
|
29
|
+
# update the counter if exists
|
30
|
+
corrector.replace(offense.source_range, offense.context)
|
31
|
+
else
|
32
|
+
# add comment with counter if none
|
33
|
+
corrector.insert_before(processed_source.source_buffer.source_range, "#{offense.context}\n")
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: erblint-github
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GitHub Open Source
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-02-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: erb_lint
|
@@ -16,42 +16,42 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.3.0
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 0.3.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: minitest
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 5.17.0
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 5.17.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: mocha
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 2.0.2
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 2.0.2
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,28 +72,28 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - '='
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 1.
|
75
|
+
version: 1.44.1
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - '='
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 1.
|
82
|
+
version: 1.44.1
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rubocop-github
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 0.
|
89
|
+
version: 0.20.0
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 0.
|
96
|
+
version: 0.20.0
|
97
97
|
description: Template style checking for GitHub Ruby repositories
|
98
98
|
email:
|
99
99
|
- opensource+erblint-github@github.com
|
@@ -113,6 +113,7 @@ files:
|
|
113
113
|
- lib/erblint-github/linters/github/accessibility/landmark_has_label_counter.rb
|
114
114
|
- lib/erblint-github/linters/github/accessibility/link_has_href_counter.rb
|
115
115
|
- lib/erblint-github/linters/github/accessibility/nested_interactive_elements_counter.rb
|
116
|
+
- lib/erblint-github/linters/github/accessibility/no_aria_hidden_on_focusable_counter.rb
|
116
117
|
- lib/erblint-github/linters/github/accessibility/no_aria_label_misuse_counter.rb
|
117
118
|
- lib/erblint-github/linters/github/accessibility/no_positive_tab_index_counter.rb
|
118
119
|
- lib/erblint-github/linters/github/accessibility/no_redundant_image_alt_counter.rb
|
@@ -125,7 +126,7 @@ licenses:
|
|
125
126
|
- MIT
|
126
127
|
metadata:
|
127
128
|
rubygems_mfa_required: 'true'
|
128
|
-
post_install_message:
|
129
|
+
post_install_message:
|
129
130
|
rdoc_options: []
|
130
131
|
require_paths:
|
131
132
|
- lib
|
@@ -133,15 +134,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
133
134
|
requirements:
|
134
135
|
- - ">="
|
135
136
|
- !ruby/object:Gem::Version
|
136
|
-
version: 2.
|
137
|
+
version: 2.7.0
|
137
138
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
138
139
|
requirements:
|
139
140
|
- - ">="
|
140
141
|
- !ruby/object:Gem::Version
|
141
142
|
version: '0'
|
142
143
|
requirements: []
|
143
|
-
rubygems_version: 3.
|
144
|
-
signing_key:
|
144
|
+
rubygems_version: 3.2.15
|
145
|
+
signing_key:
|
145
146
|
specification_version: 4
|
146
147
|
summary: erblint GitHub
|
147
148
|
test_files: []
|