Sha256: b35977937865b0db68fae92f94c2c64d58702ae97905682ed08b7b1d840eb01a

Contents?: true

Size: 642 Bytes

Versions: 9

Compression:

Stored size: 642 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*[^"']/
      add_lint(node, 'URLs should be enclosed in quotes')
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
scss-lint-0.28.0 lib/scss_lint/linter/url_quotes.rb
scss-lint-0.27.0 lib/scss_lint/linter/url_quotes.rb
scss-lint-0.26.2 lib/scss_lint/linter/url_quotes.rb
scss-lint-0.26.1 lib/scss_lint/linter/url_quotes.rb
scss-lint-0.26.0 lib/scss_lint/linter/url_quotes.rb
scss-lint-0.25.1 lib/scss_lint/linter/url_quotes.rb
scss-lint-0.25.0 lib/scss_lint/linter/url_quotes.rb
scss-lint-0.24.1 lib/scss_lint/linter/url_quotes.rb
scss-lint-0.24.0 lib/scss_lint/linter/url_quotes.rb