Sha256: 69a4d30adc69ba6271ffeecd6d9c7f0dadc8d168a9cb1b84fd92e763304072b3

Contents?: true

Size: 617 Bytes

Versions: 5

Compression:

Stored size: 617 Bytes

Contents

module SCSSLint
  # Reports the use of literals for properties where variables are prefered.
  class Linter::VariableForProperty < Linter
    include LinterRegistry

    def visit_root(_node)
      @properties = Set.new(config['properties'])
      yield if @properties.any?
    end

    def visit_prop(node)
      property_name = node.name.join
      return unless @properties.include? property_name
      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
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
scss-lint-0.37.0 lib/scss_lint/linter/variable_for_property.rb
scss-lint-0.36.1 lib/scss_lint/linter/variable_for_property.rb
scss-lint-0.36.0 lib/scss_lint/linter/variable_for_property.rb
scss-lint-0.35.0 lib/scss_lint/linter/variable_for_property.rb
scss-lint-0.34.0 lib/scss_lint/linter/variable_for_property.rb