Sha256: c8a6431c87e26c183bd5ade09c449e914165324f6a17f76437b257d662d56c10

Contents?: true

Size: 894 Bytes

Versions: 19

Compression:

Stored size: 894 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

19 entries across 19 versions & 1 rubygems

Version Path
scss-lint-0.22.0 lib/scss_lint/linter/capitalization_in_selector.rb
scss-lint-0.21.0 lib/scss_lint/linter/capitalization_in_selector.rb
scss-lint-0.20.3 lib/scss_lint/linter/capitalization_in_selector.rb
scss-lint-0.20.2 lib/scss_lint/linter/capitalization_in_selector.rb
scss-lint-0.20.1 lib/scss_lint/linter/capitalization_in_selector.rb
scss-lint-0.20.0 lib/scss_lint/linter/capitalization_in_selector.rb
scss-lint-0.19.0 lib/scss_lint/linter/capitalization_in_selector.rb
scss-lint-0.18.0 lib/scss_lint/linter/capitalization_in_selector.rb
scss-lint-0.17.3 lib/scss_lint/linter/capitalization_in_selector.rb
scss-lint-0.17.2 lib/scss_lint/linter/capitalization_in_selector.rb
scss-lint-0.17.1 lib/scss_lint/linter/capitalization_in_selector.rb
scss-lint-0.17.0 lib/scss_lint/linter/capitalization_in_selector.rb
scss-lint-0.16.1 lib/scss_lint/linter/capitalization_in_selector.rb
scss-lint-0.16.0 lib/scss_lint/linter/capitalization_in_selector.rb
scss-lint-0.15.0 lib/scss_lint/linter/capitalization_in_selector.rb
scss-lint-0.14.0 lib/scss_lint/linter/capitalization_in_selector.rb
scss-lint-0.13.0 lib/scss_lint/linter/capitalization_in_selector.rb
scss-lint-0.12.1 lib/scss_lint/linter/capitalization_in_selector.rb
scss-lint-0.12.0 lib/scss_lint/linter/capitalization_in_selector.rb