Skip to content

Commit

Permalink
fix: few issues leading to invalid output template
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanPiercey committed Oct 11, 2021
1 parent dad6203 commit 0b4700c
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<div data-foo=a ? b : c data-bar=a ? b : c/>
<div data-foo=(a ? b : c) data-bar=(a ? b : c)/>
Original file line number Diff line number Diff line change
@@ -1 +1 @@
div data-foo=a ? b : c data-bar=a ? b : c
div data-foo=(a ? b : c) data-bar=(a ? b : c)
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<div data-foo=a ? b : c data-bar=a ? b : c/>
<div data-foo=(a ? b : c) data-bar=(a ? b : c)/>
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
$ var foo = {
bar: "foo",
};
$ {
var foo = {
bar: "foo",
};
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
$ var foo = {
bar: "foo",
};
$ {
var foo = {
bar: "foo",
};
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
$ var foo = {
bar: "foo",
};
$ {
var foo = {
bar: "foo",
};
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
$ var foo = {
bar: "foo",
};
$ {
var foo = {
bar: "foo",
};
}
13 changes: 13 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,18 @@ export const parsers: Record<string, Parser<Node>> = {
output: "source",
sourceMaps: false,
writeVersionComment: false,
babelConfig: {
caller: { name: "@marko/prettier" },
babelrc: false,
configFile: false,
parserOpts: {
allowUndeclaredExports: true,
allowAwaitOutsideFunction: true,
allowReturnOutsideFunction: true,
allowImportExportEverywhere: true,
plugins: ["exportDefaultFrom", "importAssertions"],
},
},
});

opts.originalText = text;
Expand Down Expand Up @@ -322,6 +334,7 @@ export const printers: Record<string, Printer<Node>> = {
t.isMarkoAttribute(childNode) &&
(childNode.name === "class" || childNode.name === "id") &&
t.isStringLiteral(childNode.value) &&
!childNode.modifier &&
shorthandIdOrClassReg.test(childNode.value.value)
) {
const symbol = childNode.name === "class" ? "." : "#";
Expand Down
2 changes: 1 addition & 1 deletion src/utils/outer-code-matches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ const unenclosedPatterns: Pattern[] = [
{
// Symbol operators
match:
/\s*(?:[\^~%:!]|\+{1,2}|\*{1,2}|-(?:-(?!\s))?|&{1,2}|\|{1,2}|\?{1,2}|[!=]={0,2}|<{2,3}|>{2,3}|<=?|>=)\s*/y,
/\s*(?:[\^~%!]|\+{1,2}|\*{1,2}|-(?:-(?!\s))?|&{1,2}|\|{1,2}|!={0,2}|===?|<{2,3}|>{2,3}|<=?|>=)\s*/y,
},
].concat(enclosedPatterns);

Expand Down

0 comments on commit 0b4700c

Please sign in to comment.