Sha256: ce48b909bfd710024cdaa1c7f0ae30f2a770afe9717086868495c2b6129a834b

Contents?: true

Size: 618 Bytes

Versions: 1

Compression:

Stored size: 618 Bytes

Contents

module SlimLint
  # This linter looks for trailing blank lines and a final newline.
  class Linter::TrailingBlankLines < Linter
    include LinterRegistry

    on_start do |_sexp|
      dummy_node = Struct.new(:line)
      next if document.source.empty?

      if !document.source.end_with?("\n")
        report_lint(dummy_node.new(document.source_lines.size),
                    'No blank line in the end of file')
      elsif document.source.lines.last.blank?
        report_lint(dummy_node.new(document.source.lines.size),
                    'Multiple empty lines in the end of file')
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
slim_lint-0.15.1 lib/slim_lint/linter/trailing_blank_lines.rb