node-lintspaces
node-lintspaces copied to clipboard
[EditorConfig] Disable properties that use "unset" or invalid values.
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, https://github.com/editorconfig/editorconfig/issues/262#issuecomment-230530280 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
:
{}
Hi @EricDunsworth,
thank you for this detailed issue. I think this is related to the editorconfig-core-js implementation itself. Without currently testing the response of editorconfig, I expect to receive the value 'unset'
from the configuration which will be interpreted as true
. I think editorconfig needs to return its default values if unset
is used. I need to run the code and read the documentation to prove this statement. I will get back to you later.