diff --git a/tests/ternaries/with-balanced-formatting/__snapshots__/jsfmt.spec.js.snap b/tests/ternaries/with-balanced-formatting/__snapshots__/jsfmt.spec.js.snap index e77be6da9b..eb10fe7f21 100644 --- a/tests/ternaries/with-balanced-formatting/__snapshots__/jsfmt.spec.js.snap +++ b/tests/ternaries/with-balanced-formatting/__snapshots__/jsfmt.spec.js.snap @@ -89,6 +89,97 @@ room = room.map((row, rowIndex) => ================================================================================ `; +exports[`binary.js 3`] = ` +====================================options===================================== +alignTernaryLines: false +arrowParens: "avoid" +parsers: ["babel", "babel-flow", "flow", "typescript"] +printWidth: 80 +trailingComma: "none" +useTabs: true + | printWidth +=====================================input====================================== +const funnelSnapshotCard = (report === MY_OVERVIEW && + !ReportGK.xar_metrics_active_capitol_v2) || + (report === COMPANY_OVERVIEW && + !ReportGK.xar_metrics_active_capitol_v2_company_metrics) + ? + : null; + +room = room.map((row, rowIndex) => ( + row.map((col, colIndex) => ( + (rowIndex === 0 || colIndex === 0 || rowIndex === height || colIndex === width) ? 1 : 0 + )) +)) + +=====================================output===================================== +const funnelSnapshotCard = + (report === MY_OVERVIEW && !ReportGK.xar_metrics_active_capitol_v2) || + (report === COMPANY_OVERVIEW && + !ReportGK.xar_metrics_active_capitol_v2_company_metrics) ? ( + + ) : null; + +room = room.map((row, rowIndex) => + row.map((col, colIndex) => + rowIndex === 0 || + colIndex === 0 || + rowIndex === height || + colIndex === width + ? 1 + : 0 + ) +); + +================================================================================ +`; + +exports[`binary.js 4`] = ` +====================================options===================================== +alignTernaryLines: false +arrowParens: "avoid" +parsers: ["babel", "babel-flow", "flow", "typescript"] +printWidth: 80 +tabWidth: 4 +trailingComma: "none" +useTabs: true + | printWidth +=====================================input====================================== +const funnelSnapshotCard = (report === MY_OVERVIEW && + !ReportGK.xar_metrics_active_capitol_v2) || + (report === COMPANY_OVERVIEW && + !ReportGK.xar_metrics_active_capitol_v2_company_metrics) + ? + : null; + +room = room.map((row, rowIndex) => ( + row.map((col, colIndex) => ( + (rowIndex === 0 || colIndex === 0 || rowIndex === height || colIndex === width) ? 1 : 0 + )) +)) + +=====================================output===================================== +const funnelSnapshotCard = + (report === MY_OVERVIEW && !ReportGK.xar_metrics_active_capitol_v2) || + (report === COMPANY_OVERVIEW && + !ReportGK.xar_metrics_active_capitol_v2_company_metrics) ? ( + + ) : null; + +room = room.map((row, rowIndex) => + row.map((col, colIndex) => + rowIndex === 0 || + colIndex === 0 || + rowIndex === height || + colIndex === width + ? 1 + : 0 + ) +); + +================================================================================ +`; + exports[`func-call.js 1`] = ` ====================================options===================================== alignTernaryLines: false @@ -152,6 +243,71 @@ fn( ================================================================================ `; +exports[`func-call.js 3`] = ` +====================================options===================================== +alignTernaryLines: false +arrowParens: "avoid" +parsers: ["babel", "babel-flow", "flow", "typescript"] +printWidth: 80 +trailingComma: "none" +useTabs: true + | printWidth +=====================================input====================================== +fn( + bifornCringerMoshedPerplexSawder, + askTrovenaBeenaDependsRowans, + glimseGlyphsHazardNoopsTieTie === averredBathersBoxroomBuggyNurl && + anodyneCondosMalateOverateRetinol + ? annularCooeedSplicesWalksWayWay + : kochabCooieGameOnOboleUnweave +); + +=====================================output===================================== +fn( + bifornCringerMoshedPerplexSawder, + askTrovenaBeenaDependsRowans, + glimseGlyphsHazardNoopsTieTie === averredBathersBoxroomBuggyNurl && + anodyneCondosMalateOverateRetinol + ? annularCooeedSplicesWalksWayWay + : kochabCooieGameOnOboleUnweave +); + +================================================================================ +`; + +exports[`func-call.js 4`] = ` +====================================options===================================== +alignTernaryLines: false +arrowParens: "avoid" +parsers: ["babel", "babel-flow", "flow", "typescript"] +printWidth: 80 +tabWidth: 4 +trailingComma: "none" +useTabs: true + | printWidth +=====================================input====================================== +fn( + bifornCringerMoshedPerplexSawder, + askTrovenaBeenaDependsRowans, + glimseGlyphsHazardNoopsTieTie === averredBathersBoxroomBuggyNurl && + anodyneCondosMalateOverateRetinol + ? annularCooeedSplicesWalksWayWay + : kochabCooieGameOnOboleUnweave +); + +=====================================output===================================== +fn( + bifornCringerMoshedPerplexSawder, + askTrovenaBeenaDependsRowans, + glimseGlyphsHazardNoopsTieTie === averredBathersBoxroomBuggyNurl && + anodyneCondosMalateOverateRetinol + ? annularCooeedSplicesWalksWayWay + : kochabCooieGameOnOboleUnweave +); + +================================================================================ +`; + exports[`indent.js 1`] = ` ====================================options===================================== alignTernaryLines: false @@ -817,130 +973,797 @@ a ================================================================================ `; -exports[`nested.js 1`] = ` +exports[`indent.js 3`] = ` ====================================options===================================== alignTernaryLines: false arrowParens: "avoid" parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 trailingComma: "none" +useTabs: true | printWidth =====================================input====================================== -let icecream = what == "cone" - ? p => !!p ? \`here's your \${p} cone\` : \`just the empty cone for you\` - : p => \`here's your \${p} \${what}\`; - -const value = condition1 -? value1 -: condition2 - ? value2 - : condition3 - ? value3 - : value4; - - -const StorybookLoader = ({ match }) => ( - match.params.storyId === "button" - ? - : match.params.storyId === "color" - ? - : match.params.storyId === "typography" - ? - : match.params.storyId === "loading" - ? - : match.params.storyId === "deal-list" - ? - : ( - - {'Missing story book'} - - - - - ) -) - -const message = - i % 3 === 0 && i % 5 === 0 ? - 'fizzbuzz' - : i % 3 === 0 ? - 'fizz' - : i % 5 === 0 ? - 'buzz' - : - String(i) - -const paymentMessage = state == 'success' - ? 'Payment completed successfully' - -: state == 'processing' - ? 'Payment processing' - -: state == 'invalid_cvc' - ? 'There was an issue with your CVC number' - -: state == 'invalid_expiry' - ? 'Expiry must be sometime in the past.' - - : 'There was an issue with the payment. Please contact support.' - -const paymentMessage2 = state == 'success' - ? 1 //'Payment completed successfully' - -: state == 'processing' - ? 2 //'Payment processing' - -: state == 'invalid_cvc' - ? 3 //'There was an issue with your CVC number' - -: true //state == 'invalid_expiry' - ? 4 //'Expiry must be sometime in the past.' - - : 5 // 'There was an issue with the payment. Please contact support.' +aaaaaaaaaaaaaaa ? bbbbbbbbbbbbbbbbbb : ccccccccccccccc ? ddddddddddddddd : eeeeeeeeeeeeeee ? fffffffffffffff : gggggggggggggggg -const foo =
- {medals[0].record ? ( - i18n('Record') - ) : medals[0].unique ? ( - i18n('Unique') - ) : medals[0].type === 0 ? ( - i18n('Silver') - ) : medals[0].type === 1 ? ( - i18n('Gold') - ) : medals[0].type === 2 ? ( - i18n('Platinum') - ) : ( - i18n('Theme') - )} -
+aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +? +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +? +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +? +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +: +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +: +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +: +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa a - ? literalline + ? { + a: 0 + } : { - 123: 12 - } - ? line - : softline - -=====================================output===================================== -let icecream = - what == "cone" - ? p => (!!p ? \`here's your \${p} cone\` : \`just the empty cone for you\`) - : p => \`here's your \${p} \${what}\`; - -const value = condition1 - ? value1 - : condition2 - ? value2 - : condition3 - ? value3 - : value4; + a: { + a: 0 + } + ? { + a: 0 + } + : { + y: { + a: 0 + } + ? { + a: 0 + } + : { + a: 0 + } + } + } -const StorybookLoader = ({ match }) => - match.params.storyId === "button" ? ( - - ) : match.params.storyId === "color" ? ( - +a + ? { + a: function() { + return a + ? { + a: [ + a + ? { + a: 0, + b: [ + a + ? [ + 0, + 1 + ] + : [] + ] + } + : [ + [ + 0, + { + a: 0 + }, + a + ? 0 + : 1 + ], + function() { + return a + ? { + a: 0 + } + : [ + { + a: 0 + }, + {} + ]; + } + ] + ] + } + : [ + a + ? function() { + a + ? a( + a + ? { + a: a( + { + a: 0 + } + ) + } + : [ + 0, + a(), + a( + a(), + { + a: 0 + }, + a + ? a() + : a( + { + a: 0 + } + ) + ), + a() + ? { + a: a(), + b: [] + } + : {} + ] + ): + a( + a() + ? { + a: 0 + } + : (function(a) { + return a() + ? [ + { + a: 0, + b: a() + } + ] + : a( + [ + a + ? { + a: 0 + } + : {}, + { + a: 0 + } + ] + ); + })( + a + ? function(a) { + return function() { + return 0; + }; + } + : function(a) { + return function() { + return 1; + } + } + ) + ); + } + : function() { + + } + ]; + } + } + : a; + +=====================================output===================================== +aaaaaaaaaaaaaaa + ? bbbbbbbbbbbbbbbbbb + : ccccccccccccccc + ? ddddddddddddddd + : eeeeeeeeeeeeeee + ? fffffffffffffff + : gggggggggggggggg; + +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + ? aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + ? aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + ? aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + : aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + : aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + : aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; + +a + ? { + a: 0 + } + : { + a: { + a: 0 + } + ? { + a: 0 + } + : { + y: { + a: 0 + } + ? { + a: 0 + } + : { + a: 0 + } + } + }; + +a + ? { + a: function () { + return a + ? { + a: [ + a + ? { + a: 0, + b: [a ? [0, 1] : []] + } + : [ + [ + 0, + { + a: 0 + }, + a ? 0 : 1 + ], + function () { + return a + ? { + a: 0 + } + : [ + { + a: 0 + }, + {} + ]; + } + ] + ] + } + : [ + a + ? function () { + a + ? a( + a + ? { + a: a({ + a: 0 + }) + } + : [ + 0, + a(), + a( + a(), + { + a: 0 + }, + a + ? a() + : a({ + a: 0 + }) + ), + a() + ? { + a: a(), + b: [] + } + : {} + ] + ) + : a( + a() + ? { + a: 0 + } + : (function (a) { + return a() + ? [ + { + a: 0, + b: a() + } + ] + : a([ + a + ? { + a: 0 + } + : {}, + { + a: 0 + } + ]); + })( + a + ? function (a) { + return function () { + return 0; + }; + } + : function (a) { + return function () { + return 1; + }; + } + ) + ); + } + : function () {} + ]; + } + } + : a; + +================================================================================ +`; + +exports[`indent.js 4`] = ` +====================================options===================================== +alignTernaryLines: false +arrowParens: "avoid" +parsers: ["babel", "babel-flow", "flow", "typescript"] +printWidth: 80 +tabWidth: 4 +trailingComma: "none" +useTabs: true + | printWidth +=====================================input====================================== +aaaaaaaaaaaaaaa ? bbbbbbbbbbbbbbbbbb : ccccccccccccccc ? ddddddddddddddd : eeeeeeeeeeeeeee ? fffffffffffffff : gggggggggggggggg + +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +? +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +? +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +? +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +: +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +: +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +: +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + +a + ? { + a: 0 + } + : { + a: { + a: 0 + } + ? { + a: 0 + } + : { + y: { + a: 0 + } + ? { + a: 0 + } + : { + a: 0 + } + } + } + +a + ? { + a: function() { + return a + ? { + a: [ + a + ? { + a: 0, + b: [ + a + ? [ + 0, + 1 + ] + : [] + ] + } + : [ + [ + 0, + { + a: 0 + }, + a + ? 0 + : 1 + ], + function() { + return a + ? { + a: 0 + } + : [ + { + a: 0 + }, + {} + ]; + } + ] + ] + } + : [ + a + ? function() { + a + ? a( + a + ? { + a: a( + { + a: 0 + } + ) + } + : [ + 0, + a(), + a( + a(), + { + a: 0 + }, + a + ? a() + : a( + { + a: 0 + } + ) + ), + a() + ? { + a: a(), + b: [] + } + : {} + ] + ): + a( + a() + ? { + a: 0 + } + : (function(a) { + return a() + ? [ + { + a: 0, + b: a() + } + ] + : a( + [ + a + ? { + a: 0 + } + : {}, + { + a: 0 + } + ] + ); + })( + a + ? function(a) { + return function() { + return 0; + }; + } + : function(a) { + return function() { + return 1; + } + } + ) + ); + } + : function() { + + } + ]; + } + } + : a; + +=====================================output===================================== +aaaaaaaaaaaaaaa + ? bbbbbbbbbbbbbbbbbb + : ccccccccccccccc + ? ddddddddddddddd + : eeeeeeeeeeeeeee + ? fffffffffffffff + : gggggggggggggggg; + +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + ? aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + ? aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + ? aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + : aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + : aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + : aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; + +a + ? { + a: 0 + } + : { + a: { + a: 0 + } + ? { + a: 0 + } + : { + y: { + a: 0 + } + ? { + a: 0 + } + : { + a: 0 + } + } + }; + +a + ? { + a: function () { + return a + ? { + a: [ + a + ? { + a: 0, + b: [a ? [0, 1] : []] + } + : [ + [ + 0, + { + a: 0 + }, + a ? 0 : 1 + ], + function () { + return a + ? { + a: 0 + } + : [ + { + a: 0 + }, + {} + ]; + } + ] + ] + } + : [ + a + ? function () { + a + ? a( + a + ? { + a: a({ + a: 0 + }) + } + : [ + 0, + a(), + a( + a(), + { + a: 0 + }, + a + ? a() + : a({ + a: 0 + }) + ), + a() + ? { + a: a(), + b: [] + } + : {} + ] + ) + : a( + a() + ? { + a: 0 + } + : (function (a) { + return a() + ? [ + { + a: 0, + b: a() + } + ] + : a([ + a + ? { + a: 0 + } + : {}, + { + a: 0 + } + ]); + })( + a + ? function (a) { + return function () { + return 0; + }; + } + : function (a) { + return function () { + return 1; + }; + } + ) + ); + } + : function () {} + ]; + } + } + : a; + +================================================================================ +`; + +exports[`nested.js 1`] = ` +====================================options===================================== +alignTernaryLines: false +arrowParens: "avoid" +parsers: ["babel", "babel-flow", "flow", "typescript"] +printWidth: 80 +trailingComma: "none" + | printWidth +=====================================input====================================== +let icecream = what == "cone" + ? p => !!p ? \`here's your \${p} cone\` : \`just the empty cone for you\` + : p => \`here's your \${p} \${what}\`; + +const value = condition1 +? value1 +: condition2 + ? value2 + : condition3 + ? value3 + : value4; + + +const StorybookLoader = ({ match }) => ( + match.params.storyId === "button" + ? + : match.params.storyId === "color" + ? + : match.params.storyId === "typography" + ? + : match.params.storyId === "loading" + ? + : match.params.storyId === "deal-list" + ? + : ( + + {'Missing story book'} + + + + + ) +) + +const message = + i % 3 === 0 && i % 5 === 0 ? + 'fizzbuzz' + : i % 3 === 0 ? + 'fizz' + : i % 5 === 0 ? + 'buzz' + : + String(i) + +const paymentMessage = state == 'success' + ? 'Payment completed successfully' + +: state == 'processing' + ? 'Payment processing' + +: state == 'invalid_cvc' + ? 'There was an issue with your CVC number' + +: state == 'invalid_expiry' + ? 'Expiry must be sometime in the past.' + + : 'There was an issue with the payment. Please contact support.' + +const paymentMessage2 = state == 'success' + ? 1 //'Payment completed successfully' + +: state == 'processing' + ? 2 //'Payment processing' + +: state == 'invalid_cvc' + ? 3 //'There was an issue with your CVC number' + +: true //state == 'invalid_expiry' + ? 4 //'Expiry must be sometime in the past.' + + : 5 // 'There was an issue with the payment. Please contact support.' + +const foo =
+ {medals[0].record ? ( + i18n('Record') + ) : medals[0].unique ? ( + i18n('Unique') + ) : medals[0].type === 0 ? ( + i18n('Silver') + ) : medals[0].type === 1 ? ( + i18n('Gold') + ) : medals[0].type === 2 ? ( + i18n('Platinum') + ) : ( + i18n('Theme') + )} +
+ +a + ? literalline + : { + 123: 12 + } + ? line + : softline + +=====================================output===================================== +let icecream = + what == "cone" + ? p => (!!p ? \`here's your \${p} cone\` : \`just the empty cone for you\`) + : p => \`here's your \${p} \${what}\`; + +const value = condition1 + ? value1 + : condition2 + ? value2 + : condition3 + ? value3 + : value4; + +const StorybookLoader = ({ match }) => + match.params.storyId === "button" ? ( + + ) : match.params.storyId === "color" ? ( + ) : match.params.storyId === "typography" ? ( ) : match.params.storyId === "loading" ? ( @@ -957,73 +1780,487 @@ const StorybookLoader = ({ match }) => ); const message = - i % 3 === 0 && i % 5 === 0 - ? "fizzbuzz" - : i % 3 === 0 - ? "fizz" - : i % 5 === 0 - ? "buzz" - : String(i); + i % 3 === 0 && i % 5 === 0 + ? "fizzbuzz" + : i % 3 === 0 + ? "fizz" + : i % 5 === 0 + ? "buzz" + : String(i); + +const paymentMessage = + state == "success" + ? "Payment completed successfully" + : state == "processing" + ? "Payment processing" + : state == "invalid_cvc" + ? "There was an issue with your CVC number" + : state == "invalid_expiry" + ? "Expiry must be sometime in the past." + : "There was an issue with the payment. Please contact support."; + +const paymentMessage2 = + state == "success" + ? 1 //'Payment completed successfully' + : state == "processing" + ? 2 //'Payment processing' + : state == "invalid_cvc" + ? 3 //'There was an issue with your CVC number' + : true //state == 'invalid_expiry' + ? 4 //'Expiry must be sometime in the past.' + : 5; // 'There was an issue with the payment. Please contact support.' + +const foo = ( +
+ {medals[0].record + ? i18n("Record") + : medals[0].unique + ? i18n("Unique") + : medals[0].type === 0 + ? i18n("Silver") + : medals[0].type === 1 + ? i18n("Gold") + : medals[0].type === 2 + ? i18n("Platinum") + : i18n("Theme")} +
+); + +a + ? literalline + : { + 123: 12 + } + ? line + : softline; + +================================================================================ +`; + +exports[`nested.js 2`] = ` +====================================options===================================== +alignTernaryLines: false +arrowParens: "avoid" +parsers: ["babel", "babel-flow", "flow", "typescript"] +printWidth: 80 +tabWidth: 4 +trailingComma: "none" + | printWidth +=====================================input====================================== +let icecream = what == "cone" + ? p => !!p ? \`here's your \${p} cone\` : \`just the empty cone for you\` + : p => \`here's your \${p} \${what}\`; + +const value = condition1 +? value1 +: condition2 + ? value2 + : condition3 + ? value3 + : value4; + + +const StorybookLoader = ({ match }) => ( + match.params.storyId === "button" + ? + : match.params.storyId === "color" + ? + : match.params.storyId === "typography" + ? + : match.params.storyId === "loading" + ? + : match.params.storyId === "deal-list" + ? + : ( + + {'Missing story book'} + + + + + ) +) + +const message = + i % 3 === 0 && i % 5 === 0 ? + 'fizzbuzz' + : i % 3 === 0 ? + 'fizz' + : i % 5 === 0 ? + 'buzz' + : + String(i) + +const paymentMessage = state == 'success' + ? 'Payment completed successfully' + +: state == 'processing' + ? 'Payment processing' + +: state == 'invalid_cvc' + ? 'There was an issue with your CVC number' + +: state == 'invalid_expiry' + ? 'Expiry must be sometime in the past.' + + : 'There was an issue with the payment. Please contact support.' + +const paymentMessage2 = state == 'success' + ? 1 //'Payment completed successfully' + +: state == 'processing' + ? 2 //'Payment processing' + +: state == 'invalid_cvc' + ? 3 //'There was an issue with your CVC number' + +: true //state == 'invalid_expiry' + ? 4 //'Expiry must be sometime in the past.' + + : 5 // 'There was an issue with the payment. Please contact support.' + +const foo =
+ {medals[0].record ? ( + i18n('Record') + ) : medals[0].unique ? ( + i18n('Unique') + ) : medals[0].type === 0 ? ( + i18n('Silver') + ) : medals[0].type === 1 ? ( + i18n('Gold') + ) : medals[0].type === 2 ? ( + i18n('Platinum') + ) : ( + i18n('Theme') + )} +
+ +a + ? literalline + : { + 123: 12 + } + ? line + : softline + +=====================================output===================================== +let icecream = + what == "cone" + ? p => (!!p ? \`here's your \${p} cone\` : \`just the empty cone for you\`) + : p => \`here's your \${p} \${what}\`; + +const value = condition1 + ? value1 + : condition2 + ? value2 + : condition3 + ? value3 + : value4; + +const StorybookLoader = ({ match }) => + match.params.storyId === "button" ? ( + + ) : match.params.storyId === "color" ? ( + + ) : match.params.storyId === "typography" ? ( + + ) : match.params.storyId === "loading" ? ( + + ) : match.params.storyId === "deal-list" ? ( + + ) : ( + + {"Missing story book"} + + + + + ); + +const message = + i % 3 === 0 && i % 5 === 0 + ? "fizzbuzz" + : i % 3 === 0 + ? "fizz" + : i % 5 === 0 + ? "buzz" + : String(i); + +const paymentMessage = + state == "success" + ? "Payment completed successfully" + : state == "processing" + ? "Payment processing" + : state == "invalid_cvc" + ? "There was an issue with your CVC number" + : state == "invalid_expiry" + ? "Expiry must be sometime in the past." + : "There was an issue with the payment. Please contact support."; + +const paymentMessage2 = + state == "success" + ? 1 //'Payment completed successfully' + : state == "processing" + ? 2 //'Payment processing' + : state == "invalid_cvc" + ? 3 //'There was an issue with your CVC number' + : true //state == 'invalid_expiry' + ? 4 //'Expiry must be sometime in the past.' + : 5; // 'There was an issue with the payment. Please contact support.' + +const foo = ( +
+ {medals[0].record + ? i18n("Record") + : medals[0].unique + ? i18n("Unique") + : medals[0].type === 0 + ? i18n("Silver") + : medals[0].type === 1 + ? i18n("Gold") + : medals[0].type === 2 + ? i18n("Platinum") + : i18n("Theme")} +
+); + +a + ? literalline + : { + 123: 12 + } + ? line + : softline; + +================================================================================ +`; + +exports[`nested.js 3`] = ` +====================================options===================================== +alignTernaryLines: false +arrowParens: "avoid" +parsers: ["babel", "babel-flow", "flow", "typescript"] +printWidth: 80 +trailingComma: "none" +useTabs: true + | printWidth +=====================================input====================================== +let icecream = what == "cone" + ? p => !!p ? \`here's your \${p} cone\` : \`just the empty cone for you\` + : p => \`here's your \${p} \${what}\`; + +const value = condition1 +? value1 +: condition2 + ? value2 + : condition3 + ? value3 + : value4; + + +const StorybookLoader = ({ match }) => ( + match.params.storyId === "button" + ? + : match.params.storyId === "color" + ? + : match.params.storyId === "typography" + ? + : match.params.storyId === "loading" + ? + : match.params.storyId === "deal-list" + ? + : ( + + {'Missing story book'} + + + + + ) +) + +const message = + i % 3 === 0 && i % 5 === 0 ? + 'fizzbuzz' + : i % 3 === 0 ? + 'fizz' + : i % 5 === 0 ? + 'buzz' + : + String(i) + +const paymentMessage = state == 'success' + ? 'Payment completed successfully' + +: state == 'processing' + ? 'Payment processing' + +: state == 'invalid_cvc' + ? 'There was an issue with your CVC number' + +: state == 'invalid_expiry' + ? 'Expiry must be sometime in the past.' + + : 'There was an issue with the payment. Please contact support.' + +const paymentMessage2 = state == 'success' + ? 1 //'Payment completed successfully' + +: state == 'processing' + ? 2 //'Payment processing' + +: state == 'invalid_cvc' + ? 3 //'There was an issue with your CVC number' + +: true //state == 'invalid_expiry' + ? 4 //'Expiry must be sometime in the past.' + + : 5 // 'There was an issue with the payment. Please contact support.' + +const foo =
+ {medals[0].record ? ( + i18n('Record') + ) : medals[0].unique ? ( + i18n('Unique') + ) : medals[0].type === 0 ? ( + i18n('Silver') + ) : medals[0].type === 1 ? ( + i18n('Gold') + ) : medals[0].type === 2 ? ( + i18n('Platinum') + ) : ( + i18n('Theme') + )} +
+ +a + ? literalline + : { + 123: 12 + } + ? line + : softline + +=====================================output===================================== +let icecream = + what == "cone" + ? p => (!!p ? \`here's your \${p} cone\` : \`just the empty cone for you\`) + : p => \`here's your \${p} \${what}\`; + +const value = condition1 + ? value1 + : condition2 + ? value2 + : condition3 + ? value3 + : value4; + +const StorybookLoader = ({ match }) => + match.params.storyId === "button" ? ( + + ) : match.params.storyId === "color" ? ( + + ) : match.params.storyId === "typography" ? ( + + ) : match.params.storyId === "loading" ? ( + + ) : match.params.storyId === "deal-list" ? ( + + ) : ( + + {"Missing story book"} + + + + + ); + +const message = + i % 3 === 0 && i % 5 === 0 + ? "fizzbuzz" + : i % 3 === 0 + ? "fizz" + : i % 5 === 0 + ? "buzz" + : String(i); const paymentMessage = - state == "success" - ? "Payment completed successfully" - : state == "processing" - ? "Payment processing" - : state == "invalid_cvc" - ? "There was an issue with your CVC number" - : state == "invalid_expiry" - ? "Expiry must be sometime in the past." - : "There was an issue with the payment. Please contact support."; + state == "success" + ? "Payment completed successfully" + : state == "processing" + ? "Payment processing" + : state == "invalid_cvc" + ? "There was an issue with your CVC number" + : state == "invalid_expiry" + ? "Expiry must be sometime in the past." + : "There was an issue with the payment. Please contact support."; const paymentMessage2 = - state == "success" - ? 1 //'Payment completed successfully' - : state == "processing" - ? 2 //'Payment processing' - : state == "invalid_cvc" - ? 3 //'There was an issue with your CVC number' - : true //state == 'invalid_expiry' - ? 4 //'Expiry must be sometime in the past.' - : 5; // 'There was an issue with the payment. Please contact support.' + state == "success" + ? 1 //'Payment completed successfully' + : state == "processing" + ? 2 //'Payment processing' + : state == "invalid_cvc" + ? 3 //'There was an issue with your CVC number' + : true //state == 'invalid_expiry' + ? 4 //'Expiry must be sometime in the past.' + : 5; // 'There was an issue with the payment. Please contact support.' const foo = ( -
- {medals[0].record - ? i18n("Record") - : medals[0].unique - ? i18n("Unique") - : medals[0].type === 0 - ? i18n("Silver") - : medals[0].type === 1 - ? i18n("Gold") - : medals[0].type === 2 - ? i18n("Platinum") - : i18n("Theme")} -
+
+ {medals[0].record + ? i18n("Record") + : medals[0].unique + ? i18n("Unique") + : medals[0].type === 0 + ? i18n("Silver") + : medals[0].type === 1 + ? i18n("Gold") + : medals[0].type === 2 + ? i18n("Platinum") + : i18n("Theme")} +
); a - ? literalline - : { - 123: 12 - } - ? line - : softline; + ? literalline + : { + 123: 12 + } + ? line + : softline; ================================================================================ `; -exports[`nested.js 2`] = ` +exports[`nested.js 4`] = ` ====================================options===================================== alignTernaryLines: false arrowParens: "avoid" @@ -1031,6 +2268,7 @@ parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 tabWidth: 4 trailingComma: "none" +useTabs: true | printWidth =====================================input====================================== let icecream = what == "cone" @@ -1131,101 +2369,101 @@ a =====================================output===================================== let icecream = - what == "cone" - ? p => (!!p ? \`here's your \${p} cone\` : \`just the empty cone for you\`) - : p => \`here's your \${p} \${what}\`; + what == "cone" + ? p => (!!p ? \`here's your \${p} cone\` : \`just the empty cone for you\`) + : p => \`here's your \${p} \${what}\`; const value = condition1 - ? value1 - : condition2 - ? value2 - : condition3 - ? value3 - : value4; + ? value1 + : condition2 + ? value2 + : condition3 + ? value3 + : value4; const StorybookLoader = ({ match }) => - match.params.storyId === "button" ? ( - - ) : match.params.storyId === "color" ? ( - - ) : match.params.storyId === "typography" ? ( - - ) : match.params.storyId === "loading" ? ( - - ) : match.params.storyId === "deal-list" ? ( - - ) : ( - - {"Missing story book"} - - - - - ); + match.params.storyId === "button" ? ( + + ) : match.params.storyId === "color" ? ( + + ) : match.params.storyId === "typography" ? ( + + ) : match.params.storyId === "loading" ? ( + + ) : match.params.storyId === "deal-list" ? ( + + ) : ( + + {"Missing story book"} + + + + + ); const message = - i % 3 === 0 && i % 5 === 0 - ? "fizzbuzz" - : i % 3 === 0 - ? "fizz" - : i % 5 === 0 - ? "buzz" - : String(i); + i % 3 === 0 && i % 5 === 0 + ? "fizzbuzz" + : i % 3 === 0 + ? "fizz" + : i % 5 === 0 + ? "buzz" + : String(i); const paymentMessage = - state == "success" - ? "Payment completed successfully" - : state == "processing" - ? "Payment processing" - : state == "invalid_cvc" - ? "There was an issue with your CVC number" - : state == "invalid_expiry" - ? "Expiry must be sometime in the past." - : "There was an issue with the payment. Please contact support."; + state == "success" + ? "Payment completed successfully" + : state == "processing" + ? "Payment processing" + : state == "invalid_cvc" + ? "There was an issue with your CVC number" + : state == "invalid_expiry" + ? "Expiry must be sometime in the past." + : "There was an issue with the payment. Please contact support."; const paymentMessage2 = - state == "success" - ? 1 //'Payment completed successfully' - : state == "processing" - ? 2 //'Payment processing' - : state == "invalid_cvc" - ? 3 //'There was an issue with your CVC number' - : true //state == 'invalid_expiry' - ? 4 //'Expiry must be sometime in the past.' - : 5; // 'There was an issue with the payment. Please contact support.' + state == "success" + ? 1 //'Payment completed successfully' + : state == "processing" + ? 2 //'Payment processing' + : state == "invalid_cvc" + ? 3 //'There was an issue with your CVC number' + : true //state == 'invalid_expiry' + ? 4 //'Expiry must be sometime in the past.' + : 5; // 'There was an issue with the payment. Please contact support.' -const foo = ( -
- {medals[0].record - ? i18n("Record") - : medals[0].unique - ? i18n("Unique") - : medals[0].type === 0 - ? i18n("Silver") - : medals[0].type === 1 - ? i18n("Gold") - : medals[0].type === 2 - ? i18n("Platinum") - : i18n("Theme")} -
+const foo = ( +
+ {medals[0].record + ? i18n("Record") + : medals[0].unique + ? i18n("Unique") + : medals[0].type === 0 + ? i18n("Silver") + : medals[0].type === 1 + ? i18n("Gold") + : medals[0].type === 2 + ? i18n("Platinum") + : i18n("Theme")} +
); a - ? literalline - : { - 123: 12 - } - ? line - : softline; + ? literalline + : { + 123: 12 + } + ? line + : softline; ================================================================================ `; @@ -1413,6 +2651,191 @@ const value = ( ================================================================================ `; +exports[`nested-in-condition.js 3`] = ` +====================================options===================================== +alignTernaryLines: false +arrowParens: "avoid" +parsers: ["babel", "babel-flow", "flow", "typescript"] +printWidth: 80 +trailingComma: "none" +useTabs: true + | printWidth +=====================================input====================================== +$var = ($number % 10 >= 2 && ($number % 100 < 10 || $number % 100 >= 20) +? kochabCooieGameOnOboleUnweave +: annularCooeedSplicesWalksWayWay) + ? anodyneCondosMalateOverateRetinol + : averredBathersBoxroomBuggyNurl; + +const value = (bifornCringerMoshedPerplexSawder +? askTrovenaBeenaDependsRowans +: glimseGlyphsHazardNoopsTieTie) + ? true + ? true + : false + : true + ? true + : false; + +(bifornCringerMoshedPerplexSawder ? ( + askTrovenaBeenaDependsRowans +) : ( + glimseGlyphsHazardNoopsTieTie +)) ? ( + + + + + + + + +) : ( + + + + + +); + +=====================================output===================================== +$var = ( + $number % 10 >= 2 && ($number % 100 < 10 || $number % 100 >= 20) + ? kochabCooieGameOnOboleUnweave + : annularCooeedSplicesWalksWayWay +) + ? anodyneCondosMalateOverateRetinol + : averredBathersBoxroomBuggyNurl; + +const value = ( + bifornCringerMoshedPerplexSawder + ? askTrovenaBeenaDependsRowans + : glimseGlyphsHazardNoopsTieTie +) + ? true + ? true + : false + : true + ? true + : false; + +( + bifornCringerMoshedPerplexSawder + ? askTrovenaBeenaDependsRowans + : glimseGlyphsHazardNoopsTieTie +) ? ( + + + + + + + + +) : ( + + + + + +); + +================================================================================ +`; + +exports[`nested-in-condition.js 4`] = ` +====================================options===================================== +alignTernaryLines: false +arrowParens: "avoid" +parsers: ["babel", "babel-flow", "flow", "typescript"] +printWidth: 80 +tabWidth: 4 +trailingComma: "none" +useTabs: true + | printWidth +=====================================input====================================== +$var = ($number % 10 >= 2 && ($number % 100 < 10 || $number % 100 >= 20) +? kochabCooieGameOnOboleUnweave +: annularCooeedSplicesWalksWayWay) + ? anodyneCondosMalateOverateRetinol + : averredBathersBoxroomBuggyNurl; + +const value = (bifornCringerMoshedPerplexSawder +? askTrovenaBeenaDependsRowans +: glimseGlyphsHazardNoopsTieTie) + ? true + ? true + : false + : true + ? true + : false; + +(bifornCringerMoshedPerplexSawder ? ( + askTrovenaBeenaDependsRowans +) : ( + glimseGlyphsHazardNoopsTieTie +)) ? ( + + + + + + + + +) : ( + + + + + +); + +=====================================output===================================== +$var = ( + $number % 10 >= 2 && ($number % 100 < 10 || $number % 100 >= 20) + ? kochabCooieGameOnOboleUnweave + : annularCooeedSplicesWalksWayWay +) + ? anodyneCondosMalateOverateRetinol + : averredBathersBoxroomBuggyNurl; + +const value = ( + bifornCringerMoshedPerplexSawder + ? askTrovenaBeenaDependsRowans + : glimseGlyphsHazardNoopsTieTie +) + ? true + ? true + : false + : true + ? true + : false; + +( + bifornCringerMoshedPerplexSawder + ? askTrovenaBeenaDependsRowans + : glimseGlyphsHazardNoopsTieTie +) ? ( + + + + + + + + +) : ( + + + + + +); + +================================================================================ +`; + exports[`parenthesis.js 1`] = ` ====================================options===================================== alignTernaryLines: false @@ -1492,6 +2915,87 @@ a => ================================================================================ `; +exports[`parenthesis.js 3`] = ` +====================================options===================================== +alignTernaryLines: false +arrowParens: "avoid" +parsers: ["babel", "babel-flow", "flow", "typescript"] +printWidth: 80 +trailingComma: "none" +useTabs: true + | printWidth +=====================================input====================================== +debug ? this.state.isVisible ? "partially visible" : "hidden" : null; +debug ? this.state.isVisible && somethingComplex ? "partially visible" : "hidden" : null; + +a => a ? () => {a} : () => {a} +a => a ? a : a +a => a ? aasdasdasdasdasdasdaaasdasdasdasdasdasdasdasdasdasdasdasdasdaaaaaa : a + +=====================================output===================================== +debug ? (this.state.isVisible ? "partially visible" : "hidden") : null; +debug + ? this.state.isVisible && somethingComplex + ? "partially visible" + : "hidden" + : null; + +a => + a + ? () => { + a; + } + : () => { + a; + }; +a => (a ? a : a); +a => + a ? aasdasdasdasdasdasdaaasdasdasdasdasdasdasdasdasdasdasdasdasdaaaaaa : a; + +================================================================================ +`; + +exports[`parenthesis.js 4`] = ` +====================================options===================================== +alignTernaryLines: false +arrowParens: "avoid" +parsers: ["babel", "babel-flow", "flow", "typescript"] +printWidth: 80 +tabWidth: 4 +trailingComma: "none" +useTabs: true + | printWidth +=====================================input====================================== +debug ? this.state.isVisible ? "partially visible" : "hidden" : null; +debug ? this.state.isVisible && somethingComplex ? "partially visible" : "hidden" : null; + +a => a ? () => {a} : () => {a} +a => a ? a : a +a => a ? aasdasdasdasdasdasdaaasdasdasdasdasdasdasdasdasdasdasdasdasdaaaaaa : a + +=====================================output===================================== +debug ? (this.state.isVisible ? "partially visible" : "hidden") : null; +debug + ? this.state.isVisible && somethingComplex + ? "partially visible" + : "hidden" + : null; + +a => + a + ? () => { + a; + } + : () => { + a; + }; +a => (a ? a : a); +a => + a ? aasdasdasdasdasdasdaaasdasdasdasdasdasdasdasdasdasdasdasdasdaaaaaa : a; + +================================================================================ +`; + exports[`test.js 1`] = ` ====================================options===================================== alignTernaryLines: false @@ -1616,3 +3120,130 @@ const obj5 = conditionIsTruthy ================================================================================ `; + +exports[`test.js 3`] = ` +====================================options===================================== +alignTernaryLines: false +arrowParens: "avoid" +parsers: ["babel", "babel-flow", "flow", "typescript"] +printWidth: 80 +trailingComma: "none" +useTabs: true + | printWidth +=====================================input====================================== +const obj0 = conditionIsTruthy ? shortThing : otherShortThing + +const obj1 = conditionIsTruthy ? { some: 'long', object: 'with', lots: 'of', stuff } : shortThing + +const obj2 = conditionIsTruthy ? shortThing : { some: 'long', object: 'with', lots: 'of', stuff } + +const obj3 = conditionIsTruthy ? { some: 'eeeeeeeeeeeeven looooooooooooooooooooooooooooooonger', object: 'with', lots: 'of', stuff } : shortThing + +const obj4 = conditionIsTruthy ? shortThing : { some: 'eeeeeeeeeeeeven looooooooooooooooooooooooooooooonger', object: 'with', lots: 'of', stuff } + +const obj5 = conditionIsTruthy ? { some: 'long', object: 'with', lots: 'of', stuff } : { some: 'eeeeeeeeeeeeven looooooooooooooooooooooooooooooonger', object: 'with', lots: 'of', stuff } + +=====================================output===================================== +const obj0 = conditionIsTruthy ? shortThing : otherShortThing; + +const obj1 = conditionIsTruthy + ? { some: "long", object: "with", lots: "of", stuff } + : shortThing; + +const obj2 = conditionIsTruthy + ? shortThing + : { some: "long", object: "with", lots: "of", stuff }; + +const obj3 = conditionIsTruthy + ? { + some: "eeeeeeeeeeeeven looooooooooooooooooooooooooooooonger", + object: "with", + lots: "of", + stuff + } + : shortThing; + +const obj4 = conditionIsTruthy + ? shortThing + : { + some: "eeeeeeeeeeeeven looooooooooooooooooooooooooooooonger", + object: "with", + lots: "of", + stuff + }; + +const obj5 = conditionIsTruthy + ? { some: "long", object: "with", lots: "of", stuff } + : { + some: "eeeeeeeeeeeeven looooooooooooooooooooooooooooooonger", + object: "with", + lots: "of", + stuff + }; + +================================================================================ +`; + +exports[`test.js 4`] = ` +====================================options===================================== +alignTernaryLines: false +arrowParens: "avoid" +parsers: ["babel", "babel-flow", "flow", "typescript"] +printWidth: 80 +tabWidth: 4 +trailingComma: "none" +useTabs: true + | printWidth +=====================================input====================================== +const obj0 = conditionIsTruthy ? shortThing : otherShortThing + +const obj1 = conditionIsTruthy ? { some: 'long', object: 'with', lots: 'of', stuff } : shortThing + +const obj2 = conditionIsTruthy ? shortThing : { some: 'long', object: 'with', lots: 'of', stuff } + +const obj3 = conditionIsTruthy ? { some: 'eeeeeeeeeeeeven looooooooooooooooooooooooooooooonger', object: 'with', lots: 'of', stuff } : shortThing + +const obj4 = conditionIsTruthy ? shortThing : { some: 'eeeeeeeeeeeeven looooooooooooooooooooooooooooooonger', object: 'with', lots: 'of', stuff } + +const obj5 = conditionIsTruthy ? { some: 'long', object: 'with', lots: 'of', stuff } : { some: 'eeeeeeeeeeeeven looooooooooooooooooooooooooooooonger', object: 'with', lots: 'of', stuff } + +=====================================output===================================== +const obj0 = conditionIsTruthy ? shortThing : otherShortThing; + +const obj1 = conditionIsTruthy + ? { some: "long", object: "with", lots: "of", stuff } + : shortThing; + +const obj2 = conditionIsTruthy + ? shortThing + : { some: "long", object: "with", lots: "of", stuff }; + +const obj3 = conditionIsTruthy + ? { + some: "eeeeeeeeeeeeven looooooooooooooooooooooooooooooonger", + object: "with", + lots: "of", + stuff + } + : shortThing; + +const obj4 = conditionIsTruthy + ? shortThing + : { + some: "eeeeeeeeeeeeven looooooooooooooooooooooooooooooonger", + object: "with", + lots: "of", + stuff + }; + +const obj5 = conditionIsTruthy + ? { some: "long", object: "with", lots: "of", stuff } + : { + some: "eeeeeeeeeeeeven looooooooooooooooooooooooooooooonger", + object: "with", + lots: "of", + stuff + }; + +================================================================================ +`; diff --git a/tests/ternaries/with-balanced-formatting/jsfmt.spec.js b/tests/ternaries/with-balanced-formatting/jsfmt.spec.js index 39ddd9c7a2..254620ea2a 100644 --- a/tests/ternaries/with-balanced-formatting/jsfmt.spec.js +++ b/tests/ternaries/with-balanced-formatting/jsfmt.spec.js @@ -23,3 +23,24 @@ run_spec(dirpath, ["babel", "babel-flow", "flow", "typescript"], { arrowParens: "avoid", trailingComma: "none", }); + +run_spec(dirpath, ["babel", "babel-flow", "flow", "typescript"], { + // variation from ../jsfmt.spec.js: + useTabs: true, + // [prettierx] balanced ternary formatting option: + alignTernaryLines: false, + // [prettierx] more options needed for consistency with "Standard JS": + arrowParens: "avoid", + trailingComma: "none", +}); + +run_spec(dirpath, ["babel", "babel-flow", "flow", "typescript"], { + // variation from ../jsfmt.spec.js: + useTabs: true, + tabWidth: 4, + // [prettierx] balanced ternary formatting option: + alignTernaryLines: false, + // [prettierx] more options needed for consistency with "Standard JS": + arrowParens: "avoid", + trailingComma: "none", +}); diff --git a/tests/ternary-object-expressions/with-balanced-formatting/__snapshots__/jsfmt.spec.js.snap b/tests/ternary-object-expressions/with-balanced-formatting/__snapshots__/jsfmt.spec.js.snap index 06868823c3..aa06446e6a 100644 --- a/tests/ternary-object-expressions/with-balanced-formatting/__snapshots__/jsfmt.spec.js.snap +++ b/tests/ternary-object-expressions/with-balanced-formatting/__snapshots__/jsfmt.spec.js.snap @@ -70,3 +70,76 @@ const dress = isSpace ================================================================================ `; + +exports[`crewdress.js 3`] = ` +====================================options===================================== +alignTernaryLines: false +arrowParens: "avoid" +parsers: ["babel", "babel-flow", "flow", "typescript"] +printWidth: 80 +trailingComma: "none" +useTabs: true + | printWidth +=====================================input====================================== +let isSpace = false + +const dress = isSpace ? { + spaceSuit: 3, + oxygenCylinders: 6 + } : { + shirts: 3, + paints: 3 + } + +=====================================output===================================== +let isSpace = false; + +const dress = isSpace + ? { + spaceSuit: 3, + oxygenCylinders: 6 + } + : { + shirts: 3, + paints: 3 + }; + +================================================================================ +`; + +exports[`crewdress.js 4`] = ` +====================================options===================================== +alignTernaryLines: false +arrowParens: "avoid" +parsers: ["babel", "babel-flow", "flow", "typescript"] +printWidth: 80 +tabWidth: 4 +trailingComma: "none" +useTabs: true + | printWidth +=====================================input====================================== +let isSpace = false + +const dress = isSpace ? { + spaceSuit: 3, + oxygenCylinders: 6 + } : { + shirts: 3, + paints: 3 + } + +=====================================output===================================== +let isSpace = false; + +const dress = isSpace + ? { + spaceSuit: 3, + oxygenCylinders: 6 + } + : { + shirts: 3, + paints: 3 + }; + +================================================================================ +`; diff --git a/tests/ternary-object-expressions/with-balanced-formatting/jsfmt.spec.js b/tests/ternary-object-expressions/with-balanced-formatting/jsfmt.spec.js index 39ddd9c7a2..254620ea2a 100644 --- a/tests/ternary-object-expressions/with-balanced-formatting/jsfmt.spec.js +++ b/tests/ternary-object-expressions/with-balanced-formatting/jsfmt.spec.js @@ -23,3 +23,24 @@ run_spec(dirpath, ["babel", "babel-flow", "flow", "typescript"], { arrowParens: "avoid", trailingComma: "none", }); + +run_spec(dirpath, ["babel", "babel-flow", "flow", "typescript"], { + // variation from ../jsfmt.spec.js: + useTabs: true, + // [prettierx] balanced ternary formatting option: + alignTernaryLines: false, + // [prettierx] more options needed for consistency with "Standard JS": + arrowParens: "avoid", + trailingComma: "none", +}); + +run_spec(dirpath, ["babel", "babel-flow", "flow", "typescript"], { + // variation from ../jsfmt.spec.js: + useTabs: true, + tabWidth: 4, + // [prettierx] balanced ternary formatting option: + alignTernaryLines: false, + // [prettierx] more options needed for consistency with "Standard JS": + arrowParens: "avoid", + trailingComma: "none", +});