~cytrogen/masto-fe

ref: e83059fd9d6cd4c6fa8723a36c9a4c7a62ae637b masto-fe/lib/linter/haml_middle_dot.rb -rw-r--r-- 733 bytes
e83059fd — Claire [Glitch] Fix explore prompt appearing because of posts being received out of order 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# frozen_string_literal: true

module HamlLint
  # 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)
  class Linter::MiddleDot < Linter
    include LinterRegistry

    # rubocop:disable Style/MiddleDot
    BULLET = '•'
    # rubocop:enable Style/MiddleDot
    MIDDLE_DOT = '·'
    MESSAGE = "Use '#{MIDDLE_DOT}' (middle dot) instead of '#{BULLET}' (bullet)".freeze

    def visit_plain(node)
      return unless node.text.include?(BULLET)

      record_lint(node, MESSAGE)
    end

    def visit_script(node)
      return unless node.script.include?(BULLET)

      record_lint(node, MESSAGE)
    end
  end
end