Repository: jlongster/prettier (js)

Issue:
Semicolon being stripped out of export statement
In versions 0.0.8 and 0.0.7 (at least), the following export statement gets its semicolon stripped:

```
export default connect(mapStateToProps)(MyComponent);
```
becomes
```
export default connect(mapStateToProps)(MyComponent)
```

More info and a test case here: https://github.com/jlongster/prettier/pull/101#issuecomment-273381178

Pull request description:
Fix missing semi when default exporting CallExpression
Fixes #288

Patch:
diff --git a/src/printer.js b/src/printer.js
index 66e58d462..78ed5c081 100644
--- a/src/printer.js
+++ b/src/printer.js
@@ -1843,7 +1843,8 @@ function printExportDeclaration(path, options, print) {
 
     if (
       decl.type === "ExportDefaultDeclaration" &&
-        decl.declaration.type == "Identifier"
+        (decl.declaration.type == "Identifier" ||
+          decl.declaration.type === "CallExpression")
     ) {
       parts.push(";");
     }


Test patch:
diff --git a/tests/arrows/__snapshots__/jsfmt.spec.js.snap b/tests/arrows/__snapshots__/jsfmt.spec.js.snap
index 424b07289..8ae8dc655 100644
--- a/tests/arrows/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/arrows/__snapshots__/jsfmt.spec.js.snap
@@ -39,7 +39,7 @@ new (() => {});
 typeof (() => {
 });
 export default (() => {
-})()
+})();
 (() => {
 })()\`\`;
 (() => {
diff --git a/tests/es6modules/__snapshots__/jsfmt.spec.js.snap b/tests/es6modules/__snapshots__/jsfmt.spec.js.snap
index 3d36a0533..df441d6b2 100644
--- a/tests/es6modules/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/es6modules/__snapshots__/jsfmt.spec.js.snap
@@ -1347,6 +1347,13 @@ import {
 "
 `;
 
+exports[`test export_default_call_expression.js 1`] = `
+"export default connect(mapStateToProps)(MyComponent);
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+export default connect(mapStateToProps)(MyComponent);
+"
+`;
+
 exports[`test test_imports_are_frozen.js 1`] = `
 "/* @flow */
 
diff --git a/tests/es6modules/export_default_call_expression.js b/tests/es6modules/export_default_call_expression.js
new file mode 100644
index 000000000..c3fae600c
--- /dev/null
+++ b/tests/es6modules/export_default_call_expression.js
@@ -0,0 +1,1 @@
+export default connect(mapStateToProps)(MyComponent);
diff --git a/tests/function/__snapshots__/jsfmt.spec.js.snap b/tests/function/__snapshots__/jsfmt.spec.js.snap
index 8ad3ba76d..2cd319933 100644
--- a/tests/function/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/function/__snapshots__/jsfmt.spec.js.snap
@@ -376,7 +376,7 @@ new (function() {});
 typeof (function() {
 });
 export default (function() {
-})()
+})();
 (function() {
 })()\`\`;
 (function() {