Sha256: 8ec789355b97db0d61af3b8f74736d273f1ebc6c967b130b7f81b32b18c7f27d

Contents?: true

Size: 561 Bytes

Versions: 5

Compression:

Stored size: 561 Bytes

Contents

require 'sass'

module SCSSLint
  class Linter::SortedPropertiesLinter < Linter
    include LinterRegistry

    def visit_rule(node)
      properties = node.children.select do |child|
        child.is_a?(Sass::Tree::PropNode)
      end

      prop_names = properties.map do |prop_node|
        prop_node.name.first.to_s
      end

      if prop_names.sort != prop_names
        add_lint(properties.first)
      end

      yield # Continue linting children
    end

    def description
      'Properties should be sorted in alphabetical order'
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
scss-lint-0.7.1 lib/scss_lint/linter/sorted_properties_linter.rb
scss-lint-0.7.0 lib/scss_lint/linter/sorted_properties_linter.rb
scss-lint-0.6.7 lib/scss_lint/linter/sorted_properties_linter.rb
scss-lint-0.6.6 lib/scss_lint/linter/sorted_properties_linter.rb
scss-lint-0.6.5 lib/scss_lint/linter/sorted_properties_linter.rb