Sha256: d600f6b345acdcc0eba21eb374143ad4914cd24613b482a28b09c3ddb8b09b8f

Contents?: true

Size: 643 Bytes

Versions: 14

Compression:

Stored size: 643 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)
      if string =~ /^\s*url\(\s*[^"']/
        add_lint(node, 'URLs should be enclosed in quotes')
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
scss-lint-0.23.1 lib/scss_lint/linter/url_quotes.rb
scss-lint-0.23.0 lib/scss_lint/linter/url_quotes.rb
scss-lint-0.22.0 lib/scss_lint/linter/url_quotes.rb
scss-lint-0.21.0 lib/scss_lint/linter/url_quotes.rb
scss-lint-0.20.3 lib/scss_lint/linter/url_quotes.rb
scss-lint-0.20.2 lib/scss_lint/linter/url_quotes.rb
scss-lint-0.20.1 lib/scss_lint/linter/url_quotes.rb
scss-lint-0.20.0 lib/scss_lint/linter/url_quotes.rb
scss-lint-0.19.0 lib/scss_lint/linter/url_quotes.rb
scss-lint-0.18.0 lib/scss_lint/linter/url_quotes.rb
scss-lint-0.17.3 lib/scss_lint/linter/url_quotes.rb
scss-lint-0.17.2 lib/scss_lint/linter/url_quotes.rb
scss-lint-0.17.1 lib/scss_lint/linter/url_quotes.rb
scss-lint-0.17.0 lib/scss_lint/linter/url_quotes.rb