Sha256: b03bbdea4496bca8835c91e57d2d989a40f2c8724c3249ecb493cf4d3216c3d6

Contents?: true

Size: 581 Bytes

Versions: 2

Compression:

Stored size: 581 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)

      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

2 entries across 2 versions & 1 rubygems

Version Path
slim_lint-0.15.0 lib/slim_lint/linter/trailing_blank_lines.rb
slim_lint-0.14.0 lib/slim_lint/linter/trailing_blank_lines.rb