Skip to content

[EditorConfig] "insert_final_newline = false" doesn't produce warnings in files that contain final newlines. #49

Open
@EricDunsworth

Description

@EricDunsworth

According to the EditorConfig website's supported properties section and editorconfig/editorconfig#269 (comment), insert_final_newline = false is supposed to ensure a file doesn't end with a final newline. The EditorConfig editor plugins I tried also work in that way - they strip out final newlines when saving files associated to .editorconfig files that have that property set to false.

However, lintspaces' equivalent newline property doesn't work in the same way. According to the newline option's documentation, it's solely designed to check for the the presence of final newlines and isn't capable of doing the opposite.

Since lintspaces' .editorconfig option works by remapping insert_final_newline to newline, that causes a clash between both interpretations.

Could something be done to make lintspaces' .editorconfig option follow that format's more aggressive interpretation of insert_final_newline = false?

Code/Output samples...
The samples below demonstrate how lintspaces currently reacts to insert_final_newline = false when a file contains a final newline.

.editorconfig

root = true

[*]
insert_final_newline = false

test.txt (contains a final newline)

test

check.js

var Validator = require('lintspaces');

var validator = new Validator({editorconfig: '.editorconfig'});
validator.validate('test.txt');

var results = validator.getInvalidFiles();

//Derived from https://stackoverflow.com/a/10729284
const util = require('util');

console.log(util.inspect(results, {showHidden: false, depth: null}));

Output when running node check.js in Windows:

{}

Expected output of node check.js:

{ 'test.txt':
   { '2':
      [ ValidationError {
          line: 2,
          code: 'NEWLINE_AMOUNT',
          type: 'warning',
          message: 'Unexpected additional newlines at the end of the file.' } ]
} }

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions