Sha256: da9c4afc74d7753a6279e7cc967525222954376d2a59b9edaa674594842bfb1b

Contents?: true

Size: 810 Bytes

Versions: 37

Compression:

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

      # Ignore if this is a placeholder
      return if selector.start_with?('%')

      add_lint(node, 'Prefer using placeholder selectors (e.g. ' \
                     '%some-placeholder) with @extend')
    end
  end
end

Version data entries

37 entries across 37 versions & 3 rubygems

Version Path
scss_lint-0.49.0 lib/scss_lint/linter/placeholder_in_extend.rb
scss_lint-0.48.0 lib/scss_lint/linter/placeholder_in_extend.rb
scss_lint-0.47.1 lib/scss_lint/linter/placeholder_in_extend.rb
scss_lint-0.47.0 lib/scss_lint/linter/placeholder_in_extend.rb
scss_lint-0.46.0 lib/scss_lint/linter/placeholder_in_extend.rb
scss_lint-0.45.0 lib/scss_lint/linter/placeholder_in_extend.rb
scss_lint-0.44.0 lib/scss_lint/linter/placeholder_in_extend.rb
scss_lint-0.43.2 lib/scss_lint/linter/placeholder_in_extend.rb
scss_lint-0.43.1 lib/scss_lint/linter/placeholder_in_extend.rb
scss_lint-0.43.0 lib/scss_lint/linter/placeholder_in_extend.rb
scss_lint-0.42.2 lib/scss_lint/linter/placeholder_in_extend.rb
scss_lint-0.42.1 lib/scss_lint/linter/placeholder_in_extend.rb
scss_lint-0.42.0 lib/scss_lint/linter/placeholder_in_extend.rb
scss_lint-0.41.0 lib/scss_lint/linter/placeholder_in_extend.rb
scss_lint-0.40.1 lib/scss_lint/linter/placeholder_in_extend.rb
scss_lint-0.40.0 lib/scss_lint/linter/placeholder_in_extend.rb
scss_lint-0.39.0 lib/scss_lint/linter/placeholder_in_extend.rb
scss_lint-0.38.0 lib/scss_lint/linter/placeholder_in_extend.rb
scss-lint-0.38.0 lib/scss_lint/linter/placeholder_in_extend.rb
scss-lint-bliss-1.0.0 lib/scss_lint/linter/placeholder_in_extend.rb