class SCSSLint::Linter::BorderZero

Enforce a particular value for empty borders.

Constants

BORDER_PROPERTIES
CONVENTION_TO_PREFERENCE

Public Instance Methods

visit_prop(node) click to toggle source
# File lib/scss_lint/linter/border_zero.rb, line 24
def visit_prop(node)
  return unless BORDER_PROPERTIES.include?(node.name.first.to_s)
  check_border(node, node.value.to_sass.strip)
end
visit_root(_node) { || ... } click to toggle source
# File lib/scss_lint/linter/border_zero.rb, line 19
def visit_root(_node)
  @preference = CONVENTION_TO_PREFERENCE[config['convention']]
  yield # Continue linting children
end

Private Instance Methods

check_border(node, border) click to toggle source
# File lib/scss_lint/linter/border_zero.rb, line 31
def check_border(node, border)
  return unless %w[0 none].include?(border)
  return if @preference[0] == border

  add_lint(node, "`border: #{@preference[0]} is preferred over " \
                 "`border: #{@preference[1]}`")
end