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, 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_siblings, #pluralize, #previous_node, #remove_quoted_strings, #same_position?

Methods included from SelectorVisitor

#visit_selector

Constructor Details

#initializeLinter

Returns a new instance of Linter.



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

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.



27
28
29
# File 'lib/scss_lint/linter.rb', line 27

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

#run(engine, config) ⇒ Object

Run this linter against a parsed document with a given configuration.

Parameters:



17
18
19
20
21
22
23
# File 'lib/scss_lint/linter.rb', line 17

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