Sha256: 13cc4bc95742af0b785c9c611ee9005820dbcc116e9ba42c9500bd447c4a2ed1

Contents?: true

Size: 719 Bytes

Versions: 16

Compression:

Stored size: 719 Bytes

Contents

module SCSSLint
  # Checks for quotes in URLs.
  class Linter::UrlQuotes < Linter
    include LinterRegistry

    def visit_prop(node)
      case node.value
      when Sass::Script::Tree::Literal
        check(node, node.value.value.to_s)
      when Sass::Script::Tree::ListLiteral
        node.value
            .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

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
scss_lint-0.55.0 lib/scss_lint/linter/url_quotes.rb
scss_lint-0.54.0 lib/scss_lint/linter/url_quotes.rb
scss_lint-0.53.0 lib/scss_lint/linter/url_quotes.rb
scss_lint-0.52.0 lib/scss_lint/linter/url_quotes.rb
scss_lint-0.51.0 lib/scss_lint/linter/url_quotes.rb
scss_lint-0.50.3 lib/scss_lint/linter/url_quotes.rb
scss_lint-0.50.2 lib/scss_lint/linter/url_quotes.rb
scss_lint-0.50.1 lib/scss_lint/linter/url_quotes.rb
scss_lint-0.50.0 lib/scss_lint/linter/url_quotes.rb
scss_lint-0.49.0 lib/scss_lint/linter/url_quotes.rb
scss_lint-0.48.0 lib/scss_lint/linter/url_quotes.rb
scss_lint-0.47.1 lib/scss_lint/linter/url_quotes.rb
scss_lint-0.47.0 lib/scss_lint/linter/url_quotes.rb
scss_lint-0.46.0 lib/scss_lint/linter/url_quotes.rb
scss_lint-0.45.0 lib/scss_lint/linter/url_quotes.rb
scss_lint-0.44.0 lib/scss_lint/linter/url_quotes.rb