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

Change endOfLine to lf by default for 2.0 #6932

Closed
kachkaev opened this issue Nov 11, 2019 · 9 comments
Closed

Change endOfLine to lf by default for 2.0 #6932

kachkaev opened this issue Nov 11, 2019 · 9 comments
Labels
locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. status:needs discussion Issues needing discussion and a decision to be made before action can be taken
Milestone

Comments

@kachkaev
Copy link
Member

kachkaev commented Nov 11, 2019

Refs: #6888 (about Prettier 2.0), #6929 (about changing arrowParens to always)

End of Line option was added in #5327 and is available since Prettier 1.15. Given that using LF (Linux line endings) is a default choice in the software dev world, I decided to open this issue to bring the topic to a broader discussion.

I understand that changing defaults can cause large git diffs in some projects. However for the benefit of newly created projects, I suggest that the problem can be addressed by changing prettier.config.js in existing codebases. V2.0 is a great opportunity for breaking changes like this.

WDYT folks?

@lydell
Copy link
Member

lydell commented Nov 11, 2019

What are the benefits of changing the default here?

@Shinigami92
Copy link
Member

Want to let you know that I'm using .editorconfig with end_of_line = lf

@kachkaev
Copy link
Member Author

kachkaev commented Nov 12, 2019

@Shinigami92 we also have endOfLine: "lf" configured, the suggestion is to avoid a need to do this 🙂

@lydell see #5320 and linked issues for context. My motivation for adding endOfLine to Prettier was a lot of pain we had to experience in our company. Because developers were contributing to repos from both *nix and Windows machines, end of lines ended up being different in neighbouring files and even jumped from one style to another in files between commits. In addition to a discomfort and unnecessary diffs coming out of this inconsistency, it was also a source of real bugs. If a javascript file starts with

#!/usr/bin/env node

and someone manages to commit it with CRLF, the above shebang directive no longer works. With the release of Prettier 1.15, we configured endOfLine: "lf" and had no CRLF problems ever since.

The reason we have endOfLine: "auto" by default is #92, which got more 👎 than 👍 in the end. It was addressed by #472 nearly three years ago, until then Prettier was enforcing LFs.

I'm not suggesting to remove the option completely, just in case someone still needs viewing files on the Windows 8 Nodepad. This is the least dated text editor I know of that requires CR characters in order to render multiple lines. Going further, I would suggest removing this option completely given that LF works in any modern editor.

@kachkaev
Copy link
Member Author

kachkaev commented Nov 12, 2019

Examples of mixed CRLF / LF line endings in popular repos (November 2018, before endOfLine: "lf" was introduced): #5320 (comment)

@alexander-akait alexander-akait added the status:needs discussion Issues needing discussion and a decision to be made before action can be taken label Nov 14, 2019
@thorn0 thorn0 added this to the 2.0 milestone Jan 23, 2020
@kachkaev
Copy link
Member Author

👀 ➡ ️#7435

@kachkaev
Copy link
Member Author

Closed in #7435 🚀 Thanks to @thorn0 for merging! 🙌

@snebjorn

This comment has been minimized.

@lydell

This comment has been minimized.

@snebjorn

This comment has been minimized.

@lock lock bot added the locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. label Jun 24, 2020
@lock lock bot locked as resolved and limited conversation to collaborators Jun 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. status:needs discussion Issues needing discussion and a decision to be made before action can be taken
Projects
None yet
Development

No branches or pull requests

6 participants