Sha256: 87c5a11e6a1c83426a1389da463906d78fe5702181adf8c333a6baf684140230

Contents?: true

Size: 559 Bytes

Versions: 10

Compression:

Stored size: 559 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
      elsif ends_with_newline
        add_lint(engine.lines.count, 'Files should not end with a trailing newline')
      end

      yield
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
scss_lint-0.50.2 lib/scss_lint/linter/final_newline.rb
scss_lint-0.50.1 lib/scss_lint/linter/final_newline.rb
scss_lint-0.50.0 lib/scss_lint/linter/final_newline.rb
scss_lint-0.49.0 lib/scss_lint/linter/final_newline.rb
scss_lint-0.48.0 lib/scss_lint/linter/final_newline.rb
scss_lint-0.47.1 lib/scss_lint/linter/final_newline.rb
scss_lint-0.47.0 lib/scss_lint/linter/final_newline.rb
scss_lint-0.46.0 lib/scss_lint/linter/final_newline.rb
scss_lint-0.45.0 lib/scss_lint/linter/final_newline.rb
scss_lint-0.44.0 lib/scss_lint/linter/final_newline.rb