Sha256: 69a271c7289881900c6f60d9b6073b8620add100c8deea03053429b01e8664a6

Contents?: true

Size: 622 Bytes

Versions: 2

Compression:

Stored size: 622 Bytes

Contents

module SCSSLint
  class Linter::ZeroUnit < Linter
    include LinterRegistry

    def visit_prop(node)
      if node.value.is_a?(Sass::Script::String) &&
         node.value.type == :identifier

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

      yield # Continue visiting children
    end

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

  private

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
scss-lint-0.10.1 lib/scss_lint/linter/zero_unit.rb
scss-lint-0.10.0 lib/scss_lint/linter/zero_unit.rb