Sha256: 6553e04e57280a4ab03f9966e9ea2c934c8ef69fc3b081eaad8cd31525b41d0a
Contents?: true
Size: 937 Bytes
Versions: 3
Compression:
Stored size: 937 Bytes
Contents
module SCSSLint # Checks the order of nested items within a rule set. class Linter::DeclarationOrder < Linter include LinterRegistry DECLARATION_ORDER = [ Sass::Tree::ExtendNode, Sass::Tree::PropNode, Sass::Tree::RuleNode, ] def visit_rule(node) children = node.children.select { |node| important_node?(node) }. map { |node| node.class } sorted_children = children.sort do |a, b| DECLARATION_ORDER.index(a) <=> DECLARATION_ORDER.index(b) end if children != sorted_children add_lint(node.children.first) end yield # Continue linting children end def description 'Rule sets should start with @extend declarations, followed by ' << 'properties and nested rule sets, in that order' end private def important_node?(node) DECLARATION_ORDER.include? node.class end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
scss-lint-0.13.0 | lib/scss_lint/linter/declaration_order.rb |
scss-lint-0.12.1 | lib/scss_lint/linter/declaration_order.rb |
scss-lint-0.12.0 | lib/scss_lint/linter/declaration_order.rb |