From 92795a0fdaaeeff1243fc42fb4add640690ffece Mon Sep 17 00:00:00 2001 From: Christopher Chedeau Date: Tue, 17 Jan 2017 14:12:56 -0800 Subject: [PATCH] Fix space missing before `,` on import with bracket spacing off (#279) Same fix as #278. We use the same (wrong) pattern in both places --- src/printer.js | 4 +- tests/import/__snapshots__/jsfmt.spec.js.snap | 53 +++++++++++++++++++ tests/import/brackets.js | 11 ++++ tests/import/jsfmt.spec.js | 2 + 4 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 tests/import/__snapshots__/jsfmt.spec.js.snap create mode 100644 tests/import/brackets.js create mode 100644 tests/import/jsfmt.spec.js diff --git a/src/printer.js b/src/printer.js index 349921bca..1b8944767 100644 --- a/src/printer.js +++ b/src/printer.js @@ -454,7 +454,7 @@ function genericPrintNoParens(path, options, print) { if (grouped.length > 0) { parts.push( - group( + multilineGroup( concat([ "{", indent( @@ -462,7 +462,7 @@ function genericPrintNoParens(path, options, print) { concat([ options.bracketSpacing ? line : softline, join( - concat([ ",", options.bracketSpacing ? line : softline ]), + concat([ ",", line ]), grouped ) ]) diff --git a/tests/import/__snapshots__/jsfmt.spec.js.snap b/tests/import/__snapshots__/jsfmt.spec.js.snap new file mode 100644 index 000000000..f428cf7fa --- /dev/null +++ b/tests/import/__snapshots__/jsfmt.spec.js.snap @@ -0,0 +1,53 @@ +exports[`test brackets.js 1`] = ` +"import { + runTaskForChanged, + description, + someOtherLabel, + thatMakes, + itGo, + multiLine, + andMore, + soWeCanGetItTo80Columns +} from \'.\'; +import {fitsIn, oneLine} from \'.\'; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +import { + runTaskForChanged, + description, + someOtherLabel, + thatMakes, + itGo, + multiLine, + andMore, + soWeCanGetItTo80Columns +} from \".\"; +import { fitsIn, oneLine } from \".\"; +" +`; + +exports[`test brackets.js 2`] = ` +"import { + runTaskForChanged, + description, + someOtherLabel, + thatMakes, + itGo, + multiLine, + andMore, + soWeCanGetItTo80Columns +} from \'.\'; +import {fitsIn, oneLine} from \'.\'; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +import { + runTaskForChanged, + description, + someOtherLabel, + thatMakes, + itGo, + multiLine, + andMore, + soWeCanGetItTo80Columns +} from \".\"; +import { fitsIn, oneLine } from \".\"; +" +`; diff --git a/tests/import/brackets.js b/tests/import/brackets.js new file mode 100644 index 000000000..a0e353e95 --- /dev/null +++ b/tests/import/brackets.js @@ -0,0 +1,11 @@ +import { + runTaskForChanged, + description, + someOtherLabel, + thatMakes, + itGo, + multiLine, + andMore, + soWeCanGetItTo80Columns +} from '.'; +import {fitsIn, oneLine} from '.'; diff --git a/tests/import/jsfmt.spec.js b/tests/import/jsfmt.spec.js new file mode 100644 index 000000000..b6e518ff7 --- /dev/null +++ b/tests/import/jsfmt.spec.js @@ -0,0 +1,2 @@ +run_spec(__dirname); +run_spec(__dirname, {bracketsSpacing: false});