class SCSSLint::Linter::Comment

Checks for uses of renderable comments (/* … */)

Public Instance Methods

visit_comment(node) click to toggle source
# File lib/scss_lint/linter/comment.rb, line 6
def visit_comment(node)
  add_lint(node, message) unless valid_comment?(node)
end

Private Instance Methods

allowed?(node) click to toggle source

@param node [CommentNode] @return [Boolean]

# File lib/scss_lint/linter/comment.rb, line 28
def allowed?(node)
  return false unless config['allowed']
  re = Regexp.new(config['allowed'])

  node.value.join.match(re)
end
message() click to toggle source
# File lib/scss_lint/linter/comment.rb, line 35
def message
  if config.fetch('style', 'silent') == 'silent'
    'Use `//` comments everywhere'
  else
    'Use `/* */` comments everywhere'
  end
end
valid_comment?(node) click to toggle source
# File lib/scss_lint/linter/comment.rb, line 12
def valid_comment?(node)
  allowed_type =
    if config.fetch('style', 'silent') == 'silent'
      node.invisible?
    else
      !node.invisible?
    end
  return true if allowed_type

  # Otherwise check if comment contains content that excludes it (i.e. a
  # copyright notice for loud comments)
  allowed?(node)
end