From aab300844f67851f48edb3deaac69bb24b26ca5a Mon Sep 17 00:00:00 2001 From: James Long Date: Thu, 12 Jan 2017 14:53:12 -0500 Subject: [PATCH] Use group instead of conditionalGroup --- src/printer.js | 32 ++++++++----------- .../__snapshots__/jsfmt.spec.js.snap | 16 +++------- .../__snapshots__/jsfmt.spec.js.snap | 16 +++------- .../prettier/__snapshots__/jsfmt.spec.js.snap | 8 ++--- 4 files changed, 25 insertions(+), 47 deletions(-) diff --git a/src/printer.js b/src/printer.js index d2372cce..5fd4d66f 100644 --- a/src/printer.js +++ b/src/printer.js @@ -1866,25 +1866,19 @@ function printExportDeclaration(path, options, print) { } else { parts.push( decl.exportKind === "type" ? "type " : "", - conditionalGroup([ - concat([ - shouldPrintSpaces ? "{ " : "{", - join(", ", path.map(print, "specifiers")), - shouldPrintSpaces ? " }" : "}" - ]), - concat([ - "{", - indent( - options.tabWidth, - concat([ - hardline, - join(concat([",", hardline]), path.map(print, "specifiers")) - ]) - ), - hardline, - "}" - ]) - ]) + group(concat([ + "{", + indent( + options.tabWidth, + concat([ + options.bracketSpacing ? line : softline, + join(concat([",", options.bracketSpacing ? line : softline]), + path.map(print, "specifiers")) + ]) + ), + options.bracketSpacing ? line : softline, + "}" + ])) ); } diff --git a/tests/declare_export/__snapshots__/jsfmt.spec.js.snap b/tests/declare_export/__snapshots__/jsfmt.spec.js.snap index e524afbc..d9a5c75e 100644 --- a/tests/declare_export/__snapshots__/jsfmt.spec.js.snap +++ b/tests/declare_export/__snapshots__/jsfmt.spec.js.snap @@ -352,15 +352,11 @@ declare export { * @flow */ -<<<<<<< bbe2524dab164d43febc1a8d549a76e26eb9d483 -declare export { numberValue1, numberValue2 as numberValue2_renamed } from \"ES6_ExportFrom_Source1\"; -" -======= declare export { numberValue1, numberValue2 as numberValue2_renamed -} from \"ES6_ExportFrom_Source1\";" ->>>>>>> Break long `exports` into multiple lines. +} from \"ES6_ExportFrom_Source1\"; +" `; exports[`test ES6_ExportFrom_Intermediary2.js 1`] = ` @@ -379,15 +375,11 @@ declare export { * @flow */ -<<<<<<< bbe2524dab164d43febc1a8d549a76e26eb9d483 -declare export { numberValue1, numberValue2 as numberValue2_renamed2 } from \"ES6_ExportFrom_Source2\"; -" -======= declare export { numberValue1, numberValue2 as numberValue2_renamed2 -} from \"ES6_ExportFrom_Source2\";" ->>>>>>> Break long `exports` into multiple lines. +} from \"ES6_ExportFrom_Source2\"; +" `; exports[`test ES6_ExportFrom_Source1.js 1`] = ` diff --git a/tests/es6modules/__snapshots__/jsfmt.spec.js.snap b/tests/es6modules/__snapshots__/jsfmt.spec.js.snap index a9449b82..f5c5abbe 100644 --- a/tests/es6modules/__snapshots__/jsfmt.spec.js.snap +++ b/tests/es6modules/__snapshots__/jsfmt.spec.js.snap @@ -429,15 +429,11 @@ export { * @flow */ -<<<<<<< bbe2524dab164d43febc1a8d549a76e26eb9d483 -export { numberValue1, numberValue2 as numberValue2_renamed } from \"ES6_ExportFrom_Source1\"; -" -======= export { numberValue1, numberValue2 as numberValue2_renamed -} from \"ES6_ExportFrom_Source1\";" ->>>>>>> Break long `exports` into multiple lines. +} from \"ES6_ExportFrom_Source1\"; +" `; exports[`test ES6_ExportFrom_Intermediary2.js 1`] = ` @@ -456,15 +452,11 @@ export { * @flow */ -<<<<<<< bbe2524dab164d43febc1a8d549a76e26eb9d483 -export { numberValue1, numberValue2 as numberValue2_renamed2 } from \"ES6_ExportFrom_Source2\"; -" -======= export { numberValue1, numberValue2 as numberValue2_renamed2 -} from \"ES6_ExportFrom_Source2\";" ->>>>>>> Break long `exports` into multiple lines. +} from \"ES6_ExportFrom_Source2\"; +" `; exports[`test ES6_ExportFrom_Source1.js 1`] = ` diff --git a/tests/prettier/__snapshots__/jsfmt.spec.js.snap b/tests/prettier/__snapshots__/jsfmt.spec.js.snap index 1bcf18dc..287f35f0 100644 --- a/tests/prettier/__snapshots__/jsfmt.spec.js.snap +++ b/tests/prettier/__snapshots__/jsfmt.spec.js.snap @@ -1,4 +1,3 @@ -<<<<<<< bbe2524dab164d43febc1a8d549a76e26eb9d483 exports[`test directives.js 1`] = ` "\"use strict\"; @@ -12,7 +11,8 @@ function fn() { \"use strict\"; } " -======= +`; + exports[`test exports.js 1`] = ` "export { value1, value2 as value2_renamed, value3, value4 as value4_renamed, value5 } from \"exports\"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -22,8 +22,8 @@ export { value3, value4 as value4_renamed, value5 -} from \"exports\";" ->>>>>>> Break long `exports` into multiple lines. +} from \"exports\"; +" `; exports[`test optional-type-name.js 1`] = `