gems.scss_lint-0.57.1.lib.scss_lint.linter.url_quotes.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.
The newest version!
module SCSSLint
# Checks for quotes in URLs.
class Linter::UrlQuotes < Linter
include LinterRegistry
def visit_prop(node)
case node.value.first
when Sass::Script::Tree::Literal
check(node, node.value.first.value.to_s)
when Sass::Script::Tree::ListLiteral
node.value.first
.children
.select { |child| child.is_a?(Sass::Script::Tree::Literal) }
.each { |child| check(node, child.value.to_s) }
end
yield
end
private
def check(node, string)
return unless string =~ /^\s*url\(\s*[^"']/
return if string =~ /^\s*url\(\s*data:/ # Ignore data URIs
add_lint(node, 'URLs should be enclosed in quotes')
end
end
end