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

feat: add trim_final_newlines option #5653

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

yuhr
Copy link

@yuhr yuhr commented Jan 7, 2023

Added an option to configure whether to trim final newlines.

I'm new to contribute to rustfmt, so I couldn't reasonably figure this to be stable or not (although I think it's a trivial option that there should never be a room for any kind of unstability).

@alex-semenyuk
Copy link
Member

When this option can be helpful? I mean when it makes sense to have many newlines or not have at all.

@yuhr
Copy link
Author

yuhr commented Jan 8, 2023

  1. In my opinion, newlines at the EOF are essentially meaningless.
  2. Editing EOF newlines may cause conflicts with other tooling such as Remove Final Newlines.

So, at least it should be configurable of whether to perform trimming. Even editorconfig is configurable of this.

It's weird nowadays that most programmers (and programs) force people to blindly conform to the ancient convention of POSIX which doesn't reflect human's natural intuition about what lines are. Humans are not slaves to machines.

Also see my comment on a similar issue in prettier/prettier:

From human's point of view, a newline character appears as rather the beginning of a newline, than merely the end of the line like POSIX defines. Many people think there's a pointless empty newline, probably that's one of the reason why they (and me of course) ended up into this issue. Softwares should be implemented as a reflection of how people think.

@yuhr yuhr force-pushed the feat/trim-final-newlines branch from 732b77e to 1f7ec70 Compare April 1, 2023 09:23
@yuhr yuhr force-pushed the feat/trim-final-newlines branch from 1f7ec70 to 5a98c16 Compare April 8, 2023 19:01
@yuhr yuhr force-pushed the feat/trim-final-newlines branch from 5a98c16 to da32abb Compare July 7, 2023 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants