Sha256: 27ce7a87eeb9e3e807e04f06769106d87e3b46c56f5c4444fd34e60d8c289e59
Contents?: true
Size: 870 Bytes
Versions: 3
Compression:
Stored size: 870 Bytes
Contents
module SCSSLint # Checks if hexadecimal colors are written lowercase / uppercase. class Linter::HexNotation < Linter include LinterRegistry HEX_REGEX = /(#(\h{3}|\h{6}))(?!\h)/.freeze def visit_script_color(node) return unless hex = source_from_range(node.source_range)[HEX_REGEX, 1] check_hex(hex, node) end def visit_script_string(node) return unless node.type == :identifier node.value.scan(HEX_REGEX) do |match| check_hex(match.first, node) end end private def check_hex(hex, node) return if expected(hex) == hex add_lint(node, "Color `#{hex}` should be written as `#{expected(hex)}`") end def expected(color) return color.downcase if lowercase_style? color.upcase end def lowercase_style? config['style'] == 'lowercase' end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
scss_lint-0.60.0 | lib/scss_lint/linter/hex_notation.rb |
scss_lint-0.59.0 | lib/scss_lint/linter/hex_notation.rb |
scss_lint-0.58.0 | lib/scss_lint/linter/hex_notation.rb |