Class: SCSSLint::Linter::BorderZero

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

Overview

Enforce a particular value for empty borders.

Constant Summary collapse

CONVENTION_TO_PREFERENCE =
{
  'zero' => %w[0 none],
  'none' => %w[none 0],
}.freeze
BORDER_PROPERTIES =
%w[
  border
  border-top
  border-right
  border-bottom
  border-left
].freeze

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



28
29
30
31
# File 'lib/scss_lint/linter/border_zero.rb', line 28

def visit_prop(node)
  return unless BORDER_PROPERTIES.include?(node.name.first.to_s)
  check_border(node, node.name.first.to_s, node.value.first.to_sass.strip)
end

#visit_root(_node) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/scss_lint/linter/border_zero.rb', line 19

def visit_root(_node)
  @preference = CONVENTION_TO_PREFERENCE[config['convention'].to_s]
  unless @preference
    raise "Invalid `convention` specified: #{config['convention']}." \
          "Must be one of [#{CONVENTION_TO_PREFERENCE.keys.join(', ')}]"
  end
  yield # Continue linting children
end