Sha256: 95e60b027e6f7a10ee3ca7153e70e684d11031502a52005be110a3a88067b0c9

Contents?: true

Size: 982 Bytes

Versions: 1

Compression:

Stored size: 982 Bytes

Contents

require 'sass'
require 'set'

module SCSSLint
  class Linter::DuplicateSelectorLinter < Linter
    include LinterRegistry

    class << self
      def run(engine)
        lints = []
        engine.tree.each do |node|
          if node.is_a?(Sass::Tree::RuleNode)
            lints << check_selector_already_used(node)
          end
        end
        lints.compact
      end

      def description
        'Rule was declared with same selector as another--you should merge them'
      end

    private

      def check_selector_already_used(rule_node)
        #selectors_seen = Set.new

        puts rule_node.rule.inspect
        puts rule_node.resolved_rules

        #rule_node.children.each do |child|
          #selectors = child.rule.first.to_s.gsub(/\s/, '')

          #if selectors_seen.member?(selectors)
            #return create_lint(child)
          #else
            #selectors_seen.add selectors
          #end
        #end

        nil
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
scss-lint-0.5 lib/scss_lint/linter/duplicate_selector_linter.rb