Class: HamlLint::Linter::ImplicitDiv
- Inherits:
-
HamlLint::Linter
- Object
- HamlLint::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 Attribute Summary
Attributes inherited from HamlLint::Linter
Instance Method Summary collapse
Methods included from HamlLint::LinterRegistry
extract_linters_from, included
Methods inherited from HamlLint::Linter
#initialize, #name, #run, #run_or_raise, supports_autocorrect?, #supports_autocorrect?
Methods included from HamlVisitor
Constructor Details
This class inherits a constructor from HamlLint::Linter
Instance Method Details
#visit_tag(node) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/haml_lint/linter/implicit_div.rb', line 9 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') record_lint(node, "`#{tag}` can be written as `#{node.static_attributes_source}` " \ 'since `%div` is implicit') end |