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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON files are saved with no newline at the end of file #1382

Closed
kyleoliveiro opened this issue May 25, 2018 · 5 comments · Fixed by #7039
Closed

JSON files are saved with no newline at the end of file #1382

kyleoliveiro opened this issue May 25, 2018 · 5 comments · Fixed by #7039

Comments

@kyleoliveiro
Copy link

- Do you want to request a feature or report a bug?
Bug

- What is the current behavior?
Netlify CMS saves JSON data without a newline at the end of the file.

- If the current behavior is a bug, please provide the steps to reproduce.
Configure a collection type with format: "json" and extension: "json", then create and publish a new post in the Dashboard.

- What is the expected behavior?
JSON file should created with newline at the end of the file.

@kyleoliveiro kyleoliveiro changed the title JSON files JSON files are saved with no newline at the end of file May 25, 2018
@erquhart
Copy link
Contributor

erquhart commented May 25, 2018

This is being handled under #1302. We can leave this issue open since that PR doesn't have an issue.

@stale
Copy link

stale bot commented Oct 29, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the status: stale label Oct 29, 2019
@aaronfranke
Copy link

aaronfranke commented Apr 25, 2020

Any update? #1302 was closed, but it seemed mostly good to go.

To answer the question from @erquhart:

any reason not to add a trailing newline at the file level, regardless of type?

The POSIX definition of a text file includes that it should end with a newline character. The question is whether or not the file in question is treated as a text file. If the file is a text file, then it should have the trailing newline character.

If the file does not have a trailing newline character, then by POSIX definition we can only say it is a stream of bytes, and not a text file.

@tremby
Copy link

tremby commented May 27, 2021

Same with YAML files.

I'll add that git complains when such files don't end with newline characters, and many editors will automatically add it in again, which means diffs are going to be noisy if there's a combination of Netlify-CMS-driven edits and developer-driven edits.

@erezrokah
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants