flotang-gtt / ThermML

2 stars 0 forks source link

Schema formatting format #6

Open flotang-gtt opened 6 months ago

flotang-gtt commented 6 months ago

This is not a very important question, but by accident I had the option 'Format on Save' activated in VSCode, which resulted in signifcant amout of whitespace changes (e.g. in main.xsd, some clearly non-formal whitespace uses are employed.

personally I do not really care, but the dread of git diffs being polluted by whitespace issues takes a toll on me.

My stance would be to disable 'Format on Save' and work in trusting matter. But I wanted to see/know if anyone of you has better ideas.

If you don't care, I will assume acceptance of the current status.

richardotis commented 5 months ago

We could adopt a standard code formatter like Prettier: https://prettier.io/ - looks like all the major editors/IDEs are supported. There are pre-commit and CI hooks that can be used to help enforce this. I'm not a fan of pre-commit hooks generally as they create a barrier to contributing, but it may be worth it here.

It may be a good idea to add this to .gitattributes to enforce some consistent line-ending handling:

*.xml text eol=lf
*.xsd text eol=lf

text This attribute marks the path as a text file, which enables end-of-line conversion: When a matching file is added to the index, the file’s line endings are normalized to LF in the index. Conversely, when the file is copied from the index to the working directory, its line endings may be converted from LF to CRLF depending on the eol attribute, the Git config, and the platform (see explanation of eol below).

eol This attribute marks a path to use a specific line-ending style in the working tree when it is checked out. It has effect only if text or text=auto is set (see above), but specifying eol automatically sets text if text was left unspecified.

Set to string value crlf This setting converts the file’s line endings in the working directory to CRLF when the file is checked out.

Set to string value lf This setting uses the same line endings in the working directory as in the index when the file is checked out.