sds/haml-lint

View on GitHub
lib/haml_lint/linter/ruby_comments.rb

Summary

Maintainability
A
0 mins
Test Coverage
# frozen_string_literal: true

module HamlLint
  # Checks for Ruby comments that can be written as HAML comments.
  class Linter::RubyComments < Linter
    include LinterRegistry

    def visit_silent_script(node)
      if code_comment?(node)
        record_lint(node, 'Use `-#` for comments instead of `- #`')
      end
    end

    private

    def code_comment?(node)
      node.script =~ /\A\s+#/
    end
  end
end