Sha256: b69ec181ead8f8e2ca5335509ebd0070d7ef66a27ef26d42bb463b4f0b95afe9

Contents?: true

Size: 531 Bytes

Versions: 12

Compression:

Stored size: 531 Bytes

Contents

module SCSSLint
  # Checks for unnecessary units on zero values.
  class Linter::ZeroUnit < Linter
    include LinterRegistry

    def visit_script_string(node)
      node.value.scan(/\b(0[a-z]+)\b/i) do |match|
        add_lint(node, MESSAGE_FORMAT % match.first)
      end
    end

    def visit_script_number(node)
      if node.value == 0 && !node.unitless?
        add_lint(node, MESSAGE_FORMAT % node.original_string)
      end
    end

  private

    MESSAGE_FORMAT = '`%s` should be written without units as `0`'
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
scss-lint-0.18.0 lib/scss_lint/linter/zero_unit.rb
scss-lint-0.17.3 lib/scss_lint/linter/zero_unit.rb
scss-lint-0.17.2 lib/scss_lint/linter/zero_unit.rb
scss-lint-0.17.1 lib/scss_lint/linter/zero_unit.rb
scss-lint-0.17.0 lib/scss_lint/linter/zero_unit.rb
scss-lint-0.16.1 lib/scss_lint/linter/zero_unit.rb
scss-lint-0.16.0 lib/scss_lint/linter/zero_unit.rb
scss-lint-0.15.0 lib/scss_lint/linter/zero_unit.rb
scss-lint-0.14.0 lib/scss_lint/linter/zero_unit.rb
scss-lint-0.13.0 lib/scss_lint/linter/zero_unit.rb
scss-lint-0.12.1 lib/scss_lint/linter/zero_unit.rb
scss-lint-0.12.0 lib/scss_lint/linter/zero_unit.rb