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

Comment in last line of YAML files gets leading newline trimmed #16206

Open
TheDevMinerTV opened this issue Apr 5, 2024 · 1 comment
Open
Labels
lang:yaml Issues affecting YAML type:bug Issues identifying ugly output, or a defect in the program

Comments

@TheDevMinerTV
Copy link

Prettier 3.2.4
Playground link

--parser yaml

Input:

---
a: ''

# 

Output:

---
a: ""
#

Expected output:

a: ""

#

Why?

If there's any other line after the comment it doesn't get touched. If the comment is the last line in a file, it gets the previous newline removed for some reason.

@sosukesuzuki
Copy link
Member

Thanks for the report. This should be consistent in behavior between last and non-last comments.

@sosukesuzuki sosukesuzuki added type:bug Issues identifying ugly output, or a defect in the program lang:yaml Issues affecting YAML labels Apr 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lang:yaml Issues affecting YAML type:bug Issues identifying ugly output, or a defect in the program
Projects
None yet
Development

No branches or pull requests

2 participants