Fix space missing before `,` on export with bracket spacing off (#278)

I copy and pasted the code for arrays which doesn't have this problem. Would be nice to come up with an abstraction for a list of stuff separated by commas. It happens a lot of time and right now it's duplicated everywhere.

Fixes #255
master
Christopher Chedeau 2017-01-17 14:12:42 -08:00 committed by James Long
parent 2dac27f777
commit b580a18f30
4 changed files with 77 additions and 2 deletions

View File

@ -1857,7 +1857,7 @@ function printExportDeclaration(path, options, print) {
} else {
parts.push(
decl.exportKind === "type" ? "type " : "",
group(
multilineGroup(
concat([
"{",
indent(
@ -1865,7 +1865,7 @@ function printExportDeclaration(path, options, print) {
concat([
options.bracketSpacing ? line : softline,
join(
concat([ ",", options.bracketSpacing ? line : softline ]),
concat([ ",", line ]),
path.map(print, "specifiers")
)
])

View File

@ -1,3 +1,57 @@
exports[`test bracket.js 1`] = `
"export {
runTaskForChanged,
description,
someOtherLabel,
thatMakes,
itGo,
multiLine,
andMore,
soWeCanGetItTo80Columns
};
export {fitsIn, oneLine};
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export {
runTaskForChanged,
description,
someOtherLabel,
thatMakes,
itGo,
multiLine,
andMore,
soWeCanGetItTo80Columns
};
export { fitsIn, oneLine };
"
`;
exports[`test bracket.js 2`] = `
"export {
runTaskForChanged,
description,
someOtherLabel,
thatMakes,
itGo,
multiLine,
andMore,
soWeCanGetItTo80Columns
};
export {fitsIn, oneLine};
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export {
runTaskForChanged,
description,
someOtherLabel,
thatMakes,
itGo,
multiLine,
andMore,
soWeCanGetItTo80Columns
};
export { fitsIn, oneLine };
"
`;
exports[`test empty.js 1`] = `
"export {};
export {} from \".\";
@ -6,3 +60,12 @@ export {};
export {} from \".\";
"
`;
exports[`test empty.js 2`] = `
"export {};
export {} from \".\";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export {};
export {} from \".\";
"
`;

11
tests/export/bracket.js Normal file
View File

@ -0,0 +1,11 @@
export {
runTaskForChanged,
description,
someOtherLabel,
thatMakes,
itGo,
multiLine,
andMore,
soWeCanGetItTo80Columns
};
export {fitsIn, oneLine};

View File

@ -1 +1,2 @@
run_spec(__dirname);
run_spec(__dirname, {bracketsSpacing: false});