Sha256: 6eeb6d363eeee4abebd27212b19d7bdecee11b3fa97540a12764955b8f2dbd36

Contents?: true

Size: 741 Bytes

Versions: 22

Compression:

Stored size: 741 Bytes

Contents

module SCSSLint
  # Checks for uses of chained classes (e.g. .foo.bar).
  class Linter::ChainedClasses < Linter
    include LinterRegistry

    def visit_sequence(sequence)
      line_offset = 0
      sequence.members.each do |member|
        line_offset += 1 if member =~ /\n/
        next unless chained_class?(member)
        add_lint(member.line + line_offset,
                 'Prefer using a distinct class over chained classes ' \
                 '(e.g. .new-class over .foo.bar')
      end
    end

  private

    def chained_class?(simple_sequence)
      return unless simple_sequence.is_a?(Sass::Selector::SimpleSequence)
      simple_sequence.members.count { |member| member.is_a?(Sass::Selector::Class) } >= 2
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
scss_lint-0.59.0 lib/scss_lint/linter/chained_classes.rb
scss_lint-0.58.0 lib/scss_lint/linter/chained_classes.rb
scss_lint-0.57.1 lib/scss_lint/linter/chained_classes.rb
scss_lint-0.57.0 lib/scss_lint/linter/chained_classes.rb
scss_lint-0.56.0 lib/scss_lint/linter/chained_classes.rb
scss_lint-0.55.0 lib/scss_lint/linter/chained_classes.rb
scss_lint-0.54.0 lib/scss_lint/linter/chained_classes.rb
scss_lint-0.53.0 lib/scss_lint/linter/chained_classes.rb
scss_lint-0.52.0 lib/scss_lint/linter/chained_classes.rb
scss_lint-0.51.0 lib/scss_lint/linter/chained_classes.rb
scss_lint-0.50.3 lib/scss_lint/linter/chained_classes.rb
scss_lint-0.50.2 lib/scss_lint/linter/chained_classes.rb
scss_lint-0.50.1 lib/scss_lint/linter/chained_classes.rb
scss_lint-0.50.0 lib/scss_lint/linter/chained_classes.rb
scss_lint-0.49.0 lib/scss_lint/linter/chained_classes.rb
scss_lint-0.48.0 lib/scss_lint/linter/chained_classes.rb
scss_lint-0.47.1 lib/scss_lint/linter/chained_classes.rb
scss_lint-0.47.0 lib/scss_lint/linter/chained_classes.rb
scss_lint-0.46.0 lib/scss_lint/linter/chained_classes.rb
scss_lint-0.45.0 lib/scss_lint/linter/chained_classes.rb