dprint-plugin-prettier icon indicating copy to clipboard operation
dprint-plugin-prettier copied to clipboard

Parse Error on Astro File

Open Sirius902 opened this issue 1 year ago • 2 comments

The below Astro file will fail to format with this error, however formatting it with prettier using prettier-plugin-astro directly parses the file successfully.

Message: ParseError: (0 , $029a36b82dce9f90$var$import__2.default) is not a function
    at $72712c1d1f727ace$var$error (dprint:prettier.js:150:17)
    at $8edc5f76a317f62c$var$Parser.error (dprint:prettier.js:415:56)
    at $8edc5f76a317f62c$var$Parser.acorn_error (dprint:prettier.js:409:14)
    at $029a36b82dce9f90$var$read_expression (dprint:prettier.js:6519:16)
    at $dd20ca6627ece4f3$var$mustache (dprint:prettier.js:9673:80)
    at new $8edc5f76a317f62c$var$Parser (dprint:prettier.js:382:57)
    at Object.$8edc5f76a317f62c$var$parse (dprint:prettier.js:491:20)
    at Object.$65e641842dbfc372$var$parse [as parse] (dprint:prettier.js:84132:71)
    at Object.h [as parse] (dprint:prettier.js:67890:36)
    at N (dprint:prettier.js:68555:51)
Had 1 error(s) formatting.
---

---

<html lang="en">
  <body>
    {[1, 2, 3].map((n) => <div>{n}</div>)}
  </body>
</html>

It is worth noting that the following file parses successfully unlike the above file.

---

---

<html lang="en">
  <body>
    {[1, 2, 3].map((n) => n)}
  </body>
</html>

Sirius902 avatar Oct 05 '23 00:10 Sirius902

Has anyone found any workarounds to get Astro formatting with JSX(?) working?

its-jman avatar Oct 10 '23 23:10 its-jman

Try this plugin: https://github.com/g-plane/markup_fmt . It supports JSX in Astro.

g-plane avatar Feb 18 '24 12:02 g-plane