Sha256: 0f8936ed383ed0be4d700a870ffb85ce06a8710635bcca393bda8b0342f7d1c0

Contents?: true

Size: 626 Bytes

Versions: 23

Compression:

Stored size: 626 Bytes

Contents

# frozen_string_literal: true

module SlimLint
  # This linter checks for two or more consecutive blank lines
  # and for the first blank line in file.
  class Linter::EmptyLines < Linter
    include LinterRegistry

    on_start do |_sexp|
      dummy_node = Struct.new(:line)

      was_empty = true
      document.source.lines.each_with_index do |line, i|
        if line.blank?
          if was_empty
            report_lint(dummy_node.new(i + 1),
                        'Extra empty line detected')
          end
          was_empty = true
        else
          was_empty = false
        end
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
slim_lint-0.17.0 lib/slim_lint/linter/empty_lines.rb
slim_lint-0.16.1 lib/slim_lint/linter/empty_lines.rb
slim_lint-0.16.0 lib/slim_lint/linter/empty_lines.rb