Sha256: 833f138e76e274faf3d5e3012277169fb1a1d1be10ccb9f2b186812fa02fa0b4

Contents?: true

Size: 639 Bytes

Versions: 8

Compression:

Stored size: 639 Bytes

Contents

require 'sass'

module SCSSLint
  class Linter::ZeroUnitLinter < Linter
    include LinterRegistry

    class << self
      def run(engine)
        lints = []
        engine.tree.each do |node|
          if node.is_a?(Sass::Tree::PropNode)
            lints << check_zero_unit(node, engine.lines[node.line - 1]) if node.line
          end
        end
        lints.compact
      end

      def description
        'Properties with a value of zero should be unit-less'
      end

    private

      def check_zero_unit(prop_node, line)
        return create_lint(prop_node) if line =~ /^\s*[\w-]+:\s*0[a-z]+;$/i
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
scss-lint-0.6 lib/scss_lint/linter/zero_unit_linter.rb
scss-lint-0.5.2 lib/scss_lint/linter/zero_unit_linter.rb
scss-lint-0.5.1 lib/scss_lint/linter/zero_unit_linter.rb
scss-lint-0.5 lib/scss_lint/linter/zero_unit_linter.rb
scss-lint-0.4 lib/scss_lint/linter/zero_unit_linter.rb
scss-lint-0.3 lib/scss_lint/linter/zero_unit_linter.rb
scss-lint-0.2 lib/scss_lint/linter/zero_unit_linter.rb
scss-lint-0.1 lib/scss_lint/linter/zero_unit_linter.rb