Skip to content

[EditorConfig] Disable properties that use "unset" or invalid values. #47

@EricDunsworth

Description

@EricDunsworth

Lintspaces' editorconfig option currently has inconsistent support for properties that have been set to be disabled. A few seem to work, but most don't. Not sure if the ones that already work are by design.

EditorConfig's documentation claims that the unset value can be used to disable any property (including ones that were set earlier). Before unset was officially decided upon in editorconfig/editorconfig#287, editorconfig/editorconfig#262 (comment) had recommended using any invalid value to achieve the same effect.

Would it be possible to fully support disabling properties?

Code/Output samples...
The samples below demonstrate how lintspaces currently reacts to disabled properties.

.editorconfig

root = true

[*]
indent_style = space
indent_size = 2
end_of_line = cf
insert_final_newline = true
trim_trailing_whitespace = true

[test.txt]
 #Working
indent_style = unset
indent_size = unset
#Not working
end_of_line = unset
insert_final_newline = unset
trim_trailing_whitespace = unset

test.txt

 spaces 
	tab

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:

{ 'test.txt':
   { '1':
      [ ValidationError {
          line: 1,
          code: 'END_OF_LINE',
          type: 'warning',
          message: 'Incorrect end of line character(s) found.',
          payload: { expected: 'unset', end_of_line: 'CRLF' } },
        ValidationError {
          line: 1,
          code: 'TRAILINGSPACES',
          type: 'warning',
          message: 'Unexpected trailing spaces found.' } ],
     '2':
      [ ValidationError {
          line: 2,
          code: 'NEWLINE',
          type: 'warning',
          message: 'Expected a newline at the end of the file.' } ] } }

Expected output of node check.js:

{}

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions