diff --git a/README.md b/README.md index cfc3f7908b..6a2e5b8d77 100644 --- a/README.md +++ b/README.md @@ -20,11 +20,11 @@ prettierx ## Additional prettierX options - `--align-object-properties` (`alignObjectProperties: true`): Align colons in multiline object literals (not applied with any of the JSON parsers). +- `--offset-ternary-expressions` (`offsetTernaryExpressions: true`): Indent and align ternary expression branches more consistently with "Standard JS" (similar to the corresponding eslint option). - `--space-before-function-paren` (`spaceBeforeFunctionParen: true`): Put a space before function parenthesis in all declarations (similar to the corresponding eslint option). (Default is to put a space before function parenthesis for untyped anonymous functions only.) - `--generator-star-spacing` (`generatorStarSpacing: true`): Put spaces around the star (`*`) in generator functions (before and after - similar to the corresponding eslint option). (Default is after only.) - `--yield-star-spacing` (`yieldStarSpacing: true`): Put spaces around the star (`*`) in `yield*` expressions (before and after - similar to the corresponding eslint option). (Default is after only.) - `--no-indent-chains` (`indentChains: false`): Disable indents at the start of chained calls. -- `--no-align-ternary-lines` (`alignTernaryLines: false`): Disable default alignment of ternary expression lines, which may be in conflict with "Standard JS" formatting in certain nested ternary cases ... see [`docs/options.md`](docs/options.md). - `--break-before-else` (`breakBeforeElse: true`): Always add a line break before else. - --import-formatting (importFormatting: ""): Formatting of import statements, may be `oneline` to avoid conflict with VSCode "Organize Imports" feature. - `--html-void-tags` (`htmlVoidTags: true`): Format void HTML elements as void tags. @@ -56,9 +56,9 @@ The following options should be used to _format_ the code _as consistently as po - `--single-quote` (`singleQuote: true`) - `--jsx-single-quote` (`jsxSingleQuote: true`) - `--no-semi` (`semi: false`) +- `--offset-ternary-expressions` (`offsetTernaryExpressions: true`) - `--yield-star-spacing` (`yieldStarSpacing: true`) - `--trailing-comma none` (`trailingComma: "none"`) -- and possibly `--no-align-ternary-lines` (`alignTernaryLines: false`) - see [`docs/options.md`](docs/options.md) for some more information Note that this tool does **not** follow any of the other ["Standard JS"](https://standardjs.com/) rules. It is recommended to use this tool together with eslint, in some form, to archive correct formatting according to ["Standard JS"](https://standardjs.com/). @@ -68,9 +68,11 @@ Any known conflicts with ["Standard JS"](https://standardjs.com/) will be tracke - `--arrow-parens avoid` (`arrowParens: "avoid"`), especially in combination with `--space-in-parens` (`spaceInParens: true`). - `--break-long-method-chains` (`breakLongMethodChains: true`) +- `--offset-ternary-expressions` (`offsetTernaryExpressions: true`) ## options removed +- `--no-align-ternary-lines` - replaced with: `--offset-ternary-expressions` - `--paren-spacing` - replaced with finer-grained options: - `--array-bracket-spacing` - `--css-paren-spacing` diff --git a/docs/options.md b/docs/options.md index 6cec40e3f7..098654d8d9 100644 --- a/docs/options.md +++ b/docs/options.md @@ -243,19 +243,6 @@ Put spaces around the star (`*`) in `yield*` expressions (before and after - sim | ------- | ---------------------- | -------------------------- | | `false` | `--yield-star-spacing` | `yieldStarSpacing: ` | -## Align ternary lines - -Keep or disable default alignment of ternary expression lines, which may be in conflict with "Standard JS" formatting in certain nested ternary cases. - -Valid options: - -- `true` - Keep default alignment of ternary expression lines. -- `false` - Disable default alignment of ternary expression lines. Adds some more consistency with "Standard JS" in case of certain nested ternary expressions, may lead to some other conflicts with "Standard JS". - -| Default | CLI Override | API Override | -| ------- | -------------------------- | --------------------------- | -| `true` | `--no-align-ternary-lines` | `alignTernaryLines: ` | - ## break before else Always add a line break before else. @@ -309,6 +296,14 @@ Put spaces between computed property brackets (similar to the corresponding esli | ------- | ----------------------------- | --------------------------------- | | `false` | `--computed-property-spacing` | `computedPropertySpacing: ` | +## Offset ternary expressions + +Indent and align ternary expression branches more consistently with "Standard JS" (similar to the corresponding eslint option). + +| Default | CLI Override | API Override | +| ------- | ------------------------------ | ---------------------------------- | +| `false` | `--offset-ternary-expressions` | `offsetTernaryExpressions: ` | + ## Space after unary operator symbols Put spaces after unary operator symbols, except in the middle of `!!` (similar to the corresponding eslint option). Status: experimental, with limited testing. diff --git a/src/language-js/options.js b/src/language-js/options.js index ab19de9f28..e5956cc7e0 100644 --- a/src/language-js/options.js +++ b/src/language-js/options.js @@ -153,13 +153,12 @@ module.exports = { default: false, description: "Align colons in multiline object literals.", }, - alignTernaryLines: { + offsetTernaryExpressions: { category: CATEGORY_JAVASCRIPT, type: "boolean", - default: true, - description: "Keep default alignment of ternary expression lines.", - oppositeDescription: - 'Disable default alignment of ternary expression lines. Adds some more consistency with "Standard JS" in case of certain nested ternary expressions, may lead to some other conflicts with "Standard JS".', + default: false, + description: + 'Indent and align ternary expression branches more consistently with "Standard JS" (similar to the corresponding eslint option).', }, generatorStarSpacing: { category: CATEGORY_JAVASCRIPT, diff --git a/src/language-js/printer-estree.js b/src/language-js/printer-estree.js index 3b42d5410d..072c293982 100644 --- a/src/language-js/printer-estree.js +++ b/src/language-js/printer-estree.js @@ -432,8 +432,8 @@ function printTernaryOperator(path, options, print, operatorOptions) { consequentNode.type === operatorOptions.conditionalNodeType ? ifBreak("", concat(["(", parenSpace])) : "", - // [prettierx] alignTernaryLines option support: - options.alignTernaryLines + // [prettierx] offsetTernaryExpressions option support: + !options.offsetTernaryExpressions ? align(2, path.call(print, operatorOptions.consequentNodePropertyName)) : path.call(print, operatorOptions.consequentNodePropertyName), // [prettierx] spaceInParens option support (...) @@ -442,26 +442,27 @@ function printTernaryOperator(path, options, print, operatorOptions) { : "", line, ": ", - // [prettierx] alignTernaryLines option support: - !options.alignTernaryLines || + // [prettierx] offsetTernaryExpressions option support: + options.offsetTernaryExpressions || alternateNode.type === operatorOptions.conditionalNodeType ? path.call(print, operatorOptions.alternateNodePropertyName) : align(2, path.call(print, operatorOptions.alternateNodePropertyName)), ]); parts.push( - // [prettierx merge] from prettier@2.0.0: + // [prettierx] with offsetTernaryExpressions option support below: parent.type !== operatorOptions.conditionalNodeType || parent[operatorOptions.alternateNodePropertyName] === node || isParentTest ? part - : options.useTabs || !options.alignTernaryLines // [prettierx] (...) + : options.useTabs || options.offsetTernaryExpressions // [prettierx] offsetTernaryExpressions option support (...) ? dedent(indent(part)) : align(Math.max(0, options.tabWidth - 2), part) ); - // [prettierx] alignTernaryLines option support: - // Indent the whole ternary if alignTernaryLines:false (like ESLint). - if (!options.alignTernaryLines) { + // [prettierx] offsetTernaryExpressions option support: + // Indent the whole ternary if offsetTernaryExpressions is enabled + // (like ESLint). + if (options.offsetTernaryExpressions) { forceNoIndent = false; } } @@ -499,8 +500,6 @@ function printTernaryOperator(path, options, print, operatorOptions) { * ? d * : e */ - // [prettierx] alignTernaryLines option support: - options.alignTernaryLines && parent.type === operatorOptions.conditionalNodeType && parent[operatorOptions.alternateNodePropertyName] === node ? align(2, testDoc) diff --git a/tests/standard/__snapshots__/jsfmt.spec.js.snap b/tests/standard/__snapshots__/jsfmt.spec.js.snap index babaa312fb..f145f0eaca 100644 --- a/tests/standard/__snapshots__/jsfmt.spec.js.snap +++ b/tests/standard/__snapshots__/jsfmt.spec.js.snap @@ -2,11 +2,11 @@ exports[`correct.js 1`] = ` ====================================options===================================== -alignTernaryLines: false arrowParens: "avoid" endOfLine: "lf" generatorStarSpacing: true jsxSingleQuote: true +offsetTernaryExpressions: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 semi: false @@ -705,11 +705,11 @@ function * generator () { exports[`correct-ternaries.js 1`] = ` ====================================options===================================== -alignTernaryLines: false arrowParens: "avoid" endOfLine: "lf" generatorStarSpacing: true jsxSingleQuote: true +offsetTernaryExpressions: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 semi: false @@ -955,8 +955,8 @@ let icecream = a ? literalline : { - 123: 12 - } + 123: 12 + } ? line : softline @@ -1056,11 +1056,11 @@ const StorybookLoader = ({ match }) => exports[`incorrect.js 1`] = ` ====================================options===================================== -alignTernaryLines: false arrowParens: "avoid" endOfLine: "lf" generatorStarSpacing: true jsxSingleQuote: true +offsetTernaryExpressions: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 semi: false @@ -1838,11 +1838,11 @@ const dress = isSpace exports[`incorrect-ternaries.js 1`] = ` ====================================options===================================== -alignTernaryLines: false arrowParens: "avoid" endOfLine: "lf" generatorStarSpacing: true jsxSingleQuote: true +offsetTernaryExpressions: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 semi: false @@ -2060,8 +2060,8 @@ let icecream = a ? literalline : { - 123: 12 - } + 123: 12 + } ? line : softline diff --git a/tests/standard/jsfmt.spec.js b/tests/standard/jsfmt.spec.js index 13d1366a1f..8680e55ea4 100644 --- a/tests/standard/jsfmt.spec.js +++ b/tests/standard/jsfmt.spec.js @@ -7,11 +7,11 @@ run_spec(__dirname, ["babel", "babel-flow", "flow", "typescript"], { // "Standard JS": yieldStarSpacing: true, generatorStarSpacing: true, + offsetTernaryExpressions: true, spaceBeforeFunctionParen: true, singleQuote: true, jsxSingleQuote: true, semi: false, - alignTernaryLines: false, trailingComma: "none", // recommended: arrowParens: "avoid", diff --git a/tests/ternaries/__snapshots__/jsfmt.spec.js.snap b/tests/ternaries/__snapshots__/jsfmt.spec.js.snap index 8db09ae514..e8d285a41d 100644 --- a/tests/ternaries/__snapshots__/jsfmt.spec.js.snap +++ b/tests/ternaries/__snapshots__/jsfmt.spec.js.snap @@ -2,7 +2,6 @@ exports[`binary.js 1`] = ` ====================================options===================================== -alignTernaryLines: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 | printWidth @@ -44,7 +43,6 @@ room = room.map((row, rowIndex) => exports[`binary.js 2`] = ` ====================================options===================================== -alignTernaryLines: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 tabWidth: 4 @@ -87,7 +85,6 @@ room = room.map((row, rowIndex) => exports[`binary.js 3`] = ` ====================================options===================================== -alignTernaryLines: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 useTabs: true @@ -130,7 +127,6 @@ room = room.map((row, rowIndex) => exports[`binary.js 4`] = ` ====================================options===================================== -alignTernaryLines: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 tabWidth: 4 @@ -174,7 +170,6 @@ room = room.map((row, rowIndex) => exports[`func-call.js 1`] = ` ====================================options===================================== -alignTernaryLines: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 | printWidth @@ -203,7 +198,6 @@ fn( exports[`func-call.js 2`] = ` ====================================options===================================== -alignTernaryLines: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 tabWidth: 4 @@ -233,7 +227,6 @@ fn( exports[`func-call.js 3`] = ` ====================================options===================================== -alignTernaryLines: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 useTabs: true @@ -263,7 +256,6 @@ fn( exports[`func-call.js 4`] = ` ====================================options===================================== -alignTernaryLines: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 tabWidth: 4 @@ -294,7 +286,6 @@ fn( exports[`indent.js 1`] = ` ====================================options===================================== -alignTernaryLines: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 | printWidth @@ -624,7 +615,6 @@ a exports[`indent.js 2`] = ` ====================================options===================================== -alignTernaryLines: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 tabWidth: 4 @@ -955,7 +945,6 @@ a exports[`indent.js 3`] = ` ====================================options===================================== -alignTernaryLines: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 useTabs: true @@ -1286,7 +1275,6 @@ a exports[`indent.js 4`] = ` ====================================options===================================== -alignTernaryLines: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 tabWidth: 4 @@ -1622,7 +1610,6 @@ a exports[`nested.js 1`] = ` ====================================options===================================== -alignTernaryLines: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 | printWidth @@ -1826,7 +1813,6 @@ a exports[`nested.js 2`] = ` ====================================options===================================== -alignTernaryLines: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 tabWidth: 4 @@ -2031,7 +2017,6 @@ a exports[`nested.js 3`] = ` ====================================options===================================== -alignTernaryLines: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 useTabs: true @@ -2236,7 +2221,6 @@ a exports[`nested.js 4`] = ` ====================================options===================================== -alignTernaryLines: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 tabWidth: 4 @@ -2442,7 +2426,6 @@ a exports[`nested-in-condition.js 1`] = ` ====================================options===================================== -alignTernaryLines: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 | printWidth @@ -2531,7 +2514,6 @@ const value = ( exports[`nested-in-condition.js 2`] = ` ====================================options===================================== -alignTernaryLines: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 tabWidth: 4 @@ -2621,7 +2603,6 @@ const value = ( exports[`nested-in-condition.js 3`] = ` ====================================options===================================== -alignTernaryLines: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 useTabs: true @@ -2711,7 +2692,6 @@ const value = ( exports[`nested-in-condition.js 4`] = ` ====================================options===================================== -alignTernaryLines: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 tabWidth: 4 @@ -2802,7 +2782,6 @@ const value = ( exports[`parenthesis.js 1`] = ` ====================================options===================================== -alignTernaryLines: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 | printWidth @@ -2839,7 +2818,6 @@ debug exports[`parenthesis.js 2`] = ` ====================================options===================================== -alignTernaryLines: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 tabWidth: 4 @@ -2877,7 +2855,6 @@ debug exports[`parenthesis.js 3`] = ` ====================================options===================================== -alignTernaryLines: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 useTabs: true @@ -2915,7 +2892,6 @@ debug exports[`parenthesis.js 4`] = ` ====================================options===================================== -alignTernaryLines: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 tabWidth: 4 @@ -2954,7 +2930,6 @@ debug exports[`test.js 1`] = ` ====================================options===================================== -alignTernaryLines: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 | printWidth @@ -3014,7 +2989,6 @@ const obj5 = conditionIsTruthy exports[`test.js 2`] = ` ====================================options===================================== -alignTernaryLines: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 tabWidth: 4 @@ -3075,7 +3049,6 @@ const obj5 = conditionIsTruthy exports[`test.js 3`] = ` ====================================options===================================== -alignTernaryLines: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 useTabs: true @@ -3136,7 +3109,6 @@ const obj5 = conditionIsTruthy exports[`test.js 4`] = ` ====================================options===================================== -alignTernaryLines: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 tabWidth: 4 diff --git a/tests/ternaries/jsfmt.spec.js b/tests/ternaries/jsfmt.spec.js index 3f57c946ce..387ee76713 100644 --- a/tests/ternaries/jsfmt.spec.js +++ b/tests/ternaries/jsfmt.spec.js @@ -1,16 +1,11 @@ +run_spec(__dirname, ["babel", "babel-flow", "flow", "typescript"]); run_spec(__dirname, ["babel", "babel-flow", "flow", "typescript"], { - alignTernaryLines: true, -}); -run_spec(__dirname, ["babel", "babel-flow", "flow", "typescript"], { - alignTernaryLines: true, tabWidth: 4, }); run_spec(__dirname, ["babel", "babel-flow", "flow", "typescript"], { - alignTernaryLines: true, useTabs: true, }); run_spec(__dirname, ["babel", "babel-flow", "flow", "typescript"], { - alignTernaryLines: true, useTabs: true, tabWidth: 4, }); 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 eb10fe7f21..962e02c01d 100644 --- a/tests/ternaries/with-balanced-formatting/__snapshots__/jsfmt.spec.js.snap +++ b/tests/ternaries/with-balanced-formatting/__snapshots__/jsfmt.spec.js.snap @@ -2,8 +2,8 @@ exports[`binary.js 1`] = ` ====================================options===================================== -alignTernaryLines: false arrowParens: "avoid" +offsetTernaryExpressions: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 trailingComma: "none" @@ -46,8 +46,8 @@ room = room.map((row, rowIndex) => exports[`binary.js 2`] = ` ====================================options===================================== -alignTernaryLines: false arrowParens: "avoid" +offsetTernaryExpressions: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 tabWidth: 4 @@ -91,8 +91,8 @@ room = room.map((row, rowIndex) => exports[`binary.js 3`] = ` ====================================options===================================== -alignTernaryLines: false arrowParens: "avoid" +offsetTernaryExpressions: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 trailingComma: "none" @@ -136,8 +136,8 @@ room = room.map((row, rowIndex) => exports[`binary.js 4`] = ` ====================================options===================================== -alignTernaryLines: false arrowParens: "avoid" +offsetTernaryExpressions: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 tabWidth: 4 @@ -182,8 +182,8 @@ room = room.map((row, rowIndex) => exports[`func-call.js 1`] = ` ====================================options===================================== -alignTernaryLines: false arrowParens: "avoid" +offsetTernaryExpressions: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 trailingComma: "none" @@ -213,8 +213,8 @@ fn( exports[`func-call.js 2`] = ` ====================================options===================================== -alignTernaryLines: false arrowParens: "avoid" +offsetTernaryExpressions: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 tabWidth: 4 @@ -245,8 +245,8 @@ fn( exports[`func-call.js 3`] = ` ====================================options===================================== -alignTernaryLines: false arrowParens: "avoid" +offsetTernaryExpressions: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 trailingComma: "none" @@ -277,8 +277,8 @@ fn( exports[`func-call.js 4`] = ` ====================================options===================================== -alignTernaryLines: false arrowParens: "avoid" +offsetTernaryExpressions: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 tabWidth: 4 @@ -310,8 +310,8 @@ fn( exports[`indent.js 1`] = ` ====================================options===================================== -alignTernaryLines: false arrowParens: "avoid" +offsetTernaryExpressions: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 trailingComma: "none" @@ -642,8 +642,8 @@ a exports[`indent.js 2`] = ` ====================================options===================================== -alignTernaryLines: false arrowParens: "avoid" +offsetTernaryExpressions: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 tabWidth: 4 @@ -975,8 +975,8 @@ a exports[`indent.js 3`] = ` ====================================options===================================== -alignTernaryLines: false arrowParens: "avoid" +offsetTernaryExpressions: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 trailingComma: "none" @@ -1308,8 +1308,8 @@ a exports[`indent.js 4`] = ` ====================================options===================================== -alignTernaryLines: false arrowParens: "avoid" +offsetTernaryExpressions: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 tabWidth: 4 @@ -1642,8 +1642,8 @@ a exports[`nested.js 1`] = ` ====================================options===================================== -alignTernaryLines: false arrowParens: "avoid" +offsetTernaryExpressions: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 trailingComma: "none" @@ -1838,8 +1838,8 @@ const foo = ( a ? literalline : { - 123: 12 - } + 123: 12 + } ? line : softline; @@ -1848,8 +1848,8 @@ a exports[`nested.js 2`] = ` ====================================options===================================== -alignTernaryLines: false arrowParens: "avoid" +offsetTernaryExpressions: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 tabWidth: 4 @@ -2045,8 +2045,8 @@ const foo = ( a ? literalline : { - 123: 12 - } + 123: 12 + } ? line : softline; @@ -2055,8 +2055,8 @@ a exports[`nested.js 3`] = ` ====================================options===================================== -alignTernaryLines: false arrowParens: "avoid" +offsetTernaryExpressions: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 trailingComma: "none" @@ -2252,8 +2252,8 @@ const foo = ( a ? literalline : { - 123: 12 - } + 123: 12 + } ? line : softline; @@ -2262,8 +2262,8 @@ a exports[`nested.js 4`] = ` ====================================options===================================== -alignTernaryLines: false arrowParens: "avoid" +offsetTernaryExpressions: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 tabWidth: 4 @@ -2460,8 +2460,8 @@ const foo = ( a ? literalline : { - 123: 12 - } + 123: 12 + } ? line : softline; @@ -2470,8 +2470,8 @@ a exports[`nested-in-condition.js 1`] = ` ====================================options===================================== -alignTernaryLines: false arrowParens: "avoid" +offsetTernaryExpressions: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 trailingComma: "none" @@ -2561,8 +2561,8 @@ const value = ( exports[`nested-in-condition.js 2`] = ` ====================================options===================================== -alignTernaryLines: false arrowParens: "avoid" +offsetTernaryExpressions: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 tabWidth: 4 @@ -2653,8 +2653,8 @@ const value = ( exports[`nested-in-condition.js 3`] = ` ====================================options===================================== -alignTernaryLines: false arrowParens: "avoid" +offsetTernaryExpressions: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 trailingComma: "none" @@ -2745,8 +2745,8 @@ const value = ( exports[`nested-in-condition.js 4`] = ` ====================================options===================================== -alignTernaryLines: false arrowParens: "avoid" +offsetTernaryExpressions: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 tabWidth: 4 @@ -2838,8 +2838,8 @@ const value = ( exports[`parenthesis.js 1`] = ` ====================================options===================================== -alignTernaryLines: false arrowParens: "avoid" +offsetTernaryExpressions: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 trailingComma: "none" @@ -2877,8 +2877,8 @@ a => exports[`parenthesis.js 2`] = ` ====================================options===================================== -alignTernaryLines: false arrowParens: "avoid" +offsetTernaryExpressions: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 tabWidth: 4 @@ -2917,8 +2917,8 @@ a => exports[`parenthesis.js 3`] = ` ====================================options===================================== -alignTernaryLines: false arrowParens: "avoid" +offsetTernaryExpressions: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 trailingComma: "none" @@ -2957,8 +2957,8 @@ a => exports[`parenthesis.js 4`] = ` ====================================options===================================== -alignTernaryLines: false arrowParens: "avoid" +offsetTernaryExpressions: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 tabWidth: 4 @@ -2998,8 +2998,8 @@ a => exports[`test.js 1`] = ` ====================================options===================================== -alignTernaryLines: false arrowParens: "avoid" +offsetTernaryExpressions: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 trailingComma: "none" @@ -3060,8 +3060,8 @@ const obj5 = conditionIsTruthy exports[`test.js 2`] = ` ====================================options===================================== -alignTernaryLines: false arrowParens: "avoid" +offsetTernaryExpressions: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 tabWidth: 4 @@ -3123,8 +3123,8 @@ const obj5 = conditionIsTruthy exports[`test.js 3`] = ` ====================================options===================================== -alignTernaryLines: false arrowParens: "avoid" +offsetTernaryExpressions: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 trailingComma: "none" @@ -3186,8 +3186,8 @@ const obj5 = conditionIsTruthy exports[`test.js 4`] = ` ====================================options===================================== -alignTernaryLines: false arrowParens: "avoid" +offsetTernaryExpressions: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 tabWidth: 4 diff --git a/tests/ternaries/with-balanced-formatting/jsfmt.spec.js b/tests/ternaries/with-balanced-formatting/jsfmt.spec.js index 254620ea2a..e61f9beacd 100644 --- a/tests/ternaries/with-balanced-formatting/jsfmt.spec.js +++ b/tests/ternaries/with-balanced-formatting/jsfmt.spec.js @@ -6,9 +6,8 @@ const dirpath = `${__dirname}/..`; run_spec(dirpath, ["babel", "babel-flow", "flow", "typescript"], { // [prettierx] balanced ternary formatting option - // to improve consistency with "Standard JS" in certain cases - // (may lead to inconsistencies in some other cases): - alignTernaryLines: false, + // (with improved consistency with "Standard JS"): + offsetTernaryExpressions: true, // [prettierx] more options needed for consistency with "Standard JS": arrowParens: "avoid", trailingComma: "none", @@ -17,8 +16,9 @@ run_spec(dirpath, ["babel", "babel-flow", "flow", "typescript"], { run_spec(dirpath, ["babel", "babel-flow", "flow", "typescript"], { // variation from ../jsfmt.spec.js: tabWidth: 4, - // [prettierx] balanced ternary formatting option: - alignTernaryLines: false, + // [prettierx] balanced ternary formatting option + // (with improved consistency with "Standard JS"): + offsetTernaryExpressions: true, // [prettierx] more options needed for consistency with "Standard JS": arrowParens: "avoid", trailingComma: "none", @@ -27,8 +27,9 @@ run_spec(dirpath, ["babel", "babel-flow", "flow", "typescript"], { run_spec(dirpath, ["babel", "babel-flow", "flow", "typescript"], { // variation from ../jsfmt.spec.js: useTabs: true, - // [prettierx] balanced ternary formatting option: - alignTernaryLines: false, + // [prettierx] balanced ternary formatting option + // (with improved consistency with "Standard JS"): + offsetTernaryExpressions: true, // [prettierx] more options needed for consistency with "Standard JS": arrowParens: "avoid", trailingComma: "none", @@ -38,8 +39,9 @@ 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] balanced ternary formatting option + // (with improved consistency with "Standard JS"): + offsetTernaryExpressions: true, // [prettierx] more options needed for consistency with "Standard JS": arrowParens: "avoid", trailingComma: "none", diff --git a/tests/ternaries/with-inner-spacing/__snapshots__/jsfmt.spec.js.snap b/tests/ternaries/with-inner-spacing/__snapshots__/jsfmt.spec.js.snap index 6bb65bafc5..b429ca78c9 100644 --- a/tests/ternaries/with-inner-spacing/__snapshots__/jsfmt.spec.js.snap +++ b/tests/ternaries/with-inner-spacing/__snapshots__/jsfmt.spec.js.snap @@ -2,7 +2,6 @@ exports[`binary.js 1`] = ` ====================================options===================================== -alignTernaryLines: true arrayBracketSpacing: true arrowParens: "avoid" computedPropertySpacing: true @@ -51,7 +50,6 @@ room = room.map( ( row, rowIndex ) => exports[`func-call.js 1`] = ` ====================================options===================================== -alignTernaryLines: true arrayBracketSpacing: true arrowParens: "avoid" computedPropertySpacing: true @@ -87,7 +85,6 @@ fn( exports[`indent.js 1`] = ` ====================================options===================================== -alignTernaryLines: true arrayBracketSpacing: true arrowParens: "avoid" computedPropertySpacing: true @@ -424,7 +421,6 @@ a exports[`nested.js 1`] = ` ====================================options===================================== -alignTernaryLines: true arrayBracketSpacing: true arrowParens: "avoid" computedPropertySpacing: true @@ -635,7 +631,6 @@ a exports[`nested-in-condition.js 1`] = ` ====================================options===================================== -alignTernaryLines: true arrayBracketSpacing: true arrowParens: "avoid" computedPropertySpacing: true @@ -731,7 +726,6 @@ const value = ( exports[`parenthesis.js 1`] = ` ====================================options===================================== -alignTernaryLines: true arrayBracketSpacing: true arrowParens: "avoid" computedPropertySpacing: true @@ -775,7 +769,6 @@ a => exports[`test.js 1`] = ` ====================================options===================================== -alignTernaryLines: true arrayBracketSpacing: true arrowParens: "avoid" computedPropertySpacing: true diff --git a/tests/ternaries/with-inner-spacing/jsfmt.spec.js b/tests/ternaries/with-inner-spacing/jsfmt.spec.js index 92b623fbc2..b08f5b1ef0 100644 --- a/tests/ternaries/with-inner-spacing/jsfmt.spec.js +++ b/tests/ternaries/with-inner-spacing/jsfmt.spec.js @@ -5,7 +5,6 @@ const dirpath = `${__dirname}/..`; run_spec(dirpath, ["babel", "babel-flow", "flow", "typescript"], { - alignTernaryLines: true, spaceInParens: true, arrayBracketSpacing: true, computedPropertySpacing: true, diff --git a/tests/ternary-object-expressions/__snapshots__/jsfmt.spec.js.snap b/tests/ternary-object-expressions/__snapshots__/jsfmt.spec.js.snap index 31bd406db3..c62bc6b4ac 100644 --- a/tests/ternary-object-expressions/__snapshots__/jsfmt.spec.js.snap +++ b/tests/ternary-object-expressions/__snapshots__/jsfmt.spec.js.snap @@ -2,7 +2,6 @@ exports[`crewdress.js 1`] = ` ====================================options===================================== -alignTernaryLines: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 | printWidth @@ -35,7 +34,6 @@ const dress = isSpace exports[`crewdress.js 2`] = ` ====================================options===================================== -alignTernaryLines: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 tabWidth: 4 @@ -69,7 +67,6 @@ const dress = isSpace exports[`crewdress.js 3`] = ` ====================================options===================================== -alignTernaryLines: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 useTabs: true @@ -103,7 +100,6 @@ const dress = isSpace exports[`crewdress.js 4`] = ` ====================================options===================================== -alignTernaryLines: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 tabWidth: 4 @@ -138,7 +134,6 @@ const dress = isSpace exports[`nested-ternary-promises.js 1`] = ` ====================================options===================================== -alignTernaryLines: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 | printWidth @@ -179,7 +174,6 @@ function test1() { exports[`nested-ternary-promises.js 2`] = ` ====================================options===================================== -alignTernaryLines: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 tabWidth: 4 @@ -221,7 +215,6 @@ function test1() { exports[`nested-ternary-promises.js 3`] = ` ====================================options===================================== -alignTernaryLines: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 useTabs: true @@ -263,7 +256,6 @@ function test1() { exports[`nested-ternary-promises.js 4`] = ` ====================================options===================================== -alignTernaryLines: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 tabWidth: 4 diff --git a/tests/ternary-object-expressions/jsfmt.spec.js b/tests/ternary-object-expressions/jsfmt.spec.js index 3f57c946ce..387ee76713 100644 --- a/tests/ternary-object-expressions/jsfmt.spec.js +++ b/tests/ternary-object-expressions/jsfmt.spec.js @@ -1,16 +1,11 @@ +run_spec(__dirname, ["babel", "babel-flow", "flow", "typescript"]); run_spec(__dirname, ["babel", "babel-flow", "flow", "typescript"], { - alignTernaryLines: true, -}); -run_spec(__dirname, ["babel", "babel-flow", "flow", "typescript"], { - alignTernaryLines: true, tabWidth: 4, }); run_spec(__dirname, ["babel", "babel-flow", "flow", "typescript"], { - alignTernaryLines: true, useTabs: true, }); run_spec(__dirname, ["babel", "babel-flow", "flow", "typescript"], { - alignTernaryLines: true, useTabs: true, tabWidth: 4, }); 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 8ebf96fdd9..4946dbcd70 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 @@ -2,8 +2,8 @@ exports[`crewdress.js 1`] = ` ====================================options===================================== -alignTernaryLines: false arrowParens: "avoid" +offsetTernaryExpressions: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 trailingComma: "none" @@ -37,8 +37,8 @@ const dress = isSpace exports[`crewdress.js 2`] = ` ====================================options===================================== -alignTernaryLines: false arrowParens: "avoid" +offsetTernaryExpressions: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 tabWidth: 4 @@ -73,8 +73,8 @@ const dress = isSpace exports[`crewdress.js 3`] = ` ====================================options===================================== -alignTernaryLines: false arrowParens: "avoid" +offsetTernaryExpressions: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 trailingComma: "none" @@ -109,8 +109,8 @@ const dress = isSpace exports[`crewdress.js 4`] = ` ====================================options===================================== -alignTernaryLines: false arrowParens: "avoid" +offsetTernaryExpressions: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 tabWidth: 4 @@ -146,8 +146,8 @@ const dress = isSpace exports[`nested-ternary-promises.js 1`] = ` ====================================options===================================== -alignTernaryLines: false arrowParens: "avoid" +offsetTernaryExpressions: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 trailingComma: "none" @@ -189,8 +189,8 @@ function test1() { exports[`nested-ternary-promises.js 2`] = ` ====================================options===================================== -alignTernaryLines: false arrowParens: "avoid" +offsetTernaryExpressions: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 tabWidth: 4 @@ -233,8 +233,8 @@ function test1() { exports[`nested-ternary-promises.js 3`] = ` ====================================options===================================== -alignTernaryLines: false arrowParens: "avoid" +offsetTernaryExpressions: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 trailingComma: "none" @@ -277,8 +277,8 @@ function test1() { exports[`nested-ternary-promises.js 4`] = ` ====================================options===================================== -alignTernaryLines: false arrowParens: "avoid" +offsetTernaryExpressions: true parsers: ["babel", "babel-flow", "flow", "typescript"] printWidth: 80 tabWidth: 4 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 254620ea2a..9e3465e7c9 100644 --- a/tests/ternary-object-expressions/with-balanced-formatting/jsfmt.spec.js +++ b/tests/ternary-object-expressions/with-balanced-formatting/jsfmt.spec.js @@ -5,10 +5,9 @@ const dirpath = `${__dirname}/..`; run_spec(dirpath, ["babel", "babel-flow", "flow", "typescript"], { - // [prettierx] balanced ternary formatting option - // to improve consistency with "Standard JS" in certain cases - // (may lead to inconsistencies in some other cases): - alignTernaryLines: false, + // [prettierx] balanced ternary formatting option, + // for consistency with "Standard JS": + offsetTernaryExpressions: true, // [prettierx] more options needed for consistency with "Standard JS": arrowParens: "avoid", trailingComma: "none", @@ -17,8 +16,9 @@ run_spec(dirpath, ["babel", "babel-flow", "flow", "typescript"], { run_spec(dirpath, ["babel", "babel-flow", "flow", "typescript"], { // variation from ../jsfmt.spec.js: tabWidth: 4, - // [prettierx] balanced ternary formatting option: - alignTernaryLines: false, + // [prettierx] balanced ternary formatting option, + // for consistency with "Standard JS": + offsetTernaryExpressions: true, // [prettierx] more options needed for consistency with "Standard JS": arrowParens: "avoid", trailingComma: "none", @@ -27,8 +27,9 @@ run_spec(dirpath, ["babel", "babel-flow", "flow", "typescript"], { run_spec(dirpath, ["babel", "babel-flow", "flow", "typescript"], { // variation from ../jsfmt.spec.js: useTabs: true, - // [prettierx] balanced ternary formatting option: - alignTernaryLines: false, + // [prettierx] balanced ternary formatting option, + // for consistency with "Standard JS": + offsetTernaryExpressions: true, // [prettierx] more options needed for consistency with "Standard JS": arrowParens: "avoid", trailingComma: "none", @@ -38,8 +39,9 @@ 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] balanced ternary formatting option, + // for consistency with "Standard JS": + offsetTernaryExpressions: true, // [prettierx] more options needed for consistency with "Standard JS": arrowParens: "avoid", trailingComma: "none", diff --git a/tests_integration/__tests__/__snapshots__/early-exit.js.snap b/tests_integration/__tests__/__snapshots__/early-exit.js.snap index 5335f1d9dc..0f0df691ca 100644 --- a/tests_integration/__tests__/__snapshots__/early-exit.js.snap +++ b/tests_integration/__tests__/__snapshots__/early-exit.js.snap @@ -70,7 +70,6 @@ Format options: --align-object-properties Align colons in multiline object literals. Defaults to false. - --no-align-ternary-lines Disable default alignment of ternary expression lines. Adds some more consistency with \\"Standard JS\\" in case of certain nested ternary expressions, may lead to some other conflicts with \\"Standard JS\\". --array-bracket-spacing Put spaces between array brackets (similar to the corresponding eslint option). Status: experimental, with limited testing. Defaults to false. --arrow-parens @@ -112,6 +111,9 @@ Format options: Defaults to false. --no-object-curly-spacing Disable spaces between object curly braces. + --offset-ternary-expressions + Indent and align ternary expression branches more consistently with \\"Standard JS\\" (similar to the corresponding eslint option). + Defaults to false. --parser Which parser to use. --print-width The line length where Prettier will try wrap. @@ -276,7 +278,6 @@ Format options: --align-object-properties Align colons in multiline object literals. Defaults to false. - --no-align-ternary-lines Disable default alignment of ternary expression lines. Adds some more consistency with \\"Standard JS\\" in case of certain nested ternary expressions, may lead to some other conflicts with \\"Standard JS\\". --array-bracket-spacing Put spaces between array brackets (similar to the corresponding eslint option). Status: experimental, with limited testing. Defaults to false. --arrow-parens @@ -318,6 +319,9 @@ Format options: Defaults to false. --no-object-curly-spacing Disable spaces between object curly braces. + --offset-ternary-expressions + Indent and align ternary expression branches more consistently with \\"Standard JS\\" (similar to the corresponding eslint option). + Defaults to false. --parser Which parser to use. --print-width The line length where Prettier will try wrap. diff --git a/tests_integration/__tests__/__snapshots__/help-options.js.snap b/tests_integration/__tests__/__snapshots__/help-options.js.snap index fdf9699373..dd0d6eb581 100644 --- a/tests_integration/__tests__/__snapshots__/help-options.js.snap +++ b/tests_integration/__tests__/__snapshots__/help-options.js.snap @@ -13,19 +13,6 @@ Default: false exports[`show detailed usage with --help align-object-properties (write) 1`] = `Array []`; -exports[`show detailed usage with --help align-ternary-lines (stderr) 1`] = `""`; - -exports[`show detailed usage with --help align-ternary-lines (stdout) 1`] = ` -"--align-ternary-lines - - Keep default alignment of ternary expression lines. - -Default: true -" -`; - -exports[`show detailed usage with --help align-ternary-lines (write) 1`] = `Array []`; - exports[`show detailed usage with --help array-bracket-spacing (stderr) 1`] = `""`; exports[`show detailed usage with --help array-bracket-spacing (stdout) 1`] = ` @@ -448,17 +435,6 @@ Default: log exports[`show detailed usage with --help loglevel (write) 1`] = `Array []`; -exports[`show detailed usage with --help no-align-ternary-lines (stderr) 1`] = `""`; - -exports[`show detailed usage with --help no-align-ternary-lines (stdout) 1`] = ` -"--no-align-ternary-lines - - Disable default alignment of ternary expression lines. Adds some more consistency with \\"Standard JS\\" in case of certain nested ternary expressions, may lead to some other conflicts with \\"Standard JS\\". -" -`; - -exports[`show detailed usage with --help no-align-ternary-lines (write) 1`] = `Array []`; - exports[`show detailed usage with --help no-color (stderr) 1`] = `""`; exports[`show detailed usage with --help no-color (stdout) 1`] = ` @@ -593,6 +569,19 @@ Default: true exports[`show detailed usage with --help object-curly-spacing (write) 1`] = `Array []`; +exports[`show detailed usage with --help offset-ternary-expressions (stderr) 1`] = `""`; + +exports[`show detailed usage with --help offset-ternary-expressions (stdout) 1`] = ` +"--offset-ternary-expressions + + Indent and align ternary expression branches more consistently with \\"Standard JS\\" (similar to the corresponding eslint option). + +Default: false +" +`; + +exports[`show detailed usage with --help offset-ternary-expressions (write) 1`] = `Array []`; + exports[`show detailed usage with --help parser (stderr) 1`] = `""`; exports[`show detailed usage with --help parser (stdout) 1`] = ` diff --git a/tests_integration/__tests__/__snapshots__/plugin-options-string.js.snap b/tests_integration/__tests__/__snapshots__/plugin-options-string.js.snap index 07d9115ff9..823c947e42 100644 --- a/tests_integration/__tests__/__snapshots__/plugin-options-string.js.snap +++ b/tests_integration/__tests__/__snapshots__/plugin-options-string.js.snap @@ -5,7 +5,7 @@ exports[` 1`] = ` - First value + Second value -@@ -34,10 +34,12 @@ +@@ -33,10 +33,12 @@ --end-of-line Which end of line characters to apply. Defaults to lf. diff --git a/tests_integration/__tests__/__snapshots__/plugin-options.js.snap b/tests_integration/__tests__/__snapshots__/plugin-options.js.snap index 451cbcefb4..86ba53a2d1 100644 --- a/tests_integration/__tests__/__snapshots__/plugin-options.js.snap +++ b/tests_integration/__tests__/__snapshots__/plugin-options.js.snap @@ -5,7 +5,7 @@ exports[` 1`] = ` - First value + Second value -@@ -34,10 +34,12 @@ +@@ -33,10 +33,12 @@ --end-of-line Which end of line characters to apply. Defaults to lf. diff --git a/tests_integration/__tests__/__snapshots__/schema.js.snap b/tests_integration/__tests__/__snapshots__/schema.js.snap index 92f4513ea6..a4f7b9f17d 100644 --- a/tests_integration/__tests__/__snapshots__/schema.js.snap +++ b/tests_integration/__tests__/__snapshots__/schema.js.snap @@ -11,11 +11,6 @@ Object { "description": "Align colons in multiline object literals.", "type": "boolean", }, - "alignTernaryLines": Object { - "default": true, - "description": "Keep default alignment of ternary expression lines.", - "type": "boolean", - }, "arrayBracketSpacing": Object { "default": false, "description": "Put spaces between array brackets (similar to the corresponding eslint option). Status: experimental, with limited testing.", @@ -193,6 +188,11 @@ This option cannot be used with --range-start and --range-end.", "description": "Put spaces between object curly braces (similar to the corresponding eslint option).", "type": "boolean", }, + "offsetTernaryExpressions": Object { + "default": false, + "description": "Indent and align ternary expression branches more consistently with \\"Standard JS\\" (similar to the corresponding eslint option).", + "type": "boolean", + }, "parser": Object { "default": undefined, "description": "Which parser to use.", diff --git a/tests_integration/__tests__/__snapshots__/support-info.js.snap b/tests_integration/__tests__/__snapshots__/support-info.js.snap index 74191f7e44..ab2404a077 100644 --- a/tests_integration/__tests__/__snapshots__/support-info.js.snap +++ b/tests_integration/__tests__/__snapshots__/support-info.js.snap @@ -77,10 +77,6 @@ Object { "default": false, "type": "boolean", }, - "alignTernaryLines": Object { - "default": true, - "type": "boolean", - }, "arrayBracketSpacing": Object { "default": false, "type": "boolean", @@ -189,6 +185,10 @@ Object { "default": true, "type": "boolean", }, + "offsetTernaryExpressions": Object { + "default": false, + "type": "boolean", + }, "parser": Object { "choices": Array [ "flow", @@ -792,15 +792,6 @@ exports[`CLI --support-info (stdout) 1`] = ` \\"pluginDefaults\\": {}, \\"type\\": \\"boolean\\" }, - { - \\"category\\": \\"JavaScript\\", - \\"default\\": true, - \\"description\\": \\"Keep default alignment of ternary expression lines.\\", - \\"name\\": \\"alignTernaryLines\\", - \\"oppositeDescription\\": \\"Disable default alignment of ternary expression lines. Adds some more consistency with \\\\\\"Standard JS\\\\\\" in case of certain nested ternary expressions, may lead to some other conflicts with \\\\\\"Standard JS\\\\\\".\\", - \\"pluginDefaults\\": {}, - \\"type\\": \\"boolean\\" - }, { \\"category\\": \\"JavaScript\\", \\"default\\": false, @@ -1034,6 +1025,14 @@ exports[`CLI --support-info (stdout) 1`] = ` \\"pluginDefaults\\": {}, \\"type\\": \\"boolean\\" }, + { + \\"category\\": \\"JavaScript\\", + \\"default\\": false, + \\"description\\": \\"Indent and align ternary expression branches more consistently with \\\\\\"Standard JS\\\\\\" (similar to the corresponding eslint option).\\", + \\"name\\": \\"offsetTernaryExpressions\\", + \\"pluginDefaults\\": {}, + \\"type\\": \\"boolean\\" + }, { \\"category\\": \\"Global\\", \\"choices\\": [