Class: SCSSLint::Linter::LengthVariable
- Inherits:
-
SCSSLint::Linter
- Object
- Sass::Tree::Visitors::Base
- SCSSLint::Linter
- SCSSLint::Linter::LengthVariable
- Includes:
- SCSSLint::LinterRegistry
- Defined in:
- lib/scss_lint/linter/length_variable.rb
Overview
Ensures length literals are used only in variable declarations.
Constant Summary collapse
- LENGTH_UNITS =
[ 'ch', 'em', 'ex', 'rem', # Font-relative lengths 'cm', 'in', 'mm', 'pc', 'pt', 'px', 'q', # Absolute lengths 'vh', 'vw', 'vmin', 'vmax' # Viewport-percentage lengths ].freeze
- LENGTH_RE =
%r{ (?:^|[\s+\-/*()]) # math or space separated, or beginning of string ( # capture whole length 0 # unitless zero | [-+]? # optional sign (?: \.\d+ # with leading decimal, e.g. .5 | \d+(\.\d+)? # whole or maybe with trailing decimal ) (?:#{LENGTH_UNITS.join('|')}) # unit! ) (?:$|[\s+\-/*()]) # math or space separated, or end of string }x.freeze
Constants included from Utils
Instance Attribute Summary
Attributes inherited from SCSSLint::Linter
Instance Method Summary collapse
- #visit_media(node) ⇒ Object
- #visit_mixin(node) ⇒ Object
- #visit_mixindef(node) ⇒ Object
- #visit_prop(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_media(node) ⇒ Object
37 38 39 |
# File 'lib/scss_lint/linter/length_variable.rb', line 37 def visit_media(node) lint_lengths(node) end |
#visit_mixin(node) ⇒ Object
41 42 43 |
# File 'lib/scss_lint/linter/length_variable.rb', line 41 def visit_mixin(node) lint_lengths(node) end |
#visit_mixindef(node) ⇒ Object
33 34 35 |
# File 'lib/scss_lint/linter/length_variable.rb', line 33 def visit_mixindef(node) lint_lengths(node) end |
#visit_prop(node) ⇒ Object
28 29 30 31 |
# File 'lib/scss_lint/linter/length_variable.rb', line 28 def visit_prop(node) return if allowed_prop?(node) lint_lengths(node) end |