Sha256: 677aef0ecb6bc37e09c1a142d7c03c73e5f9bc9add623d05053c38878d6422b6

Contents?: true

Size: 889 Bytes

Versions: 4

Compression:

Stored size: 889 Bytes

Contents

module SCSSLint
  # Checks for capitalized letters in IDs, classes, types, etc. in selectors.
  class Linter::CapitalizationInSelector < Linter
    include LinterRegistry

    def visit_attribute(attribute)
      check(attribute)
    end

    def visit_class(klass)
      check(klass)
    end

    def visit_element(element)
      check(element)
    end

    def visit_id(id)
      check(id)
    end

    def visit_placeholder(placeholder)
      check(placeholder)
    end

    def visit_pseudo(pseudo)
      check(pseudo, 'Pseudo-selector')
    end

  private

    def check(node, selector_name = nil)
      name = node.name.join
      return unless name =~ /[A-Z]/

      selector_name ||= node.class.name.split('::').last
      add_lint(node, "#{selector_name} `#{name}` in selector should be " \
                     "written in all lowercase as `#{name.downcase}`")
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
scss-lint-0.25.1 lib/scss_lint/linter/capitalization_in_selector.rb
scss-lint-0.25.0 lib/scss_lint/linter/capitalization_in_selector.rb
scss-lint-0.24.1 lib/scss_lint/linter/capitalization_in_selector.rb
scss-lint-0.24.0 lib/scss_lint/linter/capitalization_in_selector.rb