Class: SCSSLint::Linter::StringQuotes
- Inherits:
-
SCSSLint::Linter
- Object
- Sass::Tree::Visitors::Base
- SCSSLint::Linter
- SCSSLint::Linter::StringQuotes
- Includes:
- SCSSLint::LinterRegistry
- Defined in:
- lib/scss_lint/linter/string_quotes.rb
Overview
Checks the type of quotes used in string literals.
Constant Summary collapse
- CHARSET_DIRECTIVE_LENGTH =
'@charset'.length
Constants included from Utils
Instance Attribute Summary
Attributes inherited from SCSSLint::Linter
Instance Method Summary collapse
- #visit_charset(node) ⇒ Object
- #visit_import(node) ⇒ Object
- #visit_script_string(node) ⇒ Object
- #visit_script_stringinterpolation(node) ⇒ Object
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
Constructor Details
This class inherits a constructor from SCSSLint::Linter
Instance Method Details
#visit_charset(node) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/scss_lint/linter/string_quotes.rb', line 29 def visit_charset(node) # `@charset` source range includes entire declaration, so exclude that prefix source = source_from_range(node.source_range)[CHARSET_DIRECTIVE_LENGTH..-1] check_quotes(node, source) end |
#visit_import(node) ⇒ Object
24 25 26 27 |
# File 'lib/scss_lint/linter/string_quotes.rb', line 24 def visit_import(node) # `@import` source range conveniently includes only the quoted string check_quotes(node, source_from_range(node.source_range)) end |
#visit_script_string(node) ⇒ Object
20 21 22 |
# File 'lib/scss_lint/linter/string_quotes.rb', line 20 def visit_script_string(node) check_quotes(node, source_from_range(node.source_range)) end |
#visit_script_stringinterpolation(node) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/scss_lint/linter/string_quotes.rb', line 8 def visit_script_stringinterpolation(node) # We can't statically determine what the resultant string looks like when # string interpolation is used, e.g. "one #{$var} three" could be a very # different string depending on $var = `'" + "'` or $var = `two`. # # Thus we manually skip the substrings in the string interpolation and # visit the expressions in the interpolation itself. node.children .reject { |child| child.is_a?(Sass::Script::Tree::Literal) } .each { |child| visit(child) } end |