Sha256: 3aed2d8925b574490ca70fcdd07788405862e2c86f825d7e7ce07ccce1c387d8

Contents?: true

Size: 609 Bytes

Versions: 5

Compression:

Stored size: 609 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|
      was_empty = true
      document.source.lines.each.with_index(1) do |line, i|
        if line.blank?
          if was_empty
            sexp = Sexp.new(start: [i, 0], finish: [i, 0])
            report_lint(sexp, "Extra empty line detected")
          end
          was_empty = true
        else
          was_empty = false
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
slim_lint_standard-0.0.2.2 lib/slim_lint/linter/empty_lines.rb
slim_lint_standard-0.0.2.1 lib/slim_lint/linter/empty_lines.rb
slim_lint_standard-0.0.2 lib/slim_lint/linter/empty_lines.rb
slim_lint_standard-0.0.1 lib/slim_lint/linter/empty_lines.rb
slim_lint_standard-0.0.0 lib/slim_lint/linter/empty_lines.rb