Sha256: 03cfe8a94540187e9211b7e59e87e7ada4455a510124cef3ec9771ec075727d5

Contents?: true

Size: 708 Bytes

Versions: 23

Compression:

Stored size: 708 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

23 entries across 23 versions & 3 rubygems

Version Path
scss_lint-0.43.2 lib/scss_lint/linter/url_quotes.rb
scss_lint-0.43.1 lib/scss_lint/linter/url_quotes.rb
scss_lint-0.43.0 lib/scss_lint/linter/url_quotes.rb
scss_lint-0.42.2 lib/scss_lint/linter/url_quotes.rb
scss_lint-0.42.1 lib/scss_lint/linter/url_quotes.rb
scss_lint-0.42.0 lib/scss_lint/linter/url_quotes.rb
scss_lint-0.41.0 lib/scss_lint/linter/url_quotes.rb
scss_lint-0.40.1 lib/scss_lint/linter/url_quotes.rb
scss_lint-0.40.0 lib/scss_lint/linter/url_quotes.rb
scss_lint-0.39.0 lib/scss_lint/linter/url_quotes.rb
scss_lint-0.38.0 lib/scss_lint/linter/url_quotes.rb
scss-lint-0.38.0 lib/scss_lint/linter/url_quotes.rb
scss-lint-bliss-1.0.0 lib/scss_lint/linter/url_quotes.rb
scss-lint-0.37.0 lib/scss_lint/linter/url_quotes.rb
scss-lint-0.36.1 lib/scss_lint/linter/url_quotes.rb
scss-lint-0.36.0 lib/scss_lint/linter/url_quotes.rb
scss-lint-0.35.0 lib/scss_lint/linter/url_quotes.rb
scss-lint-0.34.0 lib/scss_lint/linter/url_quotes.rb
scss-lint-0.33.0 lib/scss_lint/linter/url_quotes.rb
scss-lint-0.32.0 lib/scss_lint/linter/url_quotes.rb