Class: SCSSLint::Linter::PropertySpelling

Inherits:
SCSSLint::Linter
  • Object
show all
Includes:
SCSSLint::LinterRegistry
Defined in:
lib/scss_lint/linter/property_spelling.rb

Overview

Checks for misspelled properties.

Constant Summary collapse

KNOWN_PROPERTIES =
File.open(File.join(SCSS_LINT_DATA, 'properties.txt'))
.read
.split
.to_set

Constants included from Utils

Utils::COLOR_REGEX

Instance Attribute Summary

Attributes inherited from SCSSLint::Linter

#config, #engine, #lints

Instance Method Summary collapse

Methods included from SCSSLint::LinterRegistry

extract_linters_from, included

Methods inherited from SCSSLint::Linter

inherited, #initialize, #name, #run

Methods included from Utils

#color?, #color_hex?, #color_keyword?, #color_keyword_to_code, #else_node?, #extract_string_selectors, #node_ancestor, #node_siblings, #pluralize, #previous_node, #remove_quoted_strings, #same_position?

Methods included from SelectorVisitor

#visit_selector

Constructor Details

This class inherits a constructor from SCSSLint::Linter

Instance Method Details

#visit_prop(node) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/scss_lint/linter/property_spelling.rb', line 18

def visit_prop(node)
  # Ignore properties with interpolation
  return if node.name.count > 1 || !node.name.first.is_a?(String)

  nested_properties = node.children.select { |child| child.is_a?(Sass::Tree::PropNode) }
  if nested_properties.any?
    # Treat nested properties specially, as they are a concatenation of the
    # parent with child property
    nested_properties.each do |nested_prop|
      check_property(nested_prop, node.name.join)
    end
  else
    check_property(node)
  end
end

#visit_root(_node) ⇒ Object



11
12
13
14
15
16
# File 'lib/scss_lint/linter/property_spelling.rb', line 11

def visit_root(_node)
  @extra_properties = Array(config['extra_properties']).to_set
  @disabled_properties = Array(config['disabled_properties']).to_set

  yield # Continue linting children
end