Sha256: 31a3360c532555439e71ca83e0a7491f3bf28d34d331ceeafa5c290b6e32a721

Contents?: true

Size: 893 Bytes

Versions: 2

Compression:

Stored size: 893 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
      if 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
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
scss-lint-0.23.1 lib/scss_lint/linter/capitalization_in_selector.rb
scss-lint-0.23.0 lib/scss_lint/linter/capitalization_in_selector.rb