Sha256: 22f86ba7e0822f45c56934c7a9f7b73f023687a0ee67c860843a99787bf31771

Contents?: true

Size: 577 Bytes

Versions: 9

Compression:

Stored size: 577 Bytes

Contents

module SCSSLint
  # Checks for final newlines at the end of a file.
  class Linter::FinalNewline < Linter
    include LinterRegistry

    def visit_root(_node)
      return if engine.lines.empty?

      ends_with_newline = engine.lines[-1][-1] == "\n"

      if config['present']
        add_lint(engine.lines.count,
                 'Files should end with a trailing newline') unless ends_with_newline
      else
        add_lint(engine.lines.count,
                 'Files should not end with a trailing newline') if ends_with_newline
      end
      yield
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
scss_lint-0.43.2 lib/scss_lint/linter/final_newline.rb
scss_lint-0.43.1 lib/scss_lint/linter/final_newline.rb
scss_lint-0.43.0 lib/scss_lint/linter/final_newline.rb
scss_lint-0.42.2 lib/scss_lint/linter/final_newline.rb
scss_lint-0.42.1 lib/scss_lint/linter/final_newline.rb
scss_lint-0.42.0 lib/scss_lint/linter/final_newline.rb
scss_lint-0.41.0 lib/scss_lint/linter/final_newline.rb
scss_lint-0.40.1 lib/scss_lint/linter/final_newline.rb
scss_lint-0.40.0 lib/scss_lint/linter/final_newline.rb