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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow configuration for final newline #547

Open
ussu opened this issue Sep 8, 2022 · 0 comments
Open

Allow configuration for final newline #547

ussu opened this issue Sep 8, 2022 · 0 comments

Comments

@ussu
Copy link

ussu commented Sep 8, 2022

Hi 馃憢馃徏

When running ember-intl-analyzer --fix with JSON translation files, I realised that the formatter trims final newline in translation files

From what I understand by reading the code, this is due to these few lines
Parsing the JSON trims the newline

It would be great if we could add the newline back into the file :)

updatedTranslations = JSON.stringify(translations, null, 2) + '\n';

This would make the behaviour consistent with YAML translation files, since YAML.stringify adds a final newline

In case there are people relying on the newline trimming, maybe we can add this as a configuration param, what do you think?

// config

export default {
  removeFinalNewline: true | false;
}

// index.js

updatedTranslations = JSON.stringify(translations, null, 2);
updatedTranslations += options.removeFinalNewline? '' : '\n';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant