gems.scss_lint-0.57.1.lib.scss_lint.linter.comment.rb Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sass-maven-plugin Show documentation
Show all versions of sass-maven-plugin Show documentation
A Maven Plugin that compiles Sass files.
The newest version!
module SCSSLint
# Checks for uses of renderable comments (/* ... */)
class Linter::Comment < Linter
include LinterRegistry
def visit_comment(node)
add_lint(node, message) unless valid_comment?(node)
end
private
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
# @param node [CommentNode]
# @return [Boolean]
def allowed?(node)
return false unless config['allowed']
re = Regexp.new(config['allowed'])
node.value.join.match(re)
end
def message
if config.fetch('style', 'silent') == 'silent'
'Use `//` comments everywhere'
else
'Use `/* */` comments everywhere'
end
end
end
end