Add option to enforce certain line endings#5327
Add option to enforce certain line endings#5327ikatyang merged 26 commits intoprettier:masterfrom kachkaev:eol-option
Conversation
…to test true presence of \r
… snapshots on Windows
|
So this is ready to be merged? Maybe we should update the TODO list then.. |
# Conflicts: # tests_integration/__tests__/__snapshots__/support-info.js.snap
|
Also if this is part of the 1.15 milestone we will have to update the blog post as well! |
|
Looks like the only thing left to do is to wait for the new version of |
…ion (#4) Partially addresses prettier/prettier#5320. Helps implement prettier/prettier#5327.
Done, you can upgrade to version |
… added in yarn 1.10)
|
Many thanks for doing this so quickly @josephfrazier! 💯 This PR should be ready for a final review and can be merged after that! @lipis can we squeeze it into 1.15 given that all is done? 😅 |
|
@ikatyang You're pretty much managing the 1.15 release, I think you can decide to include in this release or not. |
|
I'd like to wait for a day to see if there's any objection, it will be included in 1.15 if everything goes well. |
… auto,lf,crlf,cr)
|
After some more thinking, I changed the order of option values both in docs and cli ( @ikatyang if you don't agree with this change, simply chop off my last commit before merging. Let me know if you need help with anything else! |
|
Don't worry, I'll merge it later. I was fixing regressions. |
|
Thanks! |
|
Amazing!!! Many thanks for all your prompt comments and very useful reviews! I'm soooooo glad we could squeeze this feature into 1.15 that I'm jumping through the roof! 😅 |

This PR contains a minimal viable implementation of #5320.
There is also a sidecar PR in another repo to read
.editorconfigoption as suggested by @evilebottnawi. I believe it is ready to be reviewed and can be merged after we close the first item in the TODO list below. We need to release a new version ofeditorconfig-to-prettierbefore completing this feature.docs/directory)TODO (based on reviews)
Agree on the option name:
eol(originally proposed) – a commonly known abbreviation, but may be confusing for newcomersendOfLine/--end-of-line(suggested by two maintainers) – easier for newcomers, but takes longer to write; similar to.editorconfig'send_of_linelineEnding(s?)/--line-ending(s?)– a commonly used term in human-to-human communicationDecide if we want to support
--endOfLine=crat all. I'm not sure if Prettier can successfully parse files withoutLFat the moment. In any case, onlyCRLFandLFare prevalent (I haven’t seen anyone usingCRonly). Discussion: 4th conversation in Add option to enforce certain line endings #5327 (review) (marked as resolved by @ikatyang). Solution: keepcramongst values for consistency with what.editorconfigsupports.Merge [WIP] Convert .editorconfig’s end_of_line option to Prettier’s eol option josephfrazier/editorconfig-to-prettier#4 and replace a temporary used fork with the original package.
Looking forward for your thoughts folks 🙌
Future work
eolfor files that have a syntax error don't have a known grammar (e.g..gitignore). This should make it possible toprettier --write '**/*'orprettier-check '**/*'. We can do this in follow-up issues and PRs.