Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt repo to be a rules set #1

Merged
merged 5 commits into from
Aug 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
matrix:
ruby:
- '2.6'
- '2.7'

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
/pkg/
/spec/reports/
/tmp/

vendor/
# rspec failure tracking
.rspec_status
17 changes: 8 additions & 9 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
AllCops:
NewCops: enable
SuggestExtensions: false
TargetRubyVersion: 2.6
inherit_gem:
rubocop-github:
- config/default.yml
- config/rails.yml

Metrics:
Enabled: false

Style/Documentation:
Enabled: false
Naming/FileName:
Enabled: true
Exclude:
- "rubocop-rails-accessibility.gemspec"
7 changes: 0 additions & 7 deletions CHANGELOG.md

This file was deleted.

84 changes: 0 additions & 84 deletions CODE_OF_CONDUCT.md

This file was deleted.

22 changes: 22 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# How to contribute

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.

### Contributing guidelines

In general, I follow the "fork-and-pull" Git workflow:

1. **Fork and clone** the repo on GitHub.
2. **Configure and install** the dependencies `npm install`.
3. **Create** a new branch: `git checkout -b branch-name`.
4. **Commit** all your changes to your branch. Please write a [good commit message](https://chris.beams.io/posts/git-commit/).
5. **Push** your work back up to your fork.
6. **Submit a Pull Request** so that I can review your changes. Please add documentation and some details to the PR.

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.

## Resources

- [How to Contribute to Open Source](https://opensource.guide/how-to-contribute/)
- [Using Pull Requests](https://help.github.com/articles/about-pull-requests/)
- [GitHub Help](https://help.github.com)
8 changes: 2 additions & 6 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
# frozen_string_literal: true

source 'https://rubygems.org'
source "https://rubygems.org"

# Specify your gem's dependencies in my_extension.gemspec
# Specify your gem's dependencies in rubocop-rails-accessibility.gemspec
gemspec

gem 'rake', '~> 13.0'
gem 'rspec', '~> 3.0'
gem 'rubocop', '~> 1.21'
58 changes: 54 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,18 +1,50 @@
PATH
remote: .
specs:
my_extension (0.1.0)
rubocop
rubocop-rails-accessibility (0.1.0)
rubocop (>= 1.0.0)

GEM
remote: https://rubygems.org/
specs:
actionview (7.0.3.1)
activesupport (= 7.0.3.1)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
activesupport (7.0.3.1)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
ast (2.4.2)
builder (3.2.4)
concurrent-ruby (1.1.10)
crass (1.0.6)
diff-lcs (1.5.0)
erubi (1.11.0)
i18n (1.12.0)
concurrent-ruby (~> 1.0)
json (2.6.2)
loofah (2.18.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
minitest (5.16.3)
nokogiri (1.13.8-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.13.8-x86_64-linux)
racc (~> 1.4)
parallel (1.22.1)
parser (3.1.2.0)
ast (~> 2.4.1)
racc (1.6.0)
rack (2.2.4)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.4.3)
loofah (~> 2.3)
rainbow (3.1.1)
rake (13.0.6)
regexp_parser (2.5.0)
Expand Down Expand Up @@ -42,17 +74,35 @@ GEM
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.19.1)
parser (>= 3.1.1.0)
rubocop-github (0.18.0)
rubocop (>= 1.0.0)
rubocop-performance
rubocop-rails
rubocop-performance (1.14.3)
rubocop (>= 1.7.0, < 2.0)
rubocop-ast (>= 0.4.0)
rubocop-rails (2.15.2)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.7.0, < 2.0)
ruby-progressbar (1.11.0)
tzinfo (2.0.5)
concurrent-ruby (~> 1.0)
unicode-display_width (2.2.0)

PLATFORMS
x86_64-darwin-19
x86_64-linux

DEPENDENCIES
my_extension!
actionview
minitest
rake (~> 13.0)
rspec (~> 3.0)
rubocop (~> 1.21)
rubocop-github
rubocop-performance
rubocop-rails
rubocop-rails-accessibility!

BUNDLED WITH
2.3.17
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 GitHub

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
66 changes: 59 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,63 @@
# rubocop-extension-template
# RuboCop Rails Accessibility

Custom [RuboCop](https://github.com/rubocop/rubocop) extension template.
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.

## Installation

Install the `rubocop-rails-accessibility` gem

```sh
gem install rubocop-rails-accessibility
```

or if you use bundler put this in your `Gemfile`

```ruby
gem 'rubocop-rails-accessibility'
gem "rubocop-performance", require: false
gem "rubocop-rails", require: false
```

## Usage

1. [Use this template](https://github.com/r7kamura/rubocop-extension-template/generate) to create a repository
2. Rename gem name from `my_extension` to your own
3. Run `bin/setup`
4. Add your custom cop by running `bundle exec rake new_cop[Foo/Bar]`
5. Edit `lib/rubocop/cop/foo/bar.rb`
You need to tell RuboCop to load RuboCop Rails Accessibility.

Put this into your `.rubocop.yml`.

``` yaml
inherit_gem:
rubocop-rails-accessibility:
- config/default.yml
- config/rubocop_rails_accessibility.yml
```

## Testing

Install all of the required gems

```sh[]
bundle install
```[]

Run the tests

```sh
bundle exec rake
```

## The Cops

All cops are located under
[`lib/rubocop/cop/rubocop_rails_accessibility`](lib/rubocop/cop/rubocop_rails_accessibility), and contain
examples/documentation.

## Rules

- [RuboCop::Cop::Accessibility::ImageHasAlt](guides/image-has-alt.md)
- [RuboCop::Cop::Accessibility::LinkHasHref](guides/link-has-href.md)
- [RuboCop::Cop::Accessibility::NoPositiveTabindex](guides/no-positive-tabindex.md)
- [RuboCop::Cop::Accessibility::NoRedundantImageAlt](guides/no-redundant-image-alt.md)

## Contributing

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).
19 changes: 11 additions & 8 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
# frozen_string_literal: true

require 'bundler/gem_tasks'
require 'rspec/core/rake_task'
require "bundler/gem_tasks"
require "rake/testtask"
require "rspec/core/rake_task"

Rake::TestTask.new

RSpec::Core::RakeTask.new(:spec)

require 'rubocop/rake_task'
require "rubocop/rake_task"

RuboCop::RakeTask.new

task default: %i[spec rubocop]
task default: %i[test rubocop]

desc 'Generate a new cop with a template'
desc "Generate a new cop with a template"
task :new_cop, [:cop] do |_task, args|
require 'rubocop'
require "rubocop"

cop_name = args.fetch(:cop) do
warn "usage: bundle exec rake 'new_cop[Department/Name]'"
Expand All @@ -24,8 +27,8 @@ task :new_cop, [:cop] do |_task, args|

generator.write_source
generator.write_spec
generator.inject_require(root_file_path: 'lib/my_extension.rb')
generator.inject_config(config_file_path: 'config/default.yml')
generator.inject_require(root_file_path: "lib/rubocop-rails-accessibility.rb")
generator.inject_config(config_file_path: "config/default.yml")

puts generator.todo
end
2 changes: 1 addition & 1 deletion bin/console
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# frozen_string_literal: true

require 'bundler/setup'
require 'my_extension'
require 'rubocop-rails-accessibility'

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