-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Use insertFinalNewline option from editorconfig for Handlebars / Ember files #10759
base: main
Are you sure you want to change the base?
Conversation
It's difficult to agree with the Ember team's reasoning about doing the newline stripping on the editor's side. From ember-cli/ember-cli#3440 (comment):
Isn't this an edge case that happens really rarely though? Besides, it looks like the problem can be solved by putting a comment at the end of such a template to control how many significant trailing blank lines it should have. content ...
{{! The two newlines before this comment should be preserved. The final newline after this comment shouldn't matter. }} There are great points in ember-cli/ember-cli#3738 |
I alway like the idea repect |
@fisker So are you okay with adding an option controlled only by EditorConfig? |
Yes. |
That's an interesting solution to the "How do we add an option without adding an option?" problem. Need to think more about it. |
Thank you for your feedbacks.
I'll try to think about it as well. If you have any pointer, it is welcome :) |
Any updates on this? I'm being affected and would love to see this merge! |
Description
By default, Prettier will remove the final newline from Handlebars / Ember files. Why? Because otherwise it would add an extra DOM text node and in most cases this would be unnecessary. This is the recommended practise in the Ember ecosystem (source).
In this PR I propose a small adjustement to this default behavior. Prettier would read
insertFinalNewline
option from editorconfig (for Handelbars / Ember files only). When the option is set to true, Prettier would add a final newline. When set to false, the final newline would be removed.This PR is still a draft. Indeed I'd like this option to be read only from editorconfig (not user configurable). But I don't know how to do that and I would have to spend some time on it. So, I prefer to discuss the PR first not to engage too much work in case you don't want to go down that path. May you let me know if you are okay with the direction it is taking?
Links
Checklist
docs/
directory).changelog_unreleased/*/XXXX.md
file followingchangelog_unreleased/TEMPLATE.md
.✨Try the playground for this PR✨