Skip to content

fix(glimmer): Add newline at the end of files#6243

Closed
dcyriller wants to merge 5 commits intoprettier:masterfrom
dcyriller:glimmer-eof
Closed

fix(glimmer): Add newline at the end of files#6243
dcyriller wants to merge 5 commits intoprettier:masterfrom
dcyriller:glimmer-eof

Conversation

@dcyriller
Copy link
Collaborator

This PR ensures a trailing newline is added in hbs files.

// Input
Hello

// Output (Prettier stable)
Hello
// Output (Prettier master)
Hello
  • I’ve added tests to confirm my change works.
  • (If the change is user-facing) I’ve added my changes to the CHANGELOG.unreleased.md file following the template.
  • I’ve read the contributing guidelines.

Try the playground for this PR

@dcyriller dcyriller changed the title glimmer: Add eof fix(glimmer): Add eof Jun 21, 2019
@dcyriller dcyriller changed the title fix(glimmer): Add eof fix(glimmer): Add newline at the end of files Jun 22, 2019
@dcyriller
Copy link
Collaborator Author

Just to be clear: why this change? Because Prettier formats every other language this way.

@Turbo87
Copy link

Turbo87 commented Jun 28, 2019

@dcyriller this goes against https://github.com/ember-cli/ember-new-output/blob/master/.editorconfig#L17

The reason for not having a newline at the end is that it will create an extra DOM text node which in most cases would be unnecessary.

@dcyriller dcyriller closed this Jul 3, 2019
@dcyriller dcyriller deleted the glimmer-eof branch July 3, 2019 15:00
@dcyriller
Copy link
Collaborator Author

I've hoped for a moment that https://github.com/josephfrazier/editorconfig-to-prettier would have supported the editorconfig option: insert_final_newline. It would have allowed me to append / remove a final newline depending on this option. But the package doesn't have the option (on purpose I guess), so I can't make the final newline configurable through .editorconfig file.

An alternative would be to submit an RFC in ember community to actually add a newline at the end of hbs files. We could strip trailing whitespace in template compilation as suggested here: ember-cli/ember-cli#3440.

@lock lock bot added the locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. label Oct 1, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 1, 2019
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants