class SCSSLint::Linter::ZeroUnit
Checks for unnecessary units on zero values.
Constants
- LENGTH_UNITS
- MESSAGE_FORMAT
- ZERO_UNIT_REGEX
Public Instance Methods
visit_script_number(node)
click to toggle source
# File lib/scss_lint/linter/zero_unit.rb, line 15 def visit_script_number(node) length = source_from_range(node.source_range)[ZERO_UNIT_REGEX, 1] return unless zero_with_length_units?(length) add_lint(node, MESSAGE_FORMAT % length) end
visit_script_string(node)
click to toggle source
# File lib/scss_lint/linter/zero_unit.rb, line 6 def visit_script_string(node) return unless node.type == :identifier node.value.scan(ZERO_UNIT_REGEX) do |match| next unless zero_with_length_units?(match.first) add_lint(node, MESSAGE_FORMAT % match.first) end end
Private Instance Methods
zero_with_length_units?(string)
click to toggle source
# File lib/scss_lint/linter/zero_unit.rb, line 35 def zero_with_length_units?(string) string =~ /^0([a-z]+)/ && LENGTH_UNITS.include?(Regexp.last_match(1)) end