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

[bug] [yaml] list indent fix can result in invalid yaml or change the meaning of existing yaml #16183

Open
michaele-blend opened this issue Mar 28, 2024 · 0 comments

Comments

@michaele-blend
Copy link

Prettier 3.2.5
Playground link

--parser yaml

Input:

list:
- with:
    config-yml: |2
      hello: world

Output:

list:
  - with:
      config-yml: |2
      hello: world

Expected output:

list:
  - with:
      config-yml: |2
        hello: world

Why?

my expectation is that prettier does not change the meaning of a yaml document.
the list indent fix here changes the meaning of the document, the config-yml values are promoted, and with gains new keys.
this can also result in invalid yaml documents, if the multi-line string is not also valid yaml. for instance,

list:
- with:
    config-yml: |2
      hello

will be transformed into

list:
  - with:
      config-yml: |2
      hello

which is not a valid yaml document.

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