Class: HamlLint::Linter::ConsecutiveSilentScripts
- Inherits:
-
HamlLint::Linter
- Object
- HamlLint::Linter
- HamlLint::Linter::ConsecutiveSilentScripts
- Includes:
- HamlLint::LinterRegistry
- Defined in:
- lib/haml_lint/linter/consecutive_silent_scripts.rb
Overview
Checks for multiple consecutive silent script markers that could be condensed into a :ruby filter block.
Constant Summary collapse
- SILENT_SCRIPT_DETECTOR =
->(child) do child.type == :silent_script && child.children.empty? end
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
Methods included from HamlVisitor
Constructor Details
This class inherits a constructor from HamlLint::Linter
Instance Method Details
#visit_root(node) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/haml_lint/linter/consecutive_silent_scripts.rb', line 11 def visit_root(node) HamlLint::Utils.for_consecutive_items( node.children, SILENT_SCRIPT_DETECTOR, config['max_consecutive'] + 1, ) do |group| record_lint(group.first, "#{group.count} consecutive Ruby scripts can be merged " \ 'into a single `:ruby` filter') end end |