gems.scss_lint-0.57.0.lib.scss_lint.linter.hex_validation.rb Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sass-maven-plugin Show documentation
Show all versions of sass-maven-plugin Show documentation
A Maven Plugin that compiles Sass files.
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(/(?:\W|^)(#\h+)(?:\W|$)/) 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
© 2015 - 2025 Weber Informatics LLC | Privacy Policy