From a3e9563154646b88d2a96b5960aca7c99343ae6b Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Fri, 1 Jan 2021 03:35:02 -0500 Subject: [PATCH] prettierx: test formatting of nested ternary promise expressions check for consistent formatting as discussed in: - https://github.com/eslint/eslint/issues/13971 - https://github.com/standard/standard/issues/1624 - https://github.com/brodybits/prettierx/issues/41 --- .../standard/__snapshots__/jsfmt.spec.js.snap | 50 +++++++++++++++++++ tests/standard/nested-ternary-promises.js | 14 ++++++ 2 files changed, 64 insertions(+) create mode 100644 tests/standard/nested-ternary-promises.js diff --git a/tests/standard/__snapshots__/jsfmt.spec.js.snap b/tests/standard/__snapshots__/jsfmt.spec.js.snap index babaa312fb..77210fd6d3 100644 --- a/tests/standard/__snapshots__/jsfmt.spec.js.snap +++ b/tests/standard/__snapshots__/jsfmt.spec.js.snap @@ -2159,3 +2159,53 @@ const StorybookLoader = ({ match }) => ================================================================================ `; + +exports[`nested-ternary-promises.js 1`] = ` +====================================options===================================== +alignTernaryLines: false +arrowParens: "avoid" +endOfLine: "lf" +generatorStarSpacing: true +jsxSingleQuote: true +parsers: ["babel", "babel-flow", "flow", "typescript"] +printWidth: 80 +semi: false +singleQuote: true +spaceBeforeFunctionParen: true +trailingComma: "none" +yieldStarSpacing: true + | printWidth +=====================================input====================================== +// check for consistent formatting as discussed in: +// - https://github.com/eslint/eslint/issues/13971 +// - https://github.com/standard/standard/issues/1624 +// - https://github.com/brodybits/prettierx/issues/41 + +function test1() { + return condition1 + ? condition2 + ? Promise(1) + : Promise(2) + : condition3 + ? Promise(3) + : Promise(4) +} + +=====================================output===================================== +// check for consistent formatting as discussed in: +// - https://github.com/eslint/eslint/issues/13971 +// - https://github.com/standard/standard/issues/1624 +// - https://github.com/brodybits/prettierx/issues/41 + +function test1 () { + return condition1 + ? condition2 + ? Promise(1) + : Promise(2) + : condition3 + ? Promise(3) + : Promise(4) +} + +================================================================================ +`; diff --git a/tests/standard/nested-ternary-promises.js b/tests/standard/nested-ternary-promises.js new file mode 100644 index 0000000000..59fd9d27aa --- /dev/null +++ b/tests/standard/nested-ternary-promises.js @@ -0,0 +1,14 @@ +// check for consistent formatting as discussed in: +// - https://github.com/eslint/eslint/issues/13971 +// - https://github.com/standard/standard/issues/1624 +// - https://github.com/brodybits/prettierx/issues/41 + +function test1() { + return condition1 + ? condition2 + ? Promise(1) + : Promise(2) + : condition3 + ? Promise(3) + : Promise(4) +}