sindresorhus / atom-editorconfig

Helps developers maintain consistent coding styles between different editors
https://atom.io/packages/editorconfig
MIT License
812 stars 80 forks source link

Multiple paths unsupported? #240

Closed crstauf closed 4 years ago

crstauf commented 4 years ago

Involved .editorconfig-files

# Version 1

root = true

[foo/**,bar/**]
charset = utf-8
end_of_line = lf
indent_style = tab
trim_trailing_whitespace = true

I have also tried (which I think is how the doc indicates it should be?):

# Version 2

root = true

[{foo/**,bar/**}]
charset = utf-8
end_of_line = lf
indent_style = tab
trim_trailing_whitespace = true
# Version 3

root = true

[/foo/**,/bar/**]
charset = utf-8
end_of_line = lf
indent_style = tab
trim_trailing_whitespace = true

Note: I added the first line noting the version number for easy reference; it's not included in the actual .editorconfig file.

Directory structure

root
├── bar
│   └── bar.txt
├── foo
│   └── foo.txt
└── .editorconfig

On both bar/bar.txt and foo/foo.txt, after running the "Show State" command, the popup indicates no config was applied.

Screen Shot 2020-03-30 at 12 26 26 AM

If I change .editorconfig to

# Version 4

root = true

[foo/**]
charset = utf-8
end_of_line = lf
indent_style = tab
trim_trailing_whitespace = true

then foo/foo.txt applies the config, and it works fine.

Context

I'm creating a .editorconfig in the root of a WordPress install, to apply to files in wp-content/mu-plugins and wp-content/themes/my-theme. I don't want to apply a config to any files outside of those folders.

Alhadis commented 4 years ago

Does {foo,bar}/** work?

crstauf commented 4 years ago

@Alhadis Indeed it does; thanks!

What should the selector be to have two different file extensions in different directories to use the same config be?

Pseudo section name: [{foo/**.txt,bar/**.md}]

Alhadis commented 4 years ago

Two different sections with identical contents. :wink:

crstauf commented 4 years ago

Bleh, not the answer I was hoping for (not ideal), but I understand.

Thanks for the help, @Alhadis!