Class: SCSSLint::Linter::NameFormat

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

Overview

Checks the format of declared names of functions, mixins, and variables.

Constant Summary collapse

CSS_FUNCTION_WHITELIST =
%w[
  rotateX rotateY rotateZ
  scaleX scaleY scaleZ
  skewX skewY
  translateX translateY translateZ
  linear-gradient repeating-linear-gradient
  radial-gradient repeating-radial-gradient
  cubic-bezier
  fit-content
].to_set.freeze
SCSS_FUNCTION_WHITELIST =
%w[
  adjust-hue adjust-color scale-color change-color ie-hex-str
  str-length str-insert str-index str-slice to-upper-case to-lower-case
  list-separator
  map-get map-merge map-remove map-keys map-values map-has-key
  selector-nest selector-append selector-extend selector-replace
  selector-unify is-superselector simple-selectors selector-parse
  feature-exists variable-exists global-variable-exists function-exists
  mixin-exists type-of
  unique-id
].to_set.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_function(node) ⇒ Object



29
30
31
32
# File 'lib/scss_lint/linter/name_format.rb', line 29

def visit_function(node)
  check_name(node, 'function')
  yield # Continue into content block of this function definition
end

#visit_mixin(node) ⇒ Object



34
35
36
37
# File 'lib/scss_lint/linter/name_format.rb', line 34

def visit_mixin(node)
  check_name(node, 'mixin') unless whitelist?(node.name)
  yield # Continue into content block of this mixin's block
end

#visit_mixindef(node) ⇒ Object



39
40
41
42
# File 'lib/scss_lint/linter/name_format.rb', line 39

def visit_mixindef(node)
  check_name(node, 'mixin')
  yield # Continue into content block of this mixin definition
end

#visit_script_funcall(node) ⇒ Object



44
45
46
47
# File 'lib/scss_lint/linter/name_format.rb', line 44

def visit_script_funcall(node)
  check_name(node, 'function') unless whitelist?(node.name)
  yield # Continue linting any arguments of this function call
end

#visit_script_variable(node) ⇒ Object



49
50
51
# File 'lib/scss_lint/linter/name_format.rb', line 49

def visit_script_variable(node)
  check_name(node, 'variable')
end

#visit_variable(node) ⇒ Object



53
54
55
56
# File 'lib/scss_lint/linter/name_format.rb', line 53

def visit_variable(node)
  check_name(node, 'variable')
  yield # Continue into expression tree for this variable definition
end