mtasa-resources icon indicating copy to clipboard operation
mtasa-resources copied to clipboard

Add .editorconfig file

Open jlillis opened this issue 5 years ago • 10 comments

When merged, this will add an .editorconfig file to the repo to help enforce a consistent coding style. The following rules are set:

  • Add final newline and trim trim trailing whitespace from all files
  • Use 4 tabs instead of spaces and crlf line endings in .lua files

jlillis avatar Nov 10 '20 21:11 jlillis

Did commit https://github.com/multitheftauto/mtasa-resources/commit/2c6416a09697b9d8b812c182cff0955b09d753c5 standardize the repo on LF or CRLF? If LF, then I should update my settings here I think. Also, is there any way to perform a "simpler" format checking at just checks for proper indentation and line endings? That seems to be the most common pain point.

jlillis avatar Nov 10 '20 23:11 jlillis

Unfortunately I think it accidentally accidentally changed it to CRLF. It seems to edit all admin2 files, which iirc were previously standardised to LF by lua-fmt. I'm going to turn on pull request enforcements so we can catch this in code review next time.

qaisjp avatar Nov 10 '20 23:11 qaisjp

Also, is there any way to perform a "simpler" format checking at just checks for proper indentation and line endings?

I think we could do that. Do you want to look into that, or shall I?

qaisjp avatar Nov 10 '20 23:11 qaisjp

I think we could do that. Do you want to look into that, or shall I?

I have zero experience with GitHub Actions/CI so it's probably best if you look into it.

Looks like you're correct: .gitattributes calls for LF line endings.

If we can get consensus on the settings I've defined so far I'll go ahead and add a CONTRIBUTING.md file describing the desired coding style so far.

A seperate PR to format existing code is probably called for too.

jlillis avatar Nov 11 '20 01:11 jlillis

Oh, hm, if our .gitattributes calls for LF, and most of our current code is CRLF, I'm not sure what to do.

Maybe we can just comment out that line of the .gitattributes file, and revisit line endings (and mass-formatting) later.

qaisjp avatar Nov 11 '20 12:11 qaisjp

I think that's probably the best move for now. I'll open a separate issue for discussion.

jlillis avatar Nov 13 '20 02:11 jlillis

Going to switch this back to a draft PR until we make some more decisions in #250

jlillis avatar Nov 17 '20 16:11 jlillis