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
Constants included from Utils
Instance Attribute Summary
Attributes inherited from SCSSLint::Linter
Instance Method Summary collapse
- #visit_charset(node) ⇒ Object
- #visit_comment(_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
Methods included from Utils
#color?, #color_hex?, #color_keyword?, #color_keyword_to_code, #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
35 36 37 38 39 40 |
# File 'lib/scss_lint/linter/string_quotes.rb', line 35 def visit_charset(node) # `@charset` source range includes entire declaration, so exclude that prefix source = source_from_range(node.source_range)[('@charset'.length)..-1] check_quotes(node, source) end |
#visit_comment(_node) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/scss_lint/linter/string_quotes.rb', line 6 def visit_comment(_node) # Sass allows you to write Sass Script in non-silent comments (/* ... */). # Unfortunately, it doesn't report correct source ranges for these script # nodes. # It's unlikely that a developer wanted to lint the script they wrote in a # comment, so just ignore this case entirely and stop traversing the # children of comment nodes. end |
#visit_import(node) ⇒ Object
30 31 32 33 |
# File 'lib/scss_lint/linter/string_quotes.rb', line 30 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
26 27 28 |
# File 'lib/scss_lint/linter/string_quotes.rb', line 26 def visit_script_string(node) check_quotes(node, source_from_range(node.source_range)) end |
#visit_script_stringinterpolation(node) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/scss_lint/linter/string_quotes.rb', line 15 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 |