What do you think about introducing the "file should end with a newline" rule?
Here's the Checkstyle rule for this.
Hi @egor-n
You can enable it by adding this to your .editorconfig
[*.{kt,kts}]
insert_final_newline=true
(we should probably turn it on by default, though)
I should have thought of that. Thank you!
No worries. Documentation wasn't very clear. If you don't mind I'll keep this ticket open until insert_final_newline is set to true by default.
Right now it would not fail if there are two new lines at the end of a file. I guess that could be optimized, right?
@vanniktech 2 or more blank lines should trigger "Needless blank line(s)" error. If it doesn't please submit a bug report.
There you go #108
Instead of enabling this option by default I went with improving ktlint's .editorconfig support by automatically falling back to "[*]" for property resolution. This way people who have .editoconfig with insert_final_newline = true under [*] won't have to do anything else to enable it and others won't be surprised by the change.
"not enabled unless .editorconfig says otherwise" behavior is currently due to the fact that neither Jetbrains's nor Google's styleguide says anything about newline at the end of file. I'll try to clarify it before making insert_final_newline on by default.
insert_final_newline = true under [*] support included in [email protected].
Would love to see this enabled by default, especially because git diff warns about this. (A lot of tooling warns about it, actually!)
Most helpful comment
Would love to see this enabled by default, especially because git diff warns about this. (A lot of tooling warns about it, actually!)