rubocop-rails-accessibility 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +6 -7
- data/config/default.yml +5 -9
- data/guides/image-has-alt.md +2 -2
- data/guides/no-positive-tabindex.md +2 -2
- data/guides/no-redundant-image-alt.md +2 -2
- data/lib/rubocop/cop/{rubocop-rails-accessibility → rails_accessibility}/image_has_alt.rb +1 -1
- data/lib/rubocop/cop/{rubocop-rails-accessibility → rails_accessibility}/no_positive_tabindex.rb +1 -1
- data/lib/rubocop/cop/{rubocop-rails-accessibility → rails_accessibility}/no_redundant_image_alt.rb +1 -1
- data/lib/rubocop/rails_accessibility/inject.rb +20 -0
- data/lib/rubocop/rails_accessibility/version.rb +7 -0
- data/lib/rubocop/rails_accessibility.rb +10 -0
- data/lib/rubocop-rails-accessibility.rb +12 -0
- metadata +11 -17
- data/.rspec +0 -3
- data/.rubocop.yml +0 -9
- data/CODEOWNERS +0 -1
- data/Gemfile +0 -6
- data/Gemfile.lock +0 -108
- data/Rakefile +0 -34
- data/lib/rubocop/cop/inject.rb +0 -18
- data/lib/rubocop/cop/rubocop_rails_accessibility_cops.rb +0 -10
- data/lib/rubocop/cop/version.rb +0 -5
- data/rubocop-rails-accessibility.gemspec +0 -41
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dfefa9c0d0ed3f7de492a5f4db9d7922c23adbf17ffe74772e26ab45c071ac03
|
4
|
+
data.tar.gz: 8e2f7cd26c99130c1feed4b9907134b9c18cd5d087c7c60b3cf16a7a56483997
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4eb47ee8c19bb6eaa3dcecb77f6f23ada53c304470a7dbcf823d620839f085fed9282f6b9c4bff3988a44f303481020ab7fcea6b9b92061597132e650ebd538c
|
7
|
+
data.tar.gz: 6e4b29a3a70ee5fe1531c7e68084c72c799ab58e7e6fe6a49211180e8ca506da38d59971bc143066918f7340fc67ce0f0574ac821892a14ae84242b14767dc1a
|
data/README.md
CHANGED
@@ -25,9 +25,8 @@ You need to tell RuboCop to load RuboCop Rails Accessibility.
|
|
25
25
|
Put this into your `.rubocop.yml`.
|
26
26
|
|
27
27
|
``` yaml
|
28
|
-
|
29
|
-
rubocop-rails-accessibility
|
30
|
-
- config/default.yml
|
28
|
+
require:
|
29
|
+
- rubocop-rails-accessibility
|
31
30
|
```
|
32
31
|
|
33
32
|
## Testing
|
@@ -47,14 +46,14 @@ bundle exec rake
|
|
47
46
|
## The Cops
|
48
47
|
|
49
48
|
All cops are located under
|
50
|
-
[`lib/rubocop/cop/
|
49
|
+
[`lib/rubocop/cop/rails_accessibility`](lib/rubocop/cop/rails_accessibility), and contain
|
51
50
|
examples/documentation.
|
52
51
|
|
53
52
|
## Rules
|
54
53
|
|
55
|
-
- [
|
56
|
-
- [
|
57
|
-
- [
|
54
|
+
- [RailsAccessibility/ImageHasAlt](guides/image-has-alt.md)
|
55
|
+
- [RailsAccessibility/NoPositiveTabindex](guides/no-positive-tabindex.md)
|
56
|
+
- [RailsAccessibility/NoRedundantImageAlt](guides/no-redundant-image-alt.md)
|
58
57
|
|
59
58
|
## Contributing
|
60
59
|
|
data/config/default.yml
CHANGED
@@ -1,15 +1,11 @@
|
|
1
|
-
|
2
|
-
- rubocop/cop/rubocop_rails_accessibility_cops
|
3
|
-
|
4
|
-
AllCops:
|
5
|
-
DisabledByDefault: true
|
6
|
-
|
7
|
-
RubocopRailsAccessibility/ImageHasAlt:
|
1
|
+
RailsAccessibility/ImageHasAlt:
|
8
2
|
Enabled: true
|
9
3
|
StyleGuide: https://github.com/github/rubocop-rails-accessibility/blob/master/guides/image-has-alt.md
|
10
|
-
|
4
|
+
|
5
|
+
RailsAccessibility/NoPositiveTabindex:
|
11
6
|
Enabled: true
|
12
7
|
StyleGuide: https://github.com/github/rubocop-rails-accessibility/blob/master/guides/no-positive-tabindex.md
|
13
|
-
|
8
|
+
|
9
|
+
RailsAccessibility/NoRedundantImageAlt:
|
14
10
|
Enabled: true
|
15
11
|
StyleGuide: https://github.com/github/rubocop-rails-accessibility/blob/master/guides/no-redundant-image-alt.md
|
data/guides/image-has-alt.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# RailsAccessibility/ImageHasAlt
|
2
2
|
|
3
3
|
## Rule Details
|
4
4
|
|
@@ -26,4 +26,4 @@ Images should have an alt prop with meaningful text or an empty string for decor
|
|
26
26
|
```erb
|
27
27
|
<!-- also good -->
|
28
28
|
<%= image_tag "spinners/octocat-spinner-16px.gif", size: "12x12", alt: "" %>
|
29
|
-
```
|
29
|
+
```
|
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# RailsAccessibility/NoPositiveTabindex
|
2
2
|
|
3
3
|
## Rule Details
|
4
4
|
|
@@ -21,4 +21,4 @@ Positive tabindex is error-prone and often inaccessible.
|
|
21
21
|
```erb
|
22
22
|
<!-- good -->
|
23
23
|
<%= button_tag "Continue", :tabindex => -1 %>
|
24
|
-
```
|
24
|
+
```
|
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# RailsAccessibility/NoRedundantImageAlt
|
2
2
|
|
3
3
|
## Rule Details
|
4
4
|
|
@@ -21,4 +21,4 @@ Alt prop should not contain `image` or `picture` as screen readers already annou
|
|
21
21
|
```erb
|
22
22
|
<!-- good -->
|
23
23
|
<%= image_tag "cat.gif", size: "12x12", alt: "A black cat" %>
|
24
|
-
```
|
24
|
+
```
|
data/lib/rubocop/cop/{rubocop-rails-accessibility → rails_accessibility}/no_redundant_image_alt.rb
RENAMED
@@ -4,7 +4,7 @@ require "rubocop"
|
|
4
4
|
|
5
5
|
module RuboCop
|
6
6
|
module Cop
|
7
|
-
module
|
7
|
+
module RailsAccessibility
|
8
8
|
class NoRedundantImageAlt < Base
|
9
9
|
MSG = "Alt prop should not contain `image` or `picture` as screen readers already announce the element as an image"
|
10
10
|
REDUNDANT_ALT_WORDS = %w[image picture].freeze
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rubocop"
|
4
|
+
|
5
|
+
# The original code is from https://github.com/rubocop/rubocop-rspec/blob/main/lib/rubocop/rspec/inject.rb
|
6
|
+
# See https://github.com/rubocop/rubocop-rspec/blob/main/MIT-LICENSE.md
|
7
|
+
module RuboCop
|
8
|
+
module RailsAccessibility
|
9
|
+
module Inject
|
10
|
+
def self.defaults!
|
11
|
+
path = CONFIG_DEFAULT.to_s
|
12
|
+
hash = ::RuboCop::ConfigLoader.send(:load_yaml_configuration, path)
|
13
|
+
config = ::RuboCop::Config.new(hash, path).tap(&:make_excludes_absolute)
|
14
|
+
puts "configuration from #{path}" if ::RuboCop::ConfigLoader.debug?
|
15
|
+
config = ::RuboCop::ConfigLoader.merge_with_default(config, path)
|
16
|
+
::RuboCop::ConfigLoader.instance_variable_set(:@default_configuration, config)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rubocop"
|
4
|
+
require "rubocop/rails_accessibility"
|
5
|
+
require "rubocop/rails_accessibility/inject"
|
6
|
+
require "rubocop/rails_accessibility/version"
|
7
|
+
|
8
|
+
RuboCop::RailsAccessibility::Inject.defaults!
|
9
|
+
|
10
|
+
require "rubocop/cop/rails_accessibility/image_has_alt"
|
11
|
+
require "rubocop/cop/rails_accessibility/no_positive_tabindex"
|
12
|
+
require "rubocop/cop/rails_accessibility/no_redundant_image_alt"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop-rails-accessibility
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GitHub Accessibility Team
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-10-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
@@ -129,26 +129,20 @@ executables: []
|
|
129
129
|
extensions: []
|
130
130
|
extra_rdoc_files: []
|
131
131
|
files:
|
132
|
-
- ".rspec"
|
133
|
-
- ".rubocop.yml"
|
134
|
-
- CODEOWNERS
|
135
132
|
- CONTRIBUTING.md
|
136
|
-
- Gemfile
|
137
|
-
- Gemfile.lock
|
138
133
|
- LICENSE
|
139
134
|
- README.md
|
140
|
-
- Rakefile
|
141
135
|
- config/default.yml
|
142
136
|
- guides/image-has-alt.md
|
143
137
|
- guides/no-positive-tabindex.md
|
144
138
|
- guides/no-redundant-image-alt.md
|
145
|
-
- lib/rubocop
|
146
|
-
- lib/rubocop/cop/
|
147
|
-
- lib/rubocop/cop/
|
148
|
-
- lib/rubocop/cop/
|
149
|
-
- lib/rubocop/
|
150
|
-
- lib/rubocop/
|
151
|
-
- rubocop
|
139
|
+
- lib/rubocop-rails-accessibility.rb
|
140
|
+
- lib/rubocop/cop/rails_accessibility/image_has_alt.rb
|
141
|
+
- lib/rubocop/cop/rails_accessibility/no_positive_tabindex.rb
|
142
|
+
- lib/rubocop/cop/rails_accessibility/no_redundant_image_alt.rb
|
143
|
+
- lib/rubocop/rails_accessibility.rb
|
144
|
+
- lib/rubocop/rails_accessibility/inject.rb
|
145
|
+
- lib/rubocop/rails_accessibility/version.rb
|
152
146
|
homepage: https://github.com/github/rubocop-rails-accessibility
|
153
147
|
licenses:
|
154
148
|
- MIT
|
@@ -175,5 +169,5 @@ requirements: []
|
|
175
169
|
rubygems_version: 3.3.10
|
176
170
|
signing_key:
|
177
171
|
specification_version: 4
|
178
|
-
summary: Custom
|
172
|
+
summary: Custom RuboCop rules for Rails Accessibility.
|
179
173
|
test_files: []
|
data/.rspec
DELETED
data/.rubocop.yml
DELETED
data/CODEOWNERS
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
* @github/accessibility-reviewers
|
data/Gemfile
DELETED
data/Gemfile.lock
DELETED
@@ -1,108 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
rubocop-rails-accessibility (0.1.2)
|
5
|
-
rubocop (>= 1.0.0)
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: https://rubygems.org/
|
9
|
-
specs:
|
10
|
-
actionview (7.0.3.1)
|
11
|
-
activesupport (= 7.0.3.1)
|
12
|
-
builder (~> 3.1)
|
13
|
-
erubi (~> 1.4)
|
14
|
-
rails-dom-testing (~> 2.0)
|
15
|
-
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
16
|
-
activesupport (7.0.3.1)
|
17
|
-
concurrent-ruby (~> 1.0, >= 1.0.2)
|
18
|
-
i18n (>= 1.6, < 2)
|
19
|
-
minitest (>= 5.1)
|
20
|
-
tzinfo (~> 2.0)
|
21
|
-
ast (2.4.2)
|
22
|
-
builder (3.2.4)
|
23
|
-
concurrent-ruby (1.1.10)
|
24
|
-
crass (1.0.6)
|
25
|
-
diff-lcs (1.5.0)
|
26
|
-
erubi (1.11.0)
|
27
|
-
i18n (1.12.0)
|
28
|
-
concurrent-ruby (~> 1.0)
|
29
|
-
json (2.6.2)
|
30
|
-
loofah (2.18.0)
|
31
|
-
crass (~> 1.0.2)
|
32
|
-
nokogiri (>= 1.5.9)
|
33
|
-
minitest (5.16.3)
|
34
|
-
nokogiri (1.13.8-x86_64-darwin)
|
35
|
-
racc (~> 1.4)
|
36
|
-
nokogiri (1.13.8-x86_64-linux)
|
37
|
-
racc (~> 1.4)
|
38
|
-
parallel (1.22.1)
|
39
|
-
parser (3.1.2.0)
|
40
|
-
ast (~> 2.4.1)
|
41
|
-
racc (1.6.0)
|
42
|
-
rack (2.2.4)
|
43
|
-
rails-dom-testing (2.0.3)
|
44
|
-
activesupport (>= 4.2.0)
|
45
|
-
nokogiri (>= 1.6)
|
46
|
-
rails-html-sanitizer (1.4.3)
|
47
|
-
loofah (~> 2.3)
|
48
|
-
rainbow (3.1.1)
|
49
|
-
rake (13.0.6)
|
50
|
-
regexp_parser (2.5.0)
|
51
|
-
rexml (3.2.5)
|
52
|
-
rspec (3.11.0)
|
53
|
-
rspec-core (~> 3.11.0)
|
54
|
-
rspec-expectations (~> 3.11.0)
|
55
|
-
rspec-mocks (~> 3.11.0)
|
56
|
-
rspec-core (3.11.0)
|
57
|
-
rspec-support (~> 3.11.0)
|
58
|
-
rspec-expectations (3.11.0)
|
59
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
60
|
-
rspec-support (~> 3.11.0)
|
61
|
-
rspec-mocks (3.11.1)
|
62
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
63
|
-
rspec-support (~> 3.11.0)
|
64
|
-
rspec-support (3.11.0)
|
65
|
-
rubocop (1.31.2)
|
66
|
-
json (~> 2.3)
|
67
|
-
parallel (~> 1.10)
|
68
|
-
parser (>= 3.1.0.0)
|
69
|
-
rainbow (>= 2.2.2, < 4.0)
|
70
|
-
regexp_parser (>= 1.8, < 3.0)
|
71
|
-
rexml (>= 3.2.5, < 4.0)
|
72
|
-
rubocop-ast (>= 1.18.0, < 2.0)
|
73
|
-
ruby-progressbar (~> 1.7)
|
74
|
-
unicode-display_width (>= 1.4.0, < 3.0)
|
75
|
-
rubocop-ast (1.19.1)
|
76
|
-
parser (>= 3.1.1.0)
|
77
|
-
rubocop-github (0.18.0)
|
78
|
-
rubocop (>= 1.0.0)
|
79
|
-
rubocop-performance
|
80
|
-
rubocop-rails
|
81
|
-
rubocop-performance (1.14.3)
|
82
|
-
rubocop (>= 1.7.0, < 2.0)
|
83
|
-
rubocop-ast (>= 0.4.0)
|
84
|
-
rubocop-rails (2.15.2)
|
85
|
-
activesupport (>= 4.2.0)
|
86
|
-
rack (>= 1.1)
|
87
|
-
rubocop (>= 1.7.0, < 2.0)
|
88
|
-
ruby-progressbar (1.11.0)
|
89
|
-
tzinfo (2.0.5)
|
90
|
-
concurrent-ruby (~> 1.0)
|
91
|
-
unicode-display_width (2.2.0)
|
92
|
-
|
93
|
-
PLATFORMS
|
94
|
-
x86_64-darwin-19
|
95
|
-
x86_64-linux
|
96
|
-
|
97
|
-
DEPENDENCIES
|
98
|
-
actionview
|
99
|
-
minitest
|
100
|
-
rake (~> 13.0)
|
101
|
-
rspec (~> 3.0)
|
102
|
-
rubocop-github
|
103
|
-
rubocop-performance
|
104
|
-
rubocop-rails
|
105
|
-
rubocop-rails-accessibility!
|
106
|
-
|
107
|
-
BUNDLED WITH
|
108
|
-
2.3.17
|
data/Rakefile
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "bundler/gem_tasks"
|
4
|
-
require "rake/testtask"
|
5
|
-
require "rspec/core/rake_task"
|
6
|
-
|
7
|
-
Rake::TestTask.new
|
8
|
-
|
9
|
-
RSpec::Core::RakeTask.new(:spec)
|
10
|
-
|
11
|
-
require "rubocop/rake_task"
|
12
|
-
|
13
|
-
RuboCop::RakeTask.new
|
14
|
-
|
15
|
-
task default: %i[test rubocop]
|
16
|
-
|
17
|
-
desc "Generate a new cop with a template"
|
18
|
-
task :new_cop, [:cop] do |_task, args|
|
19
|
-
require "rubocop"
|
20
|
-
|
21
|
-
cop_name = args.fetch(:cop) do
|
22
|
-
warn "usage: bundle exec rake 'new_cop[Department/Name]'"
|
23
|
-
exit!
|
24
|
-
end
|
25
|
-
|
26
|
-
generator = RuboCop::Cop::Generator.new(cop_name)
|
27
|
-
|
28
|
-
generator.write_source
|
29
|
-
generator.write_spec
|
30
|
-
generator.inject_require(root_file_path: "lib/rubocop-rails-accessibility.rb")
|
31
|
-
generator.inject_config(config_file_path: "config/default.yml")
|
32
|
-
|
33
|
-
puts generator.todo
|
34
|
-
end
|
data/lib/rubocop/cop/inject.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "rubocop"
|
4
|
-
|
5
|
-
# The original code is from https://github.com/rubocop/rubocop-rspec/blob/main/lib/rubocop/rspec/inject.rb
|
6
|
-
# See https://github.com/rubocop/rubocop-rspec/blob/main/MIT-LICENSE.md
|
7
|
-
module RubocopRailsAccessibility
|
8
|
-
module Inject
|
9
|
-
def self.defaults!
|
10
|
-
path = CONFIG_DEFAULT.to_s
|
11
|
-
hash = ::RuboCop::ConfigLoader.send(:load_yaml_configuration, path)
|
12
|
-
config = ::RuboCop::Config.new(hash, path).tap(&:make_excludes_absolute)
|
13
|
-
puts "configuration from #{path}" if ::RuboCop::ConfigLoader.debug?
|
14
|
-
config = ::RuboCop::ConfigLoader.merge_with_default(config, path)
|
15
|
-
::RuboCop::ConfigLoader.instance_variable_set(:@default_configuration, config)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,10 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "pathname"
|
4
|
-
require "yaml"
|
5
|
-
|
6
|
-
require_relative "inject"
|
7
|
-
require_relative "version"
|
8
|
-
require_relative "rubocop-rails-accessibility/image_has_alt"
|
9
|
-
require_relative "rubocop-rails-accessibility/no_positive_tabindex"
|
10
|
-
require_relative "rubocop-rails-accessibility/no_redundant_image_alt"
|
data/lib/rubocop/cop/version.rb
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative "lib/rubocop/cop/version"
|
4
|
-
|
5
|
-
Gem::Specification.new do |spec|
|
6
|
-
spec.name = "rubocop-rails-accessibility"
|
7
|
-
spec.version = RubocopRailsAccessibility::VERSION
|
8
|
-
spec.authors = ["GitHub Accessibility Team"]
|
9
|
-
spec.email = ["accessibility@github.com"]
|
10
|
-
|
11
|
-
spec.summary = "Custom extension for RuboCop."
|
12
|
-
spec.homepage = "https://github.com/github/rubocop-rails-accessibility"
|
13
|
-
spec.license = "MIT"
|
14
|
-
spec.required_ruby_version = ">= 2.7.0"
|
15
|
-
|
16
|
-
spec.metadata["homepage_uri"] = spec.homepage
|
17
|
-
spec.metadata["source_code_uri"] = spec.homepage
|
18
|
-
spec.metadata["changelog_uri"] = "#{spec.homepage}/blob/main/CHANGELOG.md"
|
19
|
-
spec.metadata["rubygems_mfa_required"] = "true"
|
20
|
-
|
21
|
-
spec.add_dependency "rubocop", ">= 1.0.0"
|
22
|
-
|
23
|
-
spec.add_development_dependency "actionview"
|
24
|
-
spec.add_development_dependency "minitest"
|
25
|
-
spec.add_development_dependency "rake", "~> 13.0"
|
26
|
-
spec.add_development_dependency "rspec", "~> 3.0"
|
27
|
-
spec.add_development_dependency "rubocop-github"
|
28
|
-
spec.add_development_dependency "rubocop-rails"
|
29
|
-
spec.add_development_dependency "rubocop-performance"
|
30
|
-
|
31
|
-
# Specify which files should be added to the gem when it is released.
|
32
|
-
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
33
|
-
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
34
|
-
`git ls-files -z`.split("\x0").reject do |f|
|
35
|
-
(f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
36
|
-
end
|
37
|
-
end
|
38
|
-
spec.bindir = "exe"
|
39
|
-
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
40
|
-
spec.require_paths = ["lib"]
|
41
|
-
end
|