Sha256: e06b1146917d57b71c01db3783ae771d01d6fc896e381c60076869a41f5c2e7f

Contents?: true

Size: 526 Bytes

Versions: 21

Compression:

Stored size: 526 Bytes

Contents

module SCSSLint
  # Checks for invalid hexadecimal colors.
  class Linter::HexValidation < Linter
    include LinterRegistry

    def visit_script_string(node)
      return unless node.type == :identifier

      node.value.scan(/(#\h+)/) do |match|
        check_hex(match.first, node)
      end
    end

  private

    HEX_REGEX = /(#(\h{3}|\h{6}|\h{8}))(?!\h)/

    def check_hex(hex, node)
      return if HEX_REGEX.match(hex)
      add_lint(node, "Colors must have either three or six digits: `#{hex}`")
    end
  end
end

Version data entries

21 entries across 21 versions & 3 rubygems

Version Path
scss_lint-0.42.1 lib/scss_lint/linter/hex_validation.rb
scss_lint-0.42.0 lib/scss_lint/linter/hex_validation.rb
scss_lint-0.41.0 lib/scss_lint/linter/hex_validation.rb
scss_lint-0.40.1 lib/scss_lint/linter/hex_validation.rb
scss_lint-0.40.0 lib/scss_lint/linter/hex_validation.rb
scss_lint-0.39.0 lib/scss_lint/linter/hex_validation.rb
scss_lint-0.38.0 lib/scss_lint/linter/hex_validation.rb
scss-lint-0.38.0 lib/scss_lint/linter/hex_validation.rb
scss-lint-bliss-1.0.0 lib/scss_lint/linter/hex_validation.rb
scss-lint-0.37.0 lib/scss_lint/linter/hex_validation.rb
scss-lint-0.36.1 lib/scss_lint/linter/hex_validation.rb
scss-lint-0.36.0 lib/scss_lint/linter/hex_validation.rb
scss-lint-0.35.0 lib/scss_lint/linter/hex_validation.rb
scss-lint-0.34.0 lib/scss_lint/linter/hex_validation.rb
scss-lint-0.33.0 lib/scss_lint/linter/hex_validation.rb
scss-lint-0.32.0 lib/scss_lint/linter/hex_validation.rb
scss-lint-0.31.0 lib/scss_lint/linter/hex_validation.rb
scss-lint-0.30.0 lib/scss_lint/linter/hex_validation.rb
scss-lint-0.29.0 lib/scss_lint/linter/hex_validation.rb
scss-lint-0.28.0 lib/scss_lint/linter/hex_validation.rb