Sha256: 17a5305b39c12788709f2af152bf59f7d9d9e4a6469c23e7ae836030c955837e

Contents?: true

Size: 976 Bytes

Versions: 15

Compression:

Stored size: 976 Bytes

Contents

module SCSSLint
  # Checks that `@extend` is always used with a placeholder selector.
  class Linter::PlaceholderInExtend < Linter
    include LinterRegistry

    def visit_extend(node)
      # Ignore if it cannot be statically determined that this selector is a
      # placeholder since its prefix is dynamically generated
      return if node.selector.first.is_a?(Sass::Script::Tree::Node)

      # The array returned by the parser is a bit awkward in that it splits on
      # every word boundary (so %placeholder becomes ['%', 'placeholder']).
      selector = node.selector.join

      if selector.include?(',')
        add_lint(node, 'Avoid comma sequences in `@extend` directives; ' \
                       'prefer single placeholder selectors (e.g. `%some-placeholder`)')
      elsif !selector.start_with?('%')
        add_lint(node, 'Prefer using placeholder selectors (e.g. ' \
                       '%some-placeholder) with @extend')
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
scss_lint-0.60.0 lib/scss_lint/linter/placeholder_in_extend.rb
scss_lint-0.59.0 lib/scss_lint/linter/placeholder_in_extend.rb
scss_lint-0.58.0 lib/scss_lint/linter/placeholder_in_extend.rb
scss_lint-0.57.1 lib/scss_lint/linter/placeholder_in_extend.rb
scss_lint-0.57.0 lib/scss_lint/linter/placeholder_in_extend.rb
scss_lint-0.56.0 lib/scss_lint/linter/placeholder_in_extend.rb
scss_lint-0.55.0 lib/scss_lint/linter/placeholder_in_extend.rb
scss_lint-0.54.0 lib/scss_lint/linter/placeholder_in_extend.rb
scss_lint-0.53.0 lib/scss_lint/linter/placeholder_in_extend.rb
scss_lint-0.52.0 lib/scss_lint/linter/placeholder_in_extend.rb
scss_lint-0.51.0 lib/scss_lint/linter/placeholder_in_extend.rb
scss_lint-0.50.3 lib/scss_lint/linter/placeholder_in_extend.rb
scss_lint-0.50.2 lib/scss_lint/linter/placeholder_in_extend.rb
scss_lint-0.50.1 lib/scss_lint/linter/placeholder_in_extend.rb
scss_lint-0.50.0 lib/scss_lint/linter/placeholder_in_extend.rb