Skip to content

Commit 5a11b4b

Browse files
author
Adrián Bolonio
committed
Adapt repo to be a rules set
1 parent 728926d commit 5a11b4b

32 files changed

+554
-249
lines changed

.rubocop.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ AllCops:
33
SuggestExtensions: false
44
TargetRubyVersion: 2.6
55

6-
Metrics:
7-
Enabled: false
8-
9-
Style/Documentation:
10-
Enabled: false
6+
Naming/FileName:
7+
Enabled: true
8+
Exclude:
9+
- "rubocop-rails-accessibility.gemspec"

CHANGELOG.md

Lines changed: 0 additions & 7 deletions
This file was deleted.

CODE_OF_CONDUCT.md

Lines changed: 0 additions & 84 deletions
This file was deleted.

CONTRIBUTING.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# How to contribute
2+
3+
This is an open source project, so if you have suggestions for how this project could be improved, or want to report a bug, open an issue! I'd love all and any contributions. You can submit issues and enhancement requests through the [issues page on GitHub](https://github.com/github/rubocop-rails-accessibility/issues). If you have any question, please don't hesitate to contact me, I'd love to hear from you.
4+
5+
### Contributing guidelines
6+
7+
In general, I follow the "fork-and-pull" Git workflow:
8+
9+
1. **Fork and clone** the repo on GitHub.
10+
2. **Configure and install** the dependencies `npm install`.
11+
3. **Create** a new branch: `git checkout -b branch-name`.
12+
4. **Commit** all your changes to your branch. Please write a [good commit message](https://chris.beams.io/posts/git-commit/).
13+
5. **Push** your work back up to your fork.
14+
6. **Submit a Pull Request** so that I can review your changes. Please add documentation and some details to the PR.
15+
16+
Keep your changes as focused as possible. If there are multiple changes you would like to make that are not dependent upon each other, consider submitting them as separate pull requests. Work in Progress pull requests are also welcome to get feedback early on, or if there is something blocked you.
17+
18+
## Resources
19+
20+
- [How to Contribute to Open Source](https://opensource.guide/how-to-contribute/)
21+
- [Using Pull Requests](https://help.github.com/articles/about-pull-requests/)
22+
- [GitHub Help](https://help.github.com)

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
source 'https://rubygems.org'
44

5-
# Specify your gem's dependencies in my_extension.gemspec
5+
# Specify your gem's dependencies in rubocop-rails-accessibility.gemspec
66
gemspec
77

88
gem 'rake', '~> 13.0'

Gemfile.lock

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,47 @@
11
PATH
22
remote: .
33
specs:
4-
my_extension (0.1.0)
4+
rubocop-rails-accessibility (0.1.0)
55
rubocop
66

77
GEM
88
remote: https://rubygems.org/
99
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)
1021
ast (2.4.2)
22+
builder (3.2.4)
23+
concurrent-ruby (1.1.10)
24+
crass (1.0.6)
1125
diff-lcs (1.5.0)
26+
erubi (1.11.0)
27+
i18n (1.12.0)
28+
concurrent-ruby (~> 1.0)
1229
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-linux)
35+
racc (~> 1.4)
1336
parallel (1.22.1)
1437
parser (3.1.2.0)
1538
ast (~> 2.4.1)
39+
racc (1.6.0)
40+
rails-dom-testing (2.0.3)
41+
activesupport (>= 4.2.0)
42+
nokogiri (>= 1.6)
43+
rails-html-sanitizer (1.4.3)
44+
loofah (~> 2.3)
1645
rainbow (3.1.1)
1746
rake (13.0.6)
1847
regexp_parser (2.5.0)
@@ -43,16 +72,20 @@ GEM
4372
rubocop-ast (1.19.1)
4473
parser (>= 3.1.1.0)
4574
ruby-progressbar (1.11.0)
75+
tzinfo (2.0.5)
76+
concurrent-ruby (~> 1.0)
4677
unicode-display_width (2.2.0)
4778

4879
PLATFORMS
4980
x86_64-linux
5081

5182
DEPENDENCIES
52-
my_extension!
83+
actionview
84+
minitest
5385
rake (~> 13.0)
5486
rspec (~> 3.0)
5587
rubocop (~> 1.21)
88+
rubocop-rails-accessibility!
5689

5790
BUNDLED WITH
5891
2.3.17

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 GitHub
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 59 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,63 @@
1-
# rubocop-extension-template
1+
# RuboCop Rails Accessibility
22

3-
Custom [RuboCop](https://github.com/rubocop/rubocop) extension template.
3+
This repository provides recommended [RuboCop](https://github.com/rubocop/rubocop) configuration and additional **accessibility RuboCop Rails cops** for use on open source and internal Rails projects.
4+
5+
## Installation
6+
7+
Install the `rubocop-rails-accessibility` gem
8+
9+
```sh
10+
gem install rubocop-rails-accessibility
11+
```
12+
13+
or if you use bundler put this in your `Gemfile`
14+
15+
```ruby
16+
gem 'rubocop-rails-accessibility'
17+
gem "rubocop-performance", require: false
18+
gem "rubocop-rails", require: false
19+
```
420

521
## Usage
622

7-
1. [Use this template](https://github.com/r7kamura/rubocop-extension-template/generate) to create a repository
8-
2. Rename gem name from `my_extension` to your own
9-
3. Run `bin/setup`
10-
4. Add your custom cop by running `bundle exec rake new_cop[Foo/Bar]`
11-
5. Edit `lib/rubocop/cop/foo/bar.rb`
23+
You need to tell RuboCop to load RuboCop Rails Accessibility.
24+
25+
Put this into your `.rubocop.yml`.
26+
27+
``` yaml
28+
inherit_gem:
29+
rubocop-rails-accessibility:
30+
- config/default.yml
31+
- config/rubocop_rails_accessibility.yml
32+
```
33+
34+
## Testing
35+
36+
Install all of the required gems
37+
38+
```sh[]
39+
bundle install
40+
```[]
41+
42+
Run the tests
43+
44+
```sh
45+
bundle exec rake
46+
```
47+
48+
## The Cops
49+
50+
All cops are located under
51+
[`lib/rubocop/cop/rubocop_rails_accessibility`](lib/rubocop/cop/rubocop_rails_accessibility), and contain
52+
examples/documentation.
53+
54+
## Rules
55+
56+
- [RuboCop::Cop::Accessibility::ImageHasAlt](guides/image-has-alt.md)
57+
- [RuboCop::Cop::Accessibility::LinkHasHref](guides/link-has-href.md)
58+
- [RuboCop::Cop::Accessibility::NoPositiveTabindex](guides/no-positive-tabindex.md)
59+
- [RuboCop::Cop::Accessibility::NoRedundantImageAlt](guides/no-redundant-image-alt.md)
60+
61+
## Contributing
62+
63+
If you have any suggestion for how this project could be improved, please read the [contributing guidelines](https://github.com/github/rubocop-rails-accessibility/blob/main/CONTRIBUTING.md).

Rakefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
# frozen_string_literal: true
22

33
require 'bundler/gem_tasks'
4+
require 'rake/testtask'
45
require 'rspec/core/rake_task'
56

7+
Rake::TestTask.new
8+
69
RSpec::Core::RakeTask.new(:spec)
710

811
require 'rubocop/rake_task'
912

1013
RuboCop::RakeTask.new
1114

12-
task default: %i[spec rubocop]
15+
task default: %i[test rubocop]
1316

1417
desc 'Generate a new cop with a template'
1518
task :new_cop, [:cop] do |_task, args|
@@ -24,7 +27,7 @@ task :new_cop, [:cop] do |_task, args|
2427

2528
generator.write_source
2629
generator.write_spec
27-
generator.inject_require(root_file_path: 'lib/my_extension.rb')
30+
generator.inject_require(root_file_path: 'lib/rubocop-rails-accessibility.rb')
2831
generator.inject_config(config_file_path: 'config/default.yml')
2932

3033
puts generator.todo

bin/console

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# frozen_string_literal: true
33

44
require 'bundler/setup'
5-
require 'my_extension'
5+
require 'rubocop-rails-accessibility'
66

77
# You can add fixtures and/or initialization code here to make experimenting
88
# with your gem easier. You can also use a different console, if you like.

0 commit comments

Comments
 (0)