Class: SCSSLint::Linter::PropertySortOrder
- Inherits:
-
SCSSLint::Linter
- Object
- Sass::Tree::Visitors::Base
- SCSSLint::Linter
- SCSSLint::Linter::PropertySortOrder
- Includes:
- SCSSLint::LinterRegistry
- Defined in:
- lib/scss_lint/linter/property_sort_order.rb
Overview
Checks the declaration order of properties.
Constant Summary
Constants included from Utils
Instance Attribute Summary
Attributes inherited from SCSSLint::Linter
Instance Method Summary collapse
- #check_order(node) ⇒ Object (also: #visit_media, #visit_mixin, #visit_rule, #visit_prop)
- #visit_if(node, &block) ⇒ Object
- #visit_root(_node) ⇒ Object
Methods included from SCSSLint::LinterRegistry
extract_linters_from, included
Methods inherited from SCSSLint::Linter
Methods included from Utils
#color?, #color_hex?, #color_keyword?, #color_keyword_to_code, #extract_string_selectors, #node_ancestor, #node_siblings, #pluralize, #previous_node, #remove_quoted_strings, #same_position?
Methods included from SelectorVisitor
Constructor Details
This class inherits a constructor from SCSSLint::Linter
Instance Method Details
#check_order(node) ⇒ Object Also known as: visit_media, visit_mixin, visit_rule, visit_prop
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/scss_lint/linter/property_sort_order.rb', line 16 def check_order(node) sortable_props = node.children.select do |child| child.is_a?(Sass::Tree::PropNode) && !ignore_property?(child) end if sortable_props.count >= config.fetch('min_properties', 2) sortable_prop_info = sortable_props .map do |child| name = child.name.join /^(?<vendor>-\w+(-osx)?-)?(?<property>.+)/ =~ name { name: name, vendor: vendor, property: "#{@nested_under}#{property}", node: child } end check_sort_order(sortable_prop_info) check_group_separation(sortable_prop_info) if @group end yield # Continue linting children end |
#visit_if(node, &block) ⇒ Object
49 50 51 52 |
# File 'lib/scss_lint/linter/property_sort_order.rb', line 49 def visit_if(node, &block) check_order(node, &block) visit(node.else) if node.else end |
#visit_root(_node) ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/scss_lint/linter/property_sort_order.rb', line 6 def visit_root(_node) @preferred_order = extract_preferred_order_from_config if @preferred_order && config['separate_groups'] @group = assign_groups(@preferred_order) end yield # Continue linting children end |