Sha256: 85493a6c053dfeaed6eea1b4a0241b9ca09df2845108540e4d9ce112e5d8caed

Contents?: true

Size: 564 Bytes

Versions: 12

Compression:

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

12 entries across 12 versions & 1 rubygems

Version Path
scss_lint-0.60.0 lib/scss_lint/linter/final_newline.rb
scss_lint-0.59.0 lib/scss_lint/linter/final_newline.rb
scss_lint-0.58.0 lib/scss_lint/linter/final_newline.rb
scss_lint-0.57.1 lib/scss_lint/linter/final_newline.rb
scss_lint-0.57.0 lib/scss_lint/linter/final_newline.rb
scss_lint-0.56.0 lib/scss_lint/linter/final_newline.rb
scss_lint-0.55.0 lib/scss_lint/linter/final_newline.rb
scss_lint-0.54.0 lib/scss_lint/linter/final_newline.rb
scss_lint-0.53.0 lib/scss_lint/linter/final_newline.rb
scss_lint-0.52.0 lib/scss_lint/linter/final_newline.rb
scss_lint-0.51.0 lib/scss_lint/linter/final_newline.rb
scss_lint-0.50.3 lib/scss_lint/linter/final_newline.rb