Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
EricDunsworth opened this issue Sep 14, 2018 · 5 comments
Closed

Comments

@EricDunsworth
Copy link

EricDunsworth commented Sep 14, 2018

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:

{}
@schorfES
Copy link
Owner

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.

@Bartheleway
Copy link
Contributor

Any news on this ?

@schorfES
Copy link
Owner

schorfES commented Oct 9, 2024

I've opened a PR #295 to handle this issue. I would by happy to see your feedback on this.

schorfES added a commit that referenced this issue Oct 15, 2024
Co-authored-by: Barthélemy Laurans <barthelemy.laurans.external@salomon.com>
schorfES added a commit that referenced this issue Oct 15, 2024
Co-authored-by: Barthélemy Laurans <bartheleway@gmail.com>
schorfES added a commit that referenced this issue Oct 15, 2024
Co-authored-by: Barthélemy Laurans <bartheleway@gmail.com>
@schorfES
Copy link
Owner

This is merged to main and I will make a release today. Thanks @Bartheleway and @EricDunsworth for your support and feedback. ❤️

@schorfES
Copy link
Owner

This is now available in version 0.12.0. 🥳

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants