Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Turn insert_final_newline on by default #103

Closed
egor-n opened this issue Nov 21, 2017 · 8 comments
Closed

Turn insert_final_newline on by default #103

egor-n opened this issue Nov 21, 2017 · 8 comments

Comments

@egor-n
Copy link

egor-n commented Nov 21, 2017

What do you think about introducing the "file should end with a newline" rule?

Here's the Checkstyle rule for this.

@shyiko
Copy link
Collaborator

shyiko commented Nov 21, 2017

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)

@egor-n
Copy link
Author

egor-n commented Nov 21, 2017

I should have thought of that. Thank you!

@egor-n egor-n closed this as completed Nov 21, 2017
@shyiko
Copy link
Collaborator

shyiko commented Nov 21, 2017

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.

@shyiko shyiko reopened this Nov 21, 2017
@shyiko shyiko changed the title Ensure line feed file end Turn insert_final_newline on by default Nov 21, 2017
@vanniktech
Copy link
Contributor

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?

@shyiko
Copy link
Collaborator

shyiko commented Nov 22, 2017

@vanniktech 2 or more blank lines should trigger "Needless blank line(s)" error. If it doesn't please submit a bug report.

@vanniktech
Copy link
Contributor

There you go #108

@shyiko
Copy link
Collaborator

shyiko commented Nov 28, 2017

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 ktlint@0.13.0.

@shyiko shyiko closed this as completed Nov 28, 2017
@thauk-copperleaf
Copy link

Would love to see this enabled by default, especially because git diff warns about this. (A lot of tooling warns about it, actually!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants