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

Version 2.0.0 breaks prettier-plugin-erb #1032

Closed
akimthedream opened this issue Nov 4, 2021 · 2 comments
Closed

Version 2.0.0 breaks prettier-plugin-erb #1032

akimthedream opened this issue Nov 4, 2021 · 2 comments

Comments

@akimthedream
Copy link

Not sure if this is the right place or even plugin-ruby's fault, I just wanted to raise awareness about this open issue on prettier-plugin-erb:

adamzapasnik/prettier-plugin-erb#87

Using VSCode + Prettier extension for formatting html.erb files is broken with the new plugin-ruby version 2.0.0 (using prettier-plugin-erb 0.4.0). Follow the link for details. Thank you 🙂

@kddnewton
Copy link
Member

I appreciate the visibility! There's not too much I can do on my end here though, so I'm going to close this one. I'll see if I can reach out and help though.

@kblicharski
Copy link

@kddnewton

It appears that the author of the ERB plugin isn't actively maintaining the project currently. I would be interested in maintaining my own fork as I'd like to use it at work, but I'm not really familiar at all with how Prettier plugins work or are written. However, I did decide to do some poking around today, and this is what I determined.

The issue is that the prettier-plugin-erb does not work with Prettier 2.3 and above, due to this change introduced in that version. Naturally that causes upgrading to this version of prettier-plugin-ruby to fail with the same error as version 2 of this project depends on Prettier 2.3 or above.

The error originates on this line. formattedExpression I assume is supposed to be a single object, but instead is an array like so:

[
  { type: 'concat', parts: [ [Array] ] },
  { type: 'concat', parts: [ [Array], [Array] ] }
]

This naturally fails on formattedExpression.parts.pop(), leading to the catch block setting formatRaw = true, and leading to the subsequent failure on formattedExpression.trim() because formattedExpression is an array rather than a string.

I don't know how to solve this or progress further, because I don't really understand what embedTextToDoc is doing or where that is defined.

Any further pointers would be appreciated as I'm completely new to Prettier and open source JS development in general (not even sure how to properly debug JS libraries like this -- I've had to use print statements like so to get to this level of understanding).

@h14h h14h mentioned this issue Mar 6, 2024
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

3 participants