dprint-plugin-prettier
dprint-plugin-prettier copied to clipboard
Parse Error on Astro File
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>
Has anyone found any workarounds to get Astro formatting with JSX(?) working?
Try this plugin: https://github.com/g-plane/markup_fmt . It supports JSX in Astro.