diff --git a/src/printer.js b/src/printer.js index aada11148..d1bfa6579 100644 --- a/src/printer.js +++ b/src/printer.js @@ -3556,6 +3556,7 @@ function exprNeedsASIProtection(node) { node.type === "TemplateLiteral" || node.type === "TemplateElement" || node.type === "JSXElement" || + node.type === "BindExpression" || node.type === "RegExpLiteral" || (node.type === "Literal" && node.pattern) || (node.type === "Literal" && node.regex); diff --git a/tests/no-semi-babylon-extensions/__snapshots__/jsfmt.spec.js.snap b/tests/no-semi-babylon-extensions/__snapshots__/jsfmt.spec.js.snap new file mode 100644 index 000000000..9a0311a25 --- /dev/null +++ b/tests/no-semi-babylon-extensions/__snapshots__/jsfmt.spec.js.snap @@ -0,0 +1,19 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`no-semi.js 1`] = ` +a +;::b.c +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +a; +::b.c; + +`; + +exports[`no-semi.js 2`] = ` +a +;::b.c +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +a +;::b.c + +`; diff --git a/tests/no-semi-babylon-extensions/jsfmt.spec.js b/tests/no-semi-babylon-extensions/jsfmt.spec.js new file mode 100644 index 000000000..5bd38cc62 --- /dev/null +++ b/tests/no-semi-babylon-extensions/jsfmt.spec.js @@ -0,0 +1,2 @@ +run_spec(__dirname, { parser: "babylon" }); +run_spec(__dirname, { semi: false, parser: "babylon" }); diff --git a/tests/no-semi-babylon-extensions/no-semi.js b/tests/no-semi-babylon-extensions/no-semi.js new file mode 100644 index 000000000..831940e9d --- /dev/null +++ b/tests/no-semi-babylon-extensions/no-semi.js @@ -0,0 +1,2 @@ +a +;::b.c diff --git a/tests/no-semi/__snapshots__/jsfmt.spec.js.snap b/tests/no-semi/__snapshots__/jsfmt.spec.js.snap index e85646e42..1a3248604 100644 --- a/tests/no-semi/__snapshots__/jsfmt.spec.js.snap +++ b/tests/no-semi/__snapshots__/jsfmt.spec.js.snap @@ -103,8 +103,6 @@ x; (x, y) => x class X {} [1, 2, 3].forEach(fn) -// TODO: enable lang features -// x; ::b.c // TODO: upgrade parser // class A { // async; // The semicolon is *not* necessary @@ -269,8 +267,6 @@ x; class X {} [1, 2, 3].forEach(fn); -// TODO: enable lang features -// x; ::b.c // TODO: upgrade parser // class A { // async; // The semicolon is *not* necessary @@ -424,8 +420,6 @@ x; (x, y) => x class X {} [1, 2, 3].forEach(fn) -// TODO: enable lang features -// x; ::b.c // TODO: upgrade parser // class A { // async; // The semicolon is *not* necessary @@ -590,8 +584,6 @@ x class X {} ;[1, 2, 3].forEach(fn) -// TODO: enable lang features -// x; ::b.c // TODO: upgrade parser // class A { // async; // The semicolon is *not* necessary @@ -745,8 +737,6 @@ x; (x, y) => x class X {} [1, 2, 3].forEach(fn) -// TODO: enable lang features -// x; ::b.c // TODO: upgrade parser // class A { // async; // The semicolon is *not* necessary @@ -911,8 +901,6 @@ x class X {} ;[1, 2, 3].forEach(fn) -// TODO: enable lang features -// x; ::b.c // TODO: upgrade parser // class A { // async; // The semicolon is *not* necessary diff --git a/tests/no-semi/no-semi.js b/tests/no-semi/no-semi.js index 8f729135f..7e85d6f3c 100644 --- a/tests/no-semi/no-semi.js +++ b/tests/no-semi/no-semi.js @@ -19,8 +19,6 @@ x; (x, y) => x class X {} [1, 2, 3].forEach(fn) -// TODO: enable lang features -// x; ::b.c // TODO: upgrade parser // class A { // async; // The semicolon is *not* necessary