Class: SCSSLint::Linter::UnnecessaryMantissa
- Inherits:
-
SCSSLint::Linter
- Object
- Sass::Tree::Visitors::Base
- SCSSLint::Linter
- SCSSLint::Linter::UnnecessaryMantissa
- Includes:
- SCSSLint::LinterRegistry
- Defined in:
- lib/scss_lint/linter/unnecessary_mantissa.rb
Overview
Checks for the unnecessary inclusion of a zero-value mantissa in numbers. (e.g. ‘4.0` could be written as just `4`)
Constant Summary
Constants included from Utils
Instance Attribute Summary
Attributes inherited from SCSSLint::Linter
Instance Method Summary collapse
Methods included from SCSSLint::LinterRegistry
extract_linters_from, included
Methods inherited from SCSSLint::Linter
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
Constructor Details
This class inherits a constructor from SCSSLint::Linter
Instance Method Details
#visit_script_number(node) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/scss_lint/linter/unnecessary_mantissa.rb', line 17 def visit_script_number(node) return unless match = REAL_NUMBER_REGEX.match(source_from_range(node.source_range)) return unless unnecessary_mantissa?(match[:mantissa]) add_lint(node, MESSAGE_FORMAT % [match[:number], match[:integer], match[:units]]) end |
#visit_script_string(node) ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/scss_lint/linter/unnecessary_mantissa.rb', line 7 def visit_script_string(node) return unless node.type == :identifier node.value.scan(REAL_NUMBER_REGEX) do |number, integer, mantissa, units| if unnecessary_mantissa?(mantissa) add_lint(node, MESSAGE_FORMAT % [number, integer, units]) end end end |