Skip to content

Commit 2bf85b5

Browse files
author
Adrián Bolonio
authored
Merge pull request #1 from github/rubocop-rules-set
Adapt repo to be a rules set
2 parents 728926d + 5c9cd89 commit 2bf85b5

36 files changed

+626
-302
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
strategy:
1414
matrix:
1515
ruby:
16-
- '2.6'
16+
- '2.7'
1717

1818
steps:
1919
- uses: actions/checkout@v2

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
/pkg/
77
/spec/reports/
88
/tmp/
9-
9+
vendor/
1010
# rspec failure tracking
1111
.rspec_status

.rubocop.yml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
AllCops:
2-
NewCops: enable
3-
SuggestExtensions: false
4-
TargetRubyVersion: 2.6
1+
inherit_gem:
2+
rubocop-github:
3+
- config/default.yml
4+
- config/rails.yml
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: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
# frozen_string_literal: true
22

3-
source 'https://rubygems.org'
3+
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
7-
8-
gem 'rake', '~> 13.0'
9-
gem 'rspec', '~> 3.0'
10-
gem 'rubocop', '~> 1.21'

Gemfile.lock

Lines changed: 54 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,50 @@
11
PATH
22
remote: .
33
specs:
4-
my_extension (0.1.0)
5-
rubocop
4+
rubocop-rails-accessibility (0.1.0)
5+
rubocop (>= 1.0.0)
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-darwin)
35+
racc (~> 1.4)
36+
nokogiri (1.13.8-x86_64-linux)
37+
racc (~> 1.4)
1338
parallel (1.22.1)
1439
parser (3.1.2.0)
1540
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)
1648
rainbow (3.1.1)
1749
rake (13.0.6)
1850
regexp_parser (2.5.0)
@@ -42,17 +74,35 @@ GEM
4274
unicode-display_width (>= 1.4.0, < 3.0)
4375
rubocop-ast (1.19.1)
4476
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)
4588
ruby-progressbar (1.11.0)
89+
tzinfo (2.0.5)
90+
concurrent-ruby (~> 1.0)
4691
unicode-display_width (2.2.0)
4792

4893
PLATFORMS
94+
x86_64-darwin-19
4995
x86_64-linux
5096

5197
DEPENDENCIES
52-
my_extension!
98+
actionview
99+
minitest
53100
rake (~> 13.0)
54101
rspec (~> 3.0)
55-
rubocop (~> 1.21)
102+
rubocop-github
103+
rubocop-performance
104+
rubocop-rails
105+
rubocop-rails-accessibility!
56106

57107
BUNDLED WITH
58108
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).

0 commit comments

Comments
 (0)