Sha256: fedf91bf3b5f77f1cc19cc9f0f62d3467afa76945ac8570f0bb11356fc4766b2
Contents?: true
Size: 881 Bytes
Versions: 4
Compression:
Stored size: 881 Bytes
Contents
module SCSSLint 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
4 entries across 4 versions & 1 rubygems