Class: RuboCop::Cop::RailsAccessibility::NoRedundantImageAlt

Inherits:
Base
  • Object
show all
Defined in:
lib/rubocop/cop/rails_accessibility/no_redundant_image_alt.rb

Constant Summary collapse

MSG =
"Alt prop should not contain `image` or `picture` as screen readers already announce the element as an image"
REDUNDANT_ALT_WORDS =
%w[image picture].freeze

Instance Method Summary collapse

Instance Method Details

#on_send(node) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/rubocop/cop/rails_accessibility/no_redundant_image_alt.rb', line 14

def on_send(node)
  receiver, method_name, = *node

  return unless receiver.nil? && method_name == :image_tag

  return unless redundant_alt?(node)

  add_offense(node.loc.selector)
end