Class: SCSSLint::Linter
- Inherits:
-
Sass::Tree::Visitors::Base
- Object
- Sass::Tree::Visitors::Base
- SCSSLint::Linter
- Includes:
- SelectorVisitor, Utils
- Defined in:
- lib/scss_lint/linter.rb
Overview
Defines common functionality available to all linters.
Direct Known Subclasses
BangFormat, BemDepth, BorderZero, ChainedClasses, ColorKeyword, ColorVariable, Comment, Compass, DebugStatement, DeclarationOrder, DisableLinterReason, DuplicateProperty, ElsePlacement, EmptyLineBetweenBlocks, EmptyRule, ExtendDirective, FinalNewline, HexLength, HexNotation, HexValidation, IdSelector, ImportPath, ImportantRule, Indentation, LeadingZero, LengthVariable, MergeableSelector, NameFormat, NestingDepth, PlaceholderInExtend, PrivateNamingConvention, PropertyCount, PropertySortOrder, PropertySpelling, PropertyUnits, PseudoElement, QualifyingElement, SelectorDepth, SelectorFormat, Shorthand, SingleLinePerProperty, SingleLinePerSelector, SpaceAfterComma, SpaceAfterComment, SpaceAfterPropertyColon, SpaceAfterPropertyName, SpaceAfterVariableColon, SpaceAfterVariableName, SpaceAroundOperator, SpaceBeforeBrace, SpaceBetweenParens, StringQuotes, TrailingSemicolon, TrailingWhitespace, TrailingZero, TransitionAll, UnnecessaryMantissa, UnnecessaryParentReference, UrlFormat, UrlQuotes, VariableForProperty, VendorPrefix, ZeroUnit
Defined Under Namespace
Classes: BangFormat, BemDepth, BorderZero, ChainedClasses, ColorKeyword, ColorVariable, Comment, Compass, DebugStatement, DeclarationOrder, DisableLinterReason, DuplicateProperty, ElsePlacement, EmptyLineBetweenBlocks, EmptyRule, ExtendDirective, FinalNewline, HexLength, HexNotation, HexValidation, IdSelector, ImportPath, ImportantRule, Indentation, LeadingZero, LengthVariable, MergeableSelector, NameFormat, NestingDepth, PlaceholderInExtend, PrivateNamingConvention, PropertyCount, PropertySortOrder, PropertySpelling, PropertyUnits, PseudoElement, QualifyingElement, SelectorDepth, SelectorFormat, Shorthand, SingleLinePerProperty, SingleLinePerSelector, SpaceAfterComma, SpaceAfterComment, SpaceAfterPropertyColon, SpaceAfterPropertyName, SpaceAfterVariableColon, SpaceAfterVariableName, SpaceAroundOperator, SpaceBeforeBrace, SpaceBetweenParens, StringQuotes, TrailingSemicolon, TrailingWhitespace, TrailingZero, TransitionAll, UnnecessaryMantissa, UnnecessaryParentReference, UrlFormat, UrlQuotes, VariableForProperty, VendorPrefix, ZeroUnit
Constant Summary
Constants included from Utils
Class Attribute Summary collapse
-
.simple_name ⇒ Object
Returns the value of attribute simple_name.
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#engine ⇒ Object
readonly
Returns the value of attribute engine.
-
#lints ⇒ Object
readonly
Returns the value of attribute lints.
Class Method Summary collapse
-
.inherited(linter) ⇒ Object
When defining a Linter class, define its simple name as well.
Instance Method Summary collapse
-
#initialize ⇒ Linter
constructor
Create a linter.
-
#name ⇒ Object
Return the human-friendly name of this linter as specified in the configuration file and in lint descriptions.
-
#run(engine, config) ⇒ Array<Lint>
Run this linter against a parsed document with the given configuration, returning the lints that were found.
Methods included from Utils
#color?, #color_hex?, #color_keyword?, #color_keyword_to_code, #else_node?, #extract_string_selectors, #node_ancestor, #node_siblings, #pluralize, #previous_node, #remove_quoted_strings, #same_position?
Methods included from SelectorVisitor
Constructor Details
#initialize ⇒ Linter
Create a linter.
26 27 28 |
# File 'lib/scss_lint/linter.rb', line 26 def initialize @lints = [] end |
Class Attribute Details
.simple_name ⇒ Object
Returns the value of attribute simple_name.
8 9 10 |
# File 'lib/scss_lint/linter.rb', line 8 def simple_name @simple_name end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
23 24 25 |
# File 'lib/scss_lint/linter.rb', line 23 def config @config end |
#engine ⇒ Object (readonly)
Returns the value of attribute engine.
23 24 25 |
# File 'lib/scss_lint/linter.rb', line 23 def engine @engine end |
#lints ⇒ Object (readonly)
Returns the value of attribute lints.
23 24 25 |
# File 'lib/scss_lint/linter.rb', line 23 def lints @lints end |
Class Method Details
.inherited(linter) ⇒ Object
When defining a Linter class, define its simple name as well. This assumes that the module hierarchy of every linter starts with ‘SCSSLint::Linter::`, and removes this part of the class name.
‘SCSSLint::Linter::Foo.simple_name` #=> “Foo” `SCSSLint::Linter::Compass::Bar.simple_name` #=> “Compass::Bar”
16 17 18 19 20 |
# File 'lib/scss_lint/linter.rb', line 16 def inherited(linter) name_parts = linter.name.split('::') name = name_parts.length < 3 ? '' : name_parts[2..-1].join('::') linter.simple_name = name end |
Instance Method Details
#name ⇒ Object
Return the human-friendly name of this linter as specified in the configuration file and in lint descriptions.
47 48 49 |
# File 'lib/scss_lint/linter.rb', line 47 def name self.class.simple_name end |
#run(engine, config) ⇒ Array<Lint>
Run this linter against a parsed document with the given configuration, returning the lints that were found.
36 37 38 39 40 41 42 43 |
# File 'lib/scss_lint/linter.rb', line 36 def run(engine, config) @lints = [] @config = config @engine = engine @comment_processor = ControlCommentProcessor.new(self) visit(engine.tree) @lints = @comment_processor.filter_lints(@lints) end |