Sha256: 242fc6127e9480981c3dbfa7b3b90fb88f5fa1ea716d8afcc49e60745f2a3982

Contents?: true

Size: 542 Bytes

Versions: 9

Compression:

Stored size: 542 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+/

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

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
slim_lint-0.22.0 lib/slim_lint/linter/comment_control_statement.rb
slim_lint-0.21.1 lib/slim_lint/linter/comment_control_statement.rb
slim_lint-0.21.0 lib/slim_lint/linter/comment_control_statement.rb
slim_lint-0.20.2 lib/slim_lint/linter/comment_control_statement.rb
slim_lint-0.20.1 lib/slim_lint/linter/comment_control_statement.rb
slim_lint-0.20.0 lib/slim_lint/linter/comment_control_statement.rb
slim_lint-0.19.0 lib/slim_lint/linter/comment_control_statement.rb
slim_lint-0.18.0 lib/slim_lint/linter/comment_control_statement.rb
slim_lint-0.17.1 lib/slim_lint/linter/comment_control_statement.rb