Class: HamlLint::Linter::Indentation

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

Overview

Checks the character used for indentation.

Constant Summary collapse

INDENT_REGEX =

Allowed leading indentation for each character type.

{
  space: /^ *(?!\t)/,
  tab: /^\t*(?! )/,
}.freeze
LEADING_SPACES_REGEX =
/^( +)(?! )/

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) ⇒ Object



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

def visit_root(root)
  character = config['character'].to_sym
  check_character(character, root)

  width = config['width'].to_i
  check_width(width, root) if character == :space && width > 0
end