Sha256: 3e55fd273908722214590977721654fe260f411279dd9bf2cc07e41db8531804

Contents?: true

Size: 649 Bytes

Versions: 23

Compression:

Stored size: 649 Bytes

Contents

# frozen_string_literal: true

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

23 entries across 23 versions & 1 rubygems

Version Path
slim_lint-0.31.1 lib/slim_lint/linter/trailing_blank_lines.rb
slim_lint-0.31.0 lib/slim_lint/linter/trailing_blank_lines.rb
slim_lint-0.30.0 lib/slim_lint/linter/trailing_blank_lines.rb
slim_lint-0.29.0 lib/slim_lint/linter/trailing_blank_lines.rb
slim_lint-0.28.0 lib/slim_lint/linter/trailing_blank_lines.rb
slim_lint-0.27.0 lib/slim_lint/linter/trailing_blank_lines.rb
slim_lint-0.26.0 lib/slim_lint/linter/trailing_blank_lines.rb
slim_lint-0.25.0 lib/slim_lint/linter/trailing_blank_lines.rb
slim_lint-0.24.0 lib/slim_lint/linter/trailing_blank_lines.rb
slim_lint-0.23.0 lib/slim_lint/linter/trailing_blank_lines.rb
slim_lint-0.22.1 lib/slim_lint/linter/trailing_blank_lines.rb
slim_lint-0.22.0 lib/slim_lint/linter/trailing_blank_lines.rb
slim_lint-0.21.1 lib/slim_lint/linter/trailing_blank_lines.rb
slim_lint-0.21.0 lib/slim_lint/linter/trailing_blank_lines.rb
slim_lint-0.20.2 lib/slim_lint/linter/trailing_blank_lines.rb
slim_lint-0.20.1 lib/slim_lint/linter/trailing_blank_lines.rb
slim_lint-0.20.0 lib/slim_lint/linter/trailing_blank_lines.rb
slim_lint-0.19.0 lib/slim_lint/linter/trailing_blank_lines.rb
slim_lint-0.18.0 lib/slim_lint/linter/trailing_blank_lines.rb
slim_lint-0.17.1 lib/slim_lint/linter/trailing_blank_lines.rb