Skip to content

Commit

Permalink
Break long exports into multiple lines.
Browse files Browse the repository at this point in the history
Ref #19.
  • Loading branch information
bnjmnt4n authored and jlongster committed Jan 12, 2017
1 parent bbe2524 commit 1549936
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 3 deletions.
22 changes: 19 additions & 3 deletions src/printer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1866,9 +1866,25 @@ function printExportDeclaration(path, options, print) {
} else {
parts.push(
decl.exportKind === "type" ? "type " : "",
shouldPrintSpaces ? "{ " : "{",
join(", ", path.map(print, "specifiers")),
shouldPrintSpaces ? " }" : "}"
conditionalGroup([
concat([
shouldPrintSpaces ? "{ " : "{",
join(", ", path.map(print, "specifiers")),
shouldPrintSpaces ? " }" : "}"
]),
concat([
"{",
indent(
options.tabWidth,
concat([
hardline,
join(concat([",", hardline]), path.map(print, "specifiers"))
])
),
hardline,
"}"
])
])
);
}

Expand Down
14 changes: 14 additions & 0 deletions tests/declare_export/__snapshots__/jsfmt.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,15 @@ 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.
`;
exports[`test ES6_ExportFrom_Intermediary2.js 1`] = `
Expand All @@ -372,8 +379,15 @@ 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.
`;
exports[`test ES6_ExportFrom_Source1.js 1`] = `
Expand Down
14 changes: 14 additions & 0 deletions tests/es6modules/__snapshots__/jsfmt.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -429,8 +429,15 @@ 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.
`;
exports[`test ES6_ExportFrom_Intermediary2.js 1`] = `
Expand All @@ -449,8 +456,15 @@ 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.
`;
exports[`test ES6_ExportFrom_Source1.js 1`] = `
Expand Down
13 changes: 13 additions & 0 deletions tests/prettier/__snapshots__/jsfmt.spec.js.snap
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<<<<<<< bbe2524dab164d43febc1a8d549a76e26eb9d483
exports[`test directives.js 1`] = `
"\"use strict\";
Expand All @@ -11,6 +12,18 @@ function fn() {
\"use strict\";
}
"
=======
exports[`test exports.js 1`] = `
"export { value1, value2 as value2_renamed, value3, value4 as value4_renamed, value5 } from \"exports\";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export {
value1,
value2 as value2_renamed,
value3,
value4 as value4_renamed,
value5
} from \"exports\";"
>>>>>>> Break long `exports` into multiple lines.
`;
exports[`test optional-type-name.js 1`] = `
Expand Down
1 change: 1 addition & 0 deletions tests/prettier/exports.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { value1, value2 as value2_renamed, value3, value4 as value4_renamed, value5 } from "exports";

0 comments on commit 1549936

Please sign in to comment.