Class: HamlLint::Linter Abstract

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

Overview

This class is abstract.

Base implementation for all lint checks.

Defined Under Namespace

Classes: AltText, ClassAttributeWithStaticValue, ClassesBeforeIds, ConsecutiveComments, ConsecutiveSilentScripts, EmptyObjectReference, EmptyScript, FinalNewline, HtmlAttributes, ImplicitDiv, Indentation, 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

Initializes a linter with the specified configuration.

Parameters:

  • config (Hash)

    configuration for this linter



17
18
19
20
# File 'lib/haml_lint/linter.rb', line 17

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

Instance Attribute Details

#lintsObject (readonly)

TODO:

Remove once spec/support/shared_linter_context returns an array of lints for the subject instead of the linter itself.

List of lints reported by this linter.



12
13
14
# File 'lib/haml_lint/linter.rb', line 12

def lints
  @lints
end

Instance Method Details

#nameString

Returns the simple name for this linter.

Returns:

  • (String)


35
36
37
# File 'lib/haml_lint/linter.rb', line 35

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

#run(document) ⇒ Object

Runs the linter against the given Haml document.

Parameters:



25
26
27
28
29
30
# File 'lib/haml_lint/linter.rb', line 25

def run(document)
  @document = document
  @lints = []
  visit(document.tree)
  @lints
end