class SCSSLint::Linter::VariableForProperty

Reports the use of literals for properties where variables are prefered.

Constants

IGNORED_VALUES

Public Instance Methods

visit_prop(node) click to toggle source
# File lib/scss_lint/linter/variable_for_property.rb, line 13
def visit_prop(node)
  property_name = node.name.join
  return unless @properties.include?(property_name)
  return if ignored_value?(node.value)
  return if node.children.first.is_a?(Sass::Script::Tree::Variable)

  add_lint(node, "Property #{property_name} should use " \
                 'a variable rather than a literal value')
end
visit_root(_node) { || ... } click to toggle source
# File lib/scss_lint/linter/variable_for_property.rb, line 8
def visit_root(_node)
  @properties = Set.new(config['properties'])
  yield if @properties.any?
end

Private Instance Methods

ignored_value?(value) click to toggle source
# File lib/scss_lint/linter/variable_for_property.rb, line 25
def ignored_value?(value)
  value.respond_to?(:value) &&
    IGNORED_VALUES.include?(value.value.to_s)
end