editorconfig / editorconfig-emacs

EditorConfig plugin for Emacs
https://editorconfig.org
GNU General Public License v3.0
748 stars 107 forks source link

Comment on same line after ] breaks parsing (which is probably OK) #322

Closed reinout closed 10 months ago

reinout commented 10 months ago

The plugin doesn't like a comment after a heading - on the same line

A heading like [*.{json,js}] # Frontend development results in the following warning:

⛔ Warning (editorconfig): Failed to get properties, styles will not be applied: 
(editorconfig-error "Error from editorconfig-get-properties-function: 
(error \"Error while reading config file: /.../my-project/.editorconfig:36:
    [*.{json,js}] 
\")")

Removing the comment from the end of the line fixes it.

Now, the spec says: Comments should go on their own lines. So that probably means that the format of the editorconfig file I got is wrong? OTOH, "should" normally means "not recommended, but technically you're allowed". I'm not sure :-)

xuhdev commented 10 months ago

The actual spec is here:

A ; or # anywhere other than at the beginning of a line does not start a comment, but is part of the text of that line.

The website uses the word "should" to request the reader to do so. It is not optional in this context. See the Merriam-Webster entry meanings 2 and 5. You are probably referring to meaning 4, but it is not in the context of instructions. In instructions, if something is only recommended and optional, the word "may" should be used.

(Closing now, feel free to reopen if you have further questions)

reinout commented 10 months ago

I agree. Thanks for the link to the exact spec, I missed that one. I'll get the .editorconfig fixed up :-)