Class: HamlLint::Linter::AltText

Inherits:
HamlLint::Linter show all
Includes:
HamlLint::LinterRegistry
Defined in:
lib/haml_lint/linter/alt_text.rb

Overview

Checks for missing `alt` attributes on `img` tags.

Instance Attribute Summary

Attributes inherited from HamlLint::Linter

#lints, #parser

Instance Method Summary collapse

Methods included from HamlLint::LinterRegistry

extract_linters_from, included

Methods inherited from HamlLint::Linter

#initialize, #name, #run

Methods included from HamlVisitor

#visit, #visit_children

Constructor Details

This class inherits a constructor from HamlLint::Linter

Instance Method Details

#visit_tag(node) ⇒ Object


6
7
8
9
10
# File 'lib/haml_lint/linter/alt_text.rb', line 6

def visit_tag(node)
  if node.tag_name == 'img' && !node.has_hash_attribute?(:alt)
    add_lint(node, '`img` tags must include alt text')
  end
end