Sha256: f1a85288dece2bff68e2538b9f1f2504958fa55fee1343e46e1a2148e3124056

Contents?: true

Size: 594 Bytes

Versions: 11

Compression:

Stored size: 594 Bytes

Contents

# frozen_string_literal: true

module SlimLint
  # Searches for control statements with only comments.
  class Linter::CommentControlStatement < Linter
    include LinterRegistry

    on [:slim, :control] do |sexp|
      _, _, code = sexp
      next unless code[/\A\s*#/]

      comment = code[/\A\s*#(.*\z)/, 1]

      next if comment =~ /^\s*rubocop:\w+/
      next if comment =~ /^\s*Template Dependency:/

      report_lint(sexp,
                  "Slim code comments (`/#{comment}`) are preferred over " \
                  "control statement comments (`-##{comment}`)")
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
slim_lint-0.31.1 lib/slim_lint/linter/comment_control_statement.rb
slim_lint-0.31.0 lib/slim_lint/linter/comment_control_statement.rb
slim_lint-0.30.0 lib/slim_lint/linter/comment_control_statement.rb
slim_lint-0.29.0 lib/slim_lint/linter/comment_control_statement.rb
slim_lint-0.28.0 lib/slim_lint/linter/comment_control_statement.rb
slim_lint-0.27.0 lib/slim_lint/linter/comment_control_statement.rb
slim_lint-0.26.0 lib/slim_lint/linter/comment_control_statement.rb
slim_lint-0.25.0 lib/slim_lint/linter/comment_control_statement.rb
slim_lint-0.24.0 lib/slim_lint/linter/comment_control_statement.rb
slim_lint-0.23.0 lib/slim_lint/linter/comment_control_statement.rb
slim_lint-0.22.1 lib/slim_lint/linter/comment_control_statement.rb