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

Format YAML without conflict with prettier #153

Open
MPV opened this issue Nov 24, 2023 · 3 comments · May be fixed by #158
Open

Format YAML without conflict with prettier #153

MPV opened this issue Nov 24, 2023 · 3 comments · May be fixed by #158

Comments

@MPV
Copy link

MPV commented Nov 24, 2023

Hi,
Would it be possible to output YAML in a way that doesn't clash with prettier?

pin-github-actions wants files formatted like this:

-    needs: [changed-files]
+    needs: [ changed-files ]

prettier formats them back like this:

-    needs: [ changed-files ]
+    needs: [changed-files]
@ericcornelissen
Copy link

ericcornelissen commented Dec 19, 2023

I'm facing a similar issue - more generally I would expect this tool to not change formatting whatsoever. Going for prettier formatting might clash with other formatters (or configurations) used elsewhere.

I'm encountering the following specific unexpected reformatting:

  example: >
-   sit amet justo donec enim diam vulputate ut pharetra sit amet aliquam id diam
-   maecenas ultricies mi eget mauris pharetra et ultrices neque ornare aenean
+   sit amet justo donec enim diam vulputate ut pharetra sit amet aliquam id diam maecenas ultricies mi eget mauris pharetra et ultrices neque ornare aenean

@MPV
Copy link
Author

MPV commented Dec 20, 2023

more generally I would expect this tool to not change formatting whatsoever.

I agree. 🙂

@mheap
Copy link
Owner

mheap commented Dec 20, 2023

Unfortunately this is a side effect of parsing the YAML file, then serializing it again. We could try parsing to get the data, then using search + replace on the source file to maintain formatting but that could be brittle.

If anyone wants to try raising a PR with that approach to preserve formatting, I'd be happy to review

@ericcornelissen ericcornelissen linked a pull request Mar 24, 2024 that will close this issue
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

Successfully merging a pull request may close this issue.

3 participants