Class: HamlLint::Linter

Inherits:
Object
  • Object
show all
Includes:
HamlVisitor
Defined in:
lib/haml_lint/linter.rb

Overview

Base implementation for all lint checks.

Defined Under Namespace

Classes: AltText, ClassAttributeWithStaticValue, ClassesBeforeIds, ConsecutiveComments, ConsecutiveSilentScripts, EmptyScript, HtmlAttributes, ImplicitDiv, LeadingCommentSpace, LineLength, MultilinePipe, MultilineScript, ObjectReferenceAttributes, RuboCop, RubyComments, SpaceBeforeScript, SpaceInsideHashAttributes, TagName, TrailingWhitespace, UnnecessaryInterpolation, UnnecessaryStringOutput

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from HamlVisitor

#visit, #visit_children

Constructor Details

#initialize(config) ⇒ Linter

Returns a new instance of Linter

Parameters:

  • config (Hash)

    configuration for this linter


9
10
11
12
13
# File 'lib/haml_lint/linter.rb', line 9

def initialize(config)
  @config = config
  @lints = []
  @ruby_parser = nil
end

Instance Attribute Details

#lintsObject (readonly)

Returns the value of attribute lints


6
7
8
# File 'lib/haml_lint/linter.rb', line 6

def lints
  @lints
end

#parserObject (readonly)

Returns the value of attribute parser


6
7
8
# File 'lib/haml_lint/linter.rb', line 6

def parser
  @parser
end

Instance Method Details

#nameObject

Returns the simple name for this linter.


21
22
23
# File 'lib/haml_lint/linter.rb', line 21

def name
  self.class.name.split('::').last
end

#run(parser) ⇒ Object


15
16
17
18
# File 'lib/haml_lint/linter.rb', line 15

def run(parser)
  @parser = parser
  visit(parser.tree)
end