haml_middle_dot.rb 733 B

1234567891011121314151617181920212223242526
  1. # frozen_string_literal: true
  2. module HamlLint
  3. # Bans the usage of “•” (bullet) in HTML/HAML in favor of “·” (middle dot) in anything that will end up as a text node. (including string literals in Ruby code)
  4. class Linter::MiddleDot < Linter
  5. include LinterRegistry
  6. # rubocop:disable Style/MiddleDot
  7. BULLET = '•'
  8. # rubocop:enable Style/MiddleDot
  9. MIDDLE_DOT = '·'
  10. MESSAGE = "Use '#{MIDDLE_DOT}' (middle dot) instead of '#{BULLET}' (bullet)".freeze
  11. def visit_plain(node)
  12. return unless node.text.include?(BULLET)
  13. record_lint(node, MESSAGE)
  14. end
  15. def visit_script(node)
  16. return unless node.script.include?(BULLET)
  17. record_lint(node, MESSAGE)
  18. end
  19. end
  20. end