Class: HamlLint::Linter::ImplicitDiv
- Inherits:
-
Linter
- Object
- Linter
- HamlLint::Linter::ImplicitDiv
- Includes:
- HamlLint::LinterRegistry
- Defined in:
- lib/haml_lint/linter/implicit_div.rb
Overview
Checks for unnecessary uses of the %div prefix where a class name or ID
already implies a div.
Instance Method Summary collapse
Methods included from HamlLint::LinterRegistry
extract_linters_from, included
Instance Method Details
#visit_tag(node) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/haml_lint/linter/implicit_div.rb', line 11 def visit_tag(node) return unless node.tag_name == 'div' return unless node.static_classes.any? || node.static_ids.any? tag = node.source_code[/\s*([^\s={(\[]+)/, 1] return unless tag.start_with?('%div') corrected = correct_implicit_div(node) record_lint(node, "`#{tag}` can be written as `#{node.static_attributes_source}` " \ 'since `%div` is implicit', corrected: corrected) end |