Class: HamlLint::Linter::StrictLocals

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

Overview

Checks for the presence of a ‘locals` magic comment at the beginning of a partial.

Defined Under Namespace

Classes: DummyNode

Instance Attribute Summary

Attributes inherited from HamlLint::Linter

#lints

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

#visit, #visit_children

Constructor Details

This class inherits a constructor from HamlLint::Linter

Instance Method Details

#visit_root(root) ⇒ true, false

Enables the linter if the tree is for the right file type.

Parameters:

Returns:

  • (true, false)

    whether the linter is enabled for the tree



14
15
16
17
18
19
20
21
22
# File 'lib/haml_lint/linter/strict_locals.rb', line 14

def visit_root(root)
  return unless enabled?(root)

  first_children = root.children.first
  return if first_children.is_a?(HamlLint::Tree::HamlCommentNode) &&
                first_children.is_strict_locals?

  record_lint(DummyNode.new(1), failure_message)
end