erblint-github 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 46d00ab6d8c5bc82e5ea9e42c316037af0509e6f16a107cfd7762c21bac5c762
|
4
|
+
data.tar.gz: 87f2785cf56cd632f122eb9ddb2e369298902737e281ca75de514fffa45de514
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: efd49409b7c581f29c45bcc884279bfcff48baefa63ec7e53e028980589b33a87fa655e20a39bb919167cb078e27a6e07ab3c7f4323eec7b02f6d258e1a7f489
|
7
|
+
data.tar.gz: 24a5f6882e6795950545a47fb87c6e8950fc588976ffaa2c7135f9b363a642743f45ebc2e37ff9748360292249b5e36003c89dc8ec3adc6c77499ea12bc9336e
|
data/README.md
CHANGED
@@ -23,6 +23,8 @@ require "erblint-github/linters"
|
|
23
23
|
```yaml
|
24
24
|
---
|
25
25
|
linters:
|
26
|
+
GitHub::Accessibility::AvoidBothDisabledAndAriaDisabled:
|
27
|
+
enabled: true
|
26
28
|
GitHub::Accessibility::ImageHasAlt:
|
27
29
|
enabled: true
|
28
30
|
GitHub::Accessibility::NoAriaLabelMisuse:
|
@@ -31,10 +33,11 @@ linters:
|
|
31
33
|
enabled: true
|
32
34
|
```
|
33
35
|
|
34
|
-
|
36
|
+
## Rules
|
35
37
|
|
36
|
-
- [GitHub::Accessibility::
|
37
|
-
- [GitHub::Accessibility::
|
38
|
+
- [GitHub::Accessibility::AvoidBothDisabledAndAriaDisabled](./docs/rules/accessibility/avoid-both-disabled-and-aria-disabled.md)
|
39
|
+
- [GitHub::Accessibility::ImageHasAlt](./docs/rules/accessibility/image-has-alt.md)
|
40
|
+
- [GitHub::Accessibility::NoAriaLabelMisuse](./docs/rules/accessibility/no-aria-label-misuse.md)
|
38
41
|
- [GitHub::Accessibility::NoRedundantImageAlt](./docs/rules/accessibility/no-redundant-image-alt.md)
|
39
42
|
|
40
43
|
## Testing
|
@@ -11,7 +11,7 @@ module ERBLint
|
|
11
11
|
indicator_node, _, code_node, = *node
|
12
12
|
indicator = indicator_node&.loc&.source
|
13
13
|
comment = code_node&.loc&.source&.strip
|
14
|
-
rule_name =
|
14
|
+
rule_name = simple_class_name
|
15
15
|
|
16
16
|
if indicator == "#" && comment.start_with?("erblint:disable") && comment.match(rule_name)
|
17
17
|
if @offenses.any?
|
@@ -26,8 +26,8 @@ module ERBLint
|
|
26
26
|
|
27
27
|
def generate_offense(klass, processed_source, tag, message = nil, replacement = nil)
|
28
28
|
message ||= klass::MESSAGE
|
29
|
-
|
30
|
-
offense = ["#{
|
29
|
+
message += "\nLearn more at https://github.com/github/erblint-github#rules.\n"
|
30
|
+
offense = ["#{simple_class_name}:#{message}", tag.node.loc.source].join("\n")
|
31
31
|
add_offense(processed_source.to_source_range(tag.loc), offense, replacement)
|
32
32
|
end
|
33
33
|
|
@@ -45,6 +45,10 @@ module ERBLint
|
|
45
45
|
def tags(processed_source)
|
46
46
|
processed_source.parser.nodes_with_type(:tag).map { |tag_node| BetterHtml::Tree::Tag.from_node(tag_node) }
|
47
47
|
end
|
48
|
+
|
49
|
+
def simple_class_name
|
50
|
+
self.class.name.gsub("ERBLint::Linters::", "")
|
51
|
+
end
|
48
52
|
end
|
49
53
|
end
|
50
54
|
end
|
@@ -0,0 +1,31 @@
|
|
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 AvoidBothDisabledAndAriaDisabled < Linter
|
10
|
+
include ERBLint::Linters::CustomHelpers
|
11
|
+
include LinterRegistry
|
12
|
+
|
13
|
+
ELEMENTS_WITH_NATIVE_DISABLED_ATTRIBUTE_SUPPORT = %w[button fieldset input optgroup option select textarea].freeze
|
14
|
+
MESSAGE = "[aria-disabled] may be used in place of native HTML [disabled] to allow tab-focus on an otherwise ignored element. Setting both attributes is contradictory."
|
15
|
+
|
16
|
+
def run(processed_source)
|
17
|
+
tags(processed_source).each do |tag|
|
18
|
+
next if tag.closing?
|
19
|
+
next unless ELEMENTS_WITH_NATIVE_DISABLED_ATTRIBUTE_SUPPORT.include?(tag.name)
|
20
|
+
next unless tag.attributes["disabled"] && tag.attributes["aria-disabled"]
|
21
|
+
|
22
|
+
generate_offense(self.class, processed_source, tag)
|
23
|
+
end
|
24
|
+
|
25
|
+
rule_disabled?(processed_source)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/tasks/docs.rake
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
namespace :docs do
|
4
|
+
task :coverage do
|
5
|
+
require "erb_lint/all"
|
6
|
+
require "erblint-github/linters"
|
7
|
+
|
8
|
+
Dir[File.join(__dir__, "linters", "github/**/*.rb")].sort.each do |file|
|
9
|
+
rule_documentation_path = file
|
10
|
+
.gsub("#{__dir__}linters/github/", "docs/rules/")
|
11
|
+
.gsub(".rb", ".md")
|
12
|
+
.tr("_", "-")
|
13
|
+
raise "Missing rule documentation. Please document rule in #{rule_documentation_path}" unless File.file?(rule_documentation_path.to_s)
|
14
|
+
end
|
15
|
+
puts "All rules have been properly documented."
|
16
|
+
end
|
17
|
+
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.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GitHub Open Source
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-12-
|
11
|
+
date: 2021-12-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: erb_lint
|
@@ -105,9 +105,11 @@ files:
|
|
105
105
|
- README.md
|
106
106
|
- lib/erblint-github/linters.rb
|
107
107
|
- lib/erblint-github/linters/custom_helpers.rb
|
108
|
+
- lib/erblint-github/linters/github/accessibility/avoid_both_disabled_and_aria_disabled.rb
|
108
109
|
- lib/erblint-github/linters/github/accessibility/image_has_alt.rb
|
109
110
|
- lib/erblint-github/linters/github/accessibility/no_aria_label_misuse.rb
|
110
111
|
- lib/erblint-github/linters/github/accessibility/no_redundant_image_alt.rb
|
112
|
+
- lib/tasks/docs.rake
|
111
113
|
homepage: https://github.com/github/erblint-github
|
112
114
|
licenses:
|
113
115
|
- MIT
|
@@ -127,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
127
129
|
- !ruby/object:Gem::Version
|
128
130
|
version: '0'
|
129
131
|
requirements: []
|
130
|
-
rubygems_version: 3.
|
132
|
+
rubygems_version: 3.2.32
|
131
133
|
signing_key:
|
132
134
|
specification_version: 4
|
133
135
|
summary: erblint GitHub
|