From c28df3ac4bdd4a09783d77e0caf26995284dfb63 Mon Sep 17 00:00:00 2001 From: Brad Cornes Date: Mon, 24 Jan 2022 20:50:48 +0000 Subject: [PATCH] Use babel to parse JS expressions in Vue/Angular (#2) --- src/index.js | 4 +++- tests/test.js | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 863dccf4..7a3c4beb 100644 --- a/src/index.js +++ b/src/index.js @@ -166,7 +166,9 @@ function transformHtml(attributes, computedAttributes = []) { continue } - let ast = recast.parse(`let __prettier_temp__ = ${attr.value}`) + let ast = recast.parse(`let __prettier_temp__ = ${attr.value}`, { + parser: prettierParserBabel.parsers.babel, + }) let didChange = false astTypes.visit(ast, { diff --git a/tests/test.js b/tests/test.js index 8b409e36..f402f57d 100644 --- a/tests/test.js +++ b/tests/test.js @@ -96,6 +96,7 @@ let vue = [ t`
`, t`
`, t`
`, + t`
`, t`
`, t`
`, t`
`,