Enforcing newlines in template files results in unwanted Nodes#3440
Enforcing newlines in template files results in unwanted Nodes#3440stefanpenner merged 1 commit intoember-cli:masterfrom
Conversation
|
Maybe we should strip trailing whitespace in template compilation? |
|
@lukemelia That could break cases where a component's |
Enforcing newlines in template files results in unwanted Nodes
|
@jclem Not to impose (I know there's a good chance you're no longer in the ecosystem) but I have been curious whether you or anyone else have been able to reproduce this text-nodes issue with modern versions of Ember. One of my colleagues has been frustrated by this setting* and has been insistent that he can't reproduce the original issue with our current version of Ember (i.e., if there's an *Even if we disable the EditorConfig rule locally, it's still enforced by TemplateLint + Prettier in compliance with the blueprint default, as was noted in prettier/prettier#6243. |
|
do you think it's worth proposing no empty newline? or a setting on using I've been using mainmatter's minifier on my projects, and I'm very happy with it -- I think we should built it in to |
|
@NullVoxPopuli Thanks for the insight. We may be a ways away from fully getting on the |
|
ember-hbs-minifier supports 3.20+, so that could perhaps work for your existing stuff today? |
|
@NullVoxPopuli On reread, either I'm not quite grokking your solution or I think you've misunderstood our issue. There has been – since this 2015 PR – a rule that already causes Prettier to complain if there's a newline at the end of a .hbs (which is contrary to how Prettier handles every other file). We think that rule is based on an outdated concern about text nodes (we can't reproduce the issue @jclem originally complained about when he submitted this PR). I see how a minifier would help with cleaning up empty text nodes... which would help if we were seeing these end-of-template text nodes, but we're not, even if we disable Prettier and add one closing Ultimately though, moving to the (For context: we'd previously disabled Prettier from the app blueprint, we recently started looking at applying it and were surprised it was trimming ending newlines only for .hbs, and enforcing them everywhere else.) |
|
I'm no longer in the Ember ecosystem, so I'm sorry that I can't help out here, any longer! I hope all is well in Ember-world, though 😄 |
The default
.editorconfigof Ember CLI tells an editor to append new lines to the end of files on write. This can cause surprising behavior when I do not see a new line at the end of my template file, but my rendered component has an extraTextnode containing a new line at the end of it.Appending a newline seems fine for any file that's not a template file, but it can be problematic when applied to templates.