Skip to content

Commit

Permalink
fix: format script tag value with arrow fn
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanPiercey committed Dec 13, 2024
1 parent efa2260 commit a229a9d
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@
if (test) {
}
</script>

<script>
console.log("Foo");
if (test) {
}
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,10 @@ script
if (test) {
}
--

script
--
console.log("Foo");
if (test) {
}
--
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@
if (test) {
}
</script>

<script>
console.log("Foo");
if (test) {
}
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@
if (test) {
}
</script>

<script>
console.log("Foo");
if (test) {
}
</script>
7 changes: 7 additions & 0 deletions src/__tests__/fixtures/script-value-attribute.marko
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,10 @@
}
}/>

<script value=() => {
console.log('Foo');
if (test) {
}
}/>
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -675,9 +675,9 @@ export const printers: Record<string, Printer<types.Node>> = {
attrNode.type === "MarkoAttribute" &&
attrNode.name === "value" &&
!node.body.body.length &&
attrNode.value.type === "FunctionExpression" &&
(attrNode.value.type === "FunctionExpression" ||
attrNode.value.type === "ArrowFunctionExpression") &&
!(
attrNode.value.async ||
attrNode.value.generator ||
attrNode.value.returnType ||
attrNode.value.typeParameters
Expand Down

0 comments on commit a229a9d

Please sign in to comment.