Skip to content

Commit

Permalink
prettierx: test formatting of nested ternary promise expressions
Browse files Browse the repository at this point in the history
check for consistent formatting as discussed in:

- eslint/eslint#13971
- standard/standard#1624
- #41
  • Loading branch information
brodybits committed Jan 1, 2021
1 parent bff3a6e commit a3e9563
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
50 changes: 50 additions & 0 deletions tests/standard/__snapshots__/jsfmt.spec.js.snap
Expand Up @@ -2159,3 +2159,53 @@ const StorybookLoader = ({ match }) =><LF>

================================================================================
`;

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:<LF>
// - https://github.com/eslint/eslint/issues/13971<LF>
// - https://github.com/standard/standard/issues/1624<LF>
// - https://github.com/brodybits/prettierx/issues/41<LF>
<LF>
function test1() {<LF>
return condition1<LF>
? condition2<LF>
? Promise(1)<LF>
: Promise(2)<LF>
: condition3<LF>
? Promise(3)<LF>
: Promise(4)<LF>
}<LF>

=====================================output=====================================
// check for consistent formatting as discussed in:<LF>
// - https://github.com/eslint/eslint/issues/13971<LF>
// - https://github.com/standard/standard/issues/1624<LF>
// - https://github.com/brodybits/prettierx/issues/41<LF>
<LF>
function test1 () {<LF>
return condition1<LF>
? condition2<LF>
? Promise(1)<LF>
: Promise(2)<LF>
: condition3<LF>
? Promise(3)<LF>
: Promise(4)<LF>
}<LF>

================================================================================
`;
14 changes: 14 additions & 0 deletions 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)
}

0 comments on commit a3e9563

Please sign in to comment.