Sha256: 3105542e1bea197756af6011d29b0db97501efd999ff598912dc013d5bf1239e

Contents?: true

Size: 845 Bytes

Versions: 13

Compression:

Stored size: 845 Bytes

Contents

module SCSSLint
  # Checks for uses of renderable comments (/* ... */)
  class Linter::Comment < Linter
    include LinterRegistry

    def visit_comment(node)
      add_lint(node, 'Use `//` comments everywhere') 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
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
scss_lint-0.50.2 lib/scss_lint/linter/comment.rb
scss_lint-0.50.1 lib/scss_lint/linter/comment.rb
scss_lint-0.50.0 lib/scss_lint/linter/comment.rb
scss_lint-0.49.0 lib/scss_lint/linter/comment.rb
scss_lint-0.48.0 lib/scss_lint/linter/comment.rb
scss_lint-0.47.1 lib/scss_lint/linter/comment.rb
scss_lint-0.47.0 lib/scss_lint/linter/comment.rb
scss_lint-0.46.0 lib/scss_lint/linter/comment.rb
scss_lint-0.45.0 lib/scss_lint/linter/comment.rb
scss_lint-0.44.0 lib/scss_lint/linter/comment.rb
scss_lint-0.43.2 lib/scss_lint/linter/comment.rb
scss_lint-0.43.1 lib/scss_lint/linter/comment.rb
scss_lint-0.43.0 lib/scss_lint/linter/comment.rb