From 417fc0146090f286e9462e1699f2166d60520349 Mon Sep 17 00:00:00 2001 From: Issy Long Date: Mon, 10 Oct 2022 13:54:17 +0000 Subject: [PATCH 1/3] Delete GitHub/Accessibility cops; point to `rubocop-rails-accessibility` - Accessibility rules used to live in this gem, but https://github.com/github/rubocop-rails-accessibility now exists with the rules that were here and more. The monolith uses the new gem. - For projects that haven't moved over yet, signpost in the README (and the eventual new gem version release notes, please) that accessibility cops have moved. - Fixes https://github.com/github/code-scanning/issues/7337. --- README.md | 3 +- config/accessibility.yml | 15 -------- .../cop/github/accessibility/image_has_alt.rb | 26 ------------- .../cop/github/accessibility/link_has_href.rb | 25 ------------ .../accessibility/no_positive_tabindex.rb | 32 ---------------- .../accessibility/no_redundant_image_alt.rb | 38 ------------------- test/test_image_has_alt.rb | 28 -------------- test/test_link_has_href.rb | 35 ----------------- test/test_no_positive_tabindex.rb | 28 -------------- test/test_no_redundant_image_alt.rb | 28 -------------- 10 files changed, 2 insertions(+), 256 deletions(-) delete mode 100644 config/accessibility.yml delete mode 100644 lib/rubocop/cop/github/accessibility/image_has_alt.rb delete mode 100644 lib/rubocop/cop/github/accessibility/link_has_href.rb delete mode 100644 lib/rubocop/cop/github/accessibility/no_positive_tabindex.rb delete mode 100644 lib/rubocop/cop/github/accessibility/no_redundant_image_alt.rb delete mode 100644 test/test_image_has_alt.rb delete mode 100644 test/test_link_has_href.rb delete mode 100644 test/test_no_positive_tabindex.rb delete mode 100644 test/test_no_redundant_image_alt.rb diff --git a/README.md b/README.md index ab466b1..cdca406 100644 --- a/README.md +++ b/README.md @@ -19,9 +19,10 @@ inherit_gem: rubocop-github: - config/default.yml - config/rails.yml - - config/accessibility.yml ``` +💭 Looking for `config/accessibility.yml` and the `GitHub/Accessibility` configs? [They have moved](https://github.com/github/rubocop-rails-accessibility) to a new gem. + ### Legacy usage If you are using a rubocop version < 1.0.0, you can use rubocop-github version diff --git a/config/accessibility.yml b/config/accessibility.yml deleted file mode 100644 index 1908cad..0000000 --- a/config/accessibility.yml +++ /dev/null @@ -1,15 +0,0 @@ -require: - - rubocop/cop/github/accessibility - -GitHub/Accessibility/ImageHasAlt: - Enabled: true - StyleGuide: https://github.com/github/rubocop-github/blob/master/guides/image-has-alt.md -GitHub/Accessibility/LinkHasHref: - Enabled: true - StyleGuide: https://github.com/github/rubocop-github/blob/master/guides/link-has-href.md -GitHub/Accessibility/NoPositiveTabindex: - Enabled: true - StyleGuide: https://github.com/github/rubocop-github/blob/master/guides/no-positive-tabindex.md -GitHub/Accessibility/NoRedundantImageAlt: - Enabled: true - StyleGuide: https://github.com/github/rubocop-github/blob/master/guides/no-redundant-image-alt.md diff --git a/lib/rubocop/cop/github/accessibility/image_has_alt.rb b/lib/rubocop/cop/github/accessibility/image_has_alt.rb deleted file mode 100644 index 698d922..0000000 --- a/lib/rubocop/cop/github/accessibility/image_has_alt.rb +++ /dev/null @@ -1,26 +0,0 @@ -# frozen_string_literal: true - -require "rubocop" - -module RuboCop - module Cop - module GitHub - module Accessibility - class ImageHasAlt < Base - MSG = "Images should have an alt prop with meaningful text or an empty string for decorative images" - - def_node_search :has_alt_attribute?, "(sym :alt)" - - def on_send(node) - receiver, method_name, _= *node - - if receiver.nil? && method_name == :image_tag - alt = has_alt_attribute?(node) - add_offense(node.loc.selector) if alt.nil? - end - end - end - end - end - end -end diff --git a/lib/rubocop/cop/github/accessibility/link_has_href.rb b/lib/rubocop/cop/github/accessibility/link_has_href.rb deleted file mode 100644 index 751c564..0000000 --- a/lib/rubocop/cop/github/accessibility/link_has_href.rb +++ /dev/null @@ -1,25 +0,0 @@ -# frozen_string_literal: true - -require "rubocop" - -module RuboCop - module Cop - module GitHub - module Accessibility - class LinkHasHref < Base - MSG = "Links should go somewhere, you probably want to use a `