Class: SCSSLint::Linter

Inherits:
Sass::Tree::Visitors::Base
  • Object
show all
Includes:
SelectorVisitor, Utils
Defined in:
lib/scss_lint/linter.rb

Overview

Defines common functionality available to all linters.

Defined Under Namespace

Classes: BangFormat, BorderZero, ColorKeyword, ColorVariable, Comment, Compass, DebugStatement, DeclarationOrder, DuplicateProperty, ElsePlacement, EmptyLineBetweenBlocks, EmptyRule, FinalNewline, HexLength, HexNotation, HexValidation, IdSelector, ImportPath, ImportantRule, Indentation, LeadingZero, MergeableSelector, NameFormat, NestingDepth, PlaceholderInExtend, PropertyCount, PropertySortOrder, PropertySpelling, PropertyUnits, QualifyingElement, SelectorDepth, SelectorFormat, Shorthand, SingleLinePerProperty, SingleLinePerSelector, SpaceAfterComma, SpaceAfterPropertyColon, SpaceAfterPropertyName, SpaceBeforeBrace, SpaceBetweenParens, StringQuotes, TrailingSemicolon, TrailingZero, UnnecessaryMantissa, UnnecessaryParentReference, UrlFormat, UrlQuotes, VariableForProperty, VendorPrefix, ZeroUnit

Constant Summary

Constants included from Utils

Utils::COLOR_REGEX

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils

#color?, #color_hex?, #color_keyword?, #color_keyword_to_code, #extract_string_selectors, #node_ancestor, #node_siblings, #pluralize, #previous_node, #remove_quoted_strings, #same_position?

Methods included from SelectorVisitor

#visit_selector

Constructor Details

#initializeLinter

Create a linter.



10
11
12
# File 'lib/scss_lint/linter.rb', line 10

def initialize
  @lints = []
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



7
8
9
# File 'lib/scss_lint/linter.rb', line 7

def config
  @config
end

#engineObject (readonly)

Returns the value of attribute engine.



7
8
9
# File 'lib/scss_lint/linter.rb', line 7

def engine
  @engine
end

#lintsObject (readonly)

Returns the value of attribute lints.



7
8
9
# File 'lib/scss_lint/linter.rb', line 7

def lints
  @lints
end

Instance Method Details

#nameObject

Return the human-friendly name of this linter as specified in the configuration file and in lint descriptions.



31
32
33
# File 'lib/scss_lint/linter.rb', line 31

def name
  self.class.name.split('::')[2..-1].join('::')
end

#run(engine, config) ⇒ Array<Lint>

Run this linter against a parsed document with the given configuration, returning the lints that were found.

Parameters:

Returns:



20
21
22
23
24
25
26
27
# File 'lib/scss_lint/linter.rb', line 20

def run(engine, config)
  @lints = []
  @config = config
  @engine = engine
  @comment_processor = ControlCommentProcessor.new(self)
  visit(engine.tree)
  @lints = @comment_processor.filter_lints(@lints)
end