Class: SCSSLint::Linter::TrailingSemicolon
- Inherits:
-
SCSSLint::Linter
- Object
- Sass::Tree::Visitors::Base
- SCSSLint::Linter
- SCSSLint::Linter::TrailingSemicolon
- Includes:
- SCSSLint::LinterRegistry
- Defined in:
- lib/scss_lint/linter/trailing_semicolon.rb
Overview
Checks for a trailing semicolon on statements within rule sets.
Constant Summary
Constants included from Utils
Instance Attribute Summary
Attributes inherited from SCSSLint::Linter
Instance Method Summary collapse
- #visit_extend(node) ⇒ Object
- #visit_import(node) ⇒ Object
- #visit_mixin(node) ⇒ Object
- #visit_prop(node) ⇒ Object
- #visit_variable(node) ⇒ Object
Methods included from SCSSLint::LinterRegistry
extract_linters_from, included
Methods inherited from SCSSLint::Linter
inherited, #initialize, #name, #run
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
This class inherits a constructor from SCSSLint::Linter
Instance Method Details
#visit_extend(node) ⇒ Object
6 7 8 |
# File 'lib/scss_lint/linter/trailing_semicolon.rb', line 6 def visit_extend(node) check_semicolon(node) end |
#visit_import(node) ⇒ Object
46 47 48 49 50 |
# File 'lib/scss_lint/linter/trailing_semicolon.rb', line 46 def visit_import(node) # Ignore all but the last import for comma-separated @imports return if source_from_range(node.source_range).match?(/,\s*$/) check_semicolon(node) end |
#visit_mixin(node) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/scss_lint/linter/trailing_semicolon.rb', line 38 def visit_mixin(node) if node.children.any? yield # Continue checking children else check_semicolon(node) end end |
#visit_prop(node) ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/scss_lint/linter/trailing_semicolon.rb', line 30 def visit_prop(node) if node.children.any? { |n| n.is_a?(Sass::Tree::PropNode) } yield # Continue checking children else check_semicolon(node) end end |
#visit_variable(node) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/scss_lint/linter/trailing_semicolon.rb', line 10 def visit_variable(node) # If the variable is using `!default` or `!global` (e.g. `$foo: bar # !default;`) then `node.expr` will give us the source range just for the # value (e.g. `bar`). In these cases, we want to use the source range of # `node`, which will give us most of the entire line (e.g. `foo: bar # !default`. return check_semicolon(node) if node.global || node.guarded # If the variable is a multi-line ListLiteral or MapLiteral, then # `node.expr` will give us everything except the last right paren, and # the semicolon if it exists. In these cases, use the source range of # `node` as above. if node.expr.is_a?(Sass::Script::Tree::ListLiteral) || node.expr.is_a?(Sass::Script::Tree::MapLiteral) return check_semicolon(node) end check_semicolon(node.expr) end |