Sha256: 1a88570c8f3e3885a61d3a8c6448c7c5c0e80b60ceca2bad7f566053b86aa999
Contents?: true
Size: 869 Bytes
Versions: 13
Compression:
Stored size: 869 Bytes
Contents
module SCSSLint # Checks for unnecessary leading zeros in numeric values with decimal points. class Linter::LeadingZero < Linter include LinterRegistry def visit_script_string(node) return unless node.type == :identifier non_string_values = remove_quoted_strings(node.value).split non_string_values.each do |value| if number = value[/\b(0\.\d+)/, 1] add_leading_zero_lint(node, number) end end end def visit_script_number(node) if node.original_string =~ /^0\./ add_leading_zero_lint(node, node.original_string) end end private def add_leading_zero_lint(node, number) trimmed_number = number[/^[^\.]+(.*)$/, 1] add_lint(node, "`#{number}` should be written without a leading zero " << "as `#{trimmed_number}`") end end end
Version data entries
13 entries across 13 versions & 1 rubygems