From a8ca2b21f4a8d610039e8254630cfc80be8d0292 Mon Sep 17 00:00:00 2001 From: Kevin Gibbons Date: Thu, 19 Jan 2017 14:30:36 -0800 Subject: [PATCH] Add semicolon to more default exports (#343) --- src/printer.js | 6 +++--- tests/es6modules/__snapshots__/jsfmt.spec.js.snap | 4 ++-- tests/import_typeof/__snapshots__/jsfmt.spec.js.snap | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/printer.js b/src/printer.js index 82635eec..345ab45f 100644 --- a/src/printer.js +++ b/src/printer.js @@ -1823,9 +1823,9 @@ function printExportDeclaration(path, options, print) { if ( decl.type === "ExportDefaultDeclaration" && - (decl.declaration.type == "Identifier" || - decl.declaration.type === "CallExpression" || - typeIsFunction(decl.declaration.type)) + (decl.declaration.type !== "ClassDeclaration" && + decl.declaration.type !== "FunctionDeclaration" && + decl.declaration.type !== "FunctionExpression") ) { parts.push(";"); } diff --git a/tests/es6modules/__snapshots__/jsfmt.spec.js.snap b/tests/es6modules/__snapshots__/jsfmt.spec.js.snap index efd59b9c..6d3b824a 100644 --- a/tests/es6modules/__snapshots__/jsfmt.spec.js.snap +++ b/tests/es6modules/__snapshots__/jsfmt.spec.js.snap @@ -324,7 +324,7 @@ export var str = \'asdf\'; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /* @flow */ -export default 42 +export default 42; export var str = \"asdf\"; " `; @@ -1366,7 +1366,7 @@ exports[`test export_default_function_expression.js 1`] = ` "export default (function() {}); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ export default function() { -}; +} " `; diff --git a/tests/import_typeof/__snapshots__/jsfmt.spec.js.snap b/tests/import_typeof/__snapshots__/jsfmt.spec.js.snap index 39cb6339..e67223f9 100644 --- a/tests/import_typeof/__snapshots__/jsfmt.spec.js.snap +++ b/tests/import_typeof/__snapshots__/jsfmt.spec.js.snap @@ -102,7 +102,7 @@ export default 42; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /* @flow */ -export default 42 +export default 42; " `;