editorconfig / editorconfig-core-js

EditorConfig Core library and command line utility written in JavaScript
http://editorconfig.org
MIT License
272 stars 48 forks source link

Single item wildcard set not applied correctly. #85

Closed MicahZoltu closed 4 years ago

MicahZoltu commented 4 years ago
root = true
[*]
indent_size = 2
indent_style = space
[*.{ts}]
indent_size = 4

Actual Behavior:

$ npx editorconfig index.ts
indent_size=2
indent_style=space
tab_width=2

Expected Behavior:

$ npx editorconfig index.ts
indent_size=4
indent_style=space
tab_width=4

Workaround

Change [*.{ts}] to [*.ts] or to [*.{ts,js}]. The problem here appears to be that a set with a single item in it doesn't properly match items. You need to have at least two items in the set for it to match.

jednano commented 4 years ago

You don't need to have at least two items, but you do need to have a comma. This is by design. I don't love it myself, but it's by design. Also, this is not specific to the JS core, but all cores. You can see the tests here.

jednano commented 4 years ago

Feel free to open up an issue here, arguing that this scenario should be supported, because it probably should be, IMO.

MicahZoltu commented 4 years ago

Hmm, I'm not sure how to read those tests:

; single choice
[{single}.b]
choice=single

This suggests to me that single choice is supported, but I may be reading it wrong.

jednano commented 4 years ago

It does seem that way. Unfortunately, the tests repo doesn’t have CI set up yet, so there’s no way to submit a breaking test PR. Even if it did, it would probably just be testing one of the cores like the C core.

jednano commented 4 years ago

Honestly, we need a way to run tests across all cores.