Class: HamlLint::Linter::AltText

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

Overview

Checks for missing alt attributes on img tags.

Instance Method Summary collapse

Methods included from HamlLint::LinterRegistry

extract_linters_from, included

Instance Method Details

#visit_tag(node) ⇒ Object



8
9
10
11
12
# File 'lib/haml_lint/linter/alt_text.rb', line 8

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