Class: ERBLint::Linters::GitHub::Accessibility::ImageHasAlt
- Inherits:
-
Linter
- Object
- Linter
- ERBLint::Linters::GitHub::Accessibility::ImageHasAlt
- Includes:
- CustomHelpers, LinterRegistry
- Defined in:
- lib/erblint-github/linters/github/accessibility/image_has_alt.rb
Constant Summary collapse
- MESSAGE =
"<img> should have an alt prop with meaningful text or an empty string for decorative images"
Instance Method Summary collapse
Methods included from CustomHelpers
#basic_conditional_code_check, #generate_offense, #possible_attribute_values, #rule_disabled?, #simple_class_name, #tags
Instance Method Details
#run(processed_source) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/erblint-github/linters/github/accessibility/image_has_alt.rb', line 15 def run(processed_source) (processed_source).each do |tag| next if tag.name != "img" next if tag.closing? alt = possible_attribute_values(tag, "alt") generate_offense(self.class, processed_source, tag) if alt.empty? end rule_disabled?(processed_source) end |