Sha256: 63bcd19a61980fb2e1ae59b68e365c33af2a4851f0c7e34107fdd8c24520a5c2

Contents?: true

Size: 816 Bytes

Versions: 3

Compression:

Stored size: 816 Bytes

Contents

module SCSSLint
  # Checks that selector sequences are split over multiple lines by comma.
  class Linter::SingleLinePerSelector < Linter
    include LinterRegistry

    MESSAGE = 'Each selector in a comma sequence should be on its own line'

    def visit_comma_sequence(node)
      return unless node.members.count > 1

      if node.members[0].members[1] == "\n"
        # Comma is on its own line
        add_lint(node, MESSAGE)
      end

      node.members[1..-1].each_with_index do |sequence, index|
        if sequence.members[0] != "\n"
          # Next sequence doesn't reside on its own line
          add_lint(node.line + index, MESSAGE)
        elsif sequence.members[1] == "\n"
          # Comma is on its own line
          add_lint(node.line + index, MESSAGE)
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
scss-lint-0.30.0 lib/scss_lint/linter/single_line_per_selector.rb
scss-lint-0.29.0 lib/scss_lint/linter/single_line_per_selector.rb
scss-lint-0.28.0 lib/scss_lint/linter/single_line_per_selector.rb