Sha256: 066af6e22f27ad72cd5f739669e8f9d4113a6056a5275055ea44d52ca33f07aa

Contents?: true

Size: 667 Bytes

Versions: 2

Compression:

Stored size: 667 Bytes

Contents

module SCSSLint
  # Checks for a selector with an ID combined with some other selector.
  class Linter::IdWithExtraneousSelector < Linter
    include LinterRegistry

    def visit_simple_sequence(seq)
      id_sel = seq.members.find { |simple| simple.is_a?(Sass::Selector::Id) }
      return unless id_sel

      can_be_simplified = seq.members.any? do |simple|
        !simple.is_a?(Sass::Selector::Id) &&
          !simple.is_a?(Sass::Selector::Pseudo)
      end

      if can_be_simplified
        add_lint(seq, "Selector `#{seq}` can be simplified to `#{id_sel}`, " <<
                      'since IDs should be uniquely identifying')
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
scss-lint-0.22.0 lib/scss_lint/linter/id_with_extraneous_selector.rb
scss-lint-0.21.0 lib/scss_lint/linter/id_with_extraneous_selector.rb