diff --git a/src/binary-operator-printers/logical.js b/src/binary-operator-printers/logical.js index 089b57217..c784ae5f7 100644 --- a/src/binary-operator-printers/logical.js +++ b/src/binary-operator-printers/logical.js @@ -6,15 +6,11 @@ import { shouldGroupOrIndent } from './utils/should-group-or-indent.js'; const { indent } = doc.builders; -const indentIfNecessaryBuilder = (path, options) => (document) => { +const indentIfNecessaryBuilder = (path) => (document) => { for (let i = 0, { node } = path; ; i += 1) { const parentNode = path.getParentNode(i); if (notIndentParentTypes.includes(parentNode.type)) return document; - if ( - options.experimentalTernaries && - parentNode.type === 'Conditional' && - parentNode.condition === node - ) + if (parentNode.type === 'Conditional' && parentNode.condition === node) return document; if (shouldGroupOrIndent(parentNode, [])) return indent(document); if (node === parentNode.right) return document; diff --git a/src/binary-operator-printers/printers/create-binary-operation-printer.js b/src/binary-operator-printers/printers/create-binary-operation-printer.js index 9f382c8d9..2a9bdaef8 100644 --- a/src/binary-operator-printers/printers/create-binary-operation-printer.js +++ b/src/binary-operator-printers/printers/create-binary-operation-printer.js @@ -22,7 +22,7 @@ export const createBinaryOperationPrinter = (groupIfNecessaryBuilder, indentIfNecessaryBuilder) => (node, path, print, options) => { const groupIfNecessary = groupIfNecessaryBuilder(path); - const indentIfNecessary = indentIfNecessaryBuilder(path, options); + const indentIfNecessary = indentIfNecessaryBuilder(path); return groupIfNecessary([ path.call(print, 'left'), diff --git a/src/slang-printers/create-binary-operation-printer.ts b/src/slang-printers/create-binary-operation-printer.ts index 2e97c66c0..4cb535a5a 100644 --- a/src/slang-printers/create-binary-operation-printer.ts +++ b/src/slang-printers/create-binary-operation-printer.ts @@ -42,8 +42,7 @@ export const createBinaryOperationPrinter = path: AstPath ) => (document: Doc) => Doc, indentRulesBuilder: ( - path: AstPath, - options: ParserOptions + path: AstPath ) => (document: Doc) => Doc ) => ( @@ -53,7 +52,7 @@ export const createBinaryOperationPrinter = options: ParserOptions ): Doc => { const groupRules = groupRulesBuilder(path); - const indentRules = indentRulesBuilder(path, options); + const indentRules = indentRulesBuilder(path); return groupRules([ path.call(print, 'leftOperand'), diff --git a/src/slang-printers/print-logical-operation.ts b/src/slang-printers/print-logical-operation.ts index 55c2b72c9..d0b7387c7 100644 --- a/src/slang-printers/print-logical-operation.ts +++ b/src/slang-printers/print-logical-operation.ts @@ -7,25 +7,20 @@ import { shouldNotIndent } from './print-binary-operation.js'; -import type { AstPath, Doc, ParserOptions } from 'prettier'; -import type { - AstNode, - BinaryOperation, - StrictAstNode -} from '../slang-nodes/types.d.ts'; +import type { AstPath, Doc } from 'prettier'; +import type { BinaryOperation, StrictAstNode } from '../slang-nodes/types.d.ts'; const { indent } = doc.builders; const logicalGroupRulesBuilder = binaryGroupRulesBuilder(() => false); const logicalIndentRulesBuilder = - (path: AstPath, options: ParserOptions) => + (path: AstPath) => (document: Doc): Doc => { for (let i = 1, node = path.node; ; i++) { const parent = path.getNode(i) as StrictAstNode; if (shouldNotIndent(parent, path, i)) break; if ( - options.experimentalTernaries && parent.kind === NonterminalKind.ConditionalExpression && parent.operand === node ) diff --git a/tests/format/BinaryOperators/__snapshots__/format.test.js.snap b/tests/format/BinaryOperators/__snapshots__/format.test.js.snap index 92eb3ccd8..7a527804f 100644 --- a/tests/format/BinaryOperators/__snapshots__/format.test.js.snap +++ b/tests/format/BinaryOperators/__snapshots__/format.test.js.snap @@ -484,7 +484,7 @@ contract ComparisonOperators { >= veryVeryVeryVeryVeryLongVariableCalledA; a += veryVeryVeryVeryVeryLongVariableCalledA - || veryVeryVeryVeryVeryLongVariableCalledB + || veryVeryVeryVeryVeryLongVariableCalledB ? 1 : 2 ) {} @@ -638,7 +638,7 @@ contract LogicalOperators { a <= veryVeryVeryVeryVeryLongVariableCalledA; a += veryVeryVeryVeryVeryLongVariableCalledA - || veryVeryVeryVeryVeryLongVariableCalledB + || veryVeryVeryVeryVeryLongVariableCalledB ? 1 : 2 ) {} @@ -1167,7 +1167,7 @@ contract ComparisonOperators { veryVeryVeryVeryVeryLongVariableCalledA; a += veryVeryVeryVeryVeryLongVariableCalledA || - veryVeryVeryVeryVeryLongVariableCalledB + veryVeryVeryVeryVeryLongVariableCalledB ? 1 : 2 ) {} @@ -1321,7 +1321,7 @@ contract LogicalOperators { a <= veryVeryVeryVeryVeryLongVariableCalledA; a += veryVeryVeryVeryVeryLongVariableCalledA || - veryVeryVeryVeryVeryLongVariableCalledB + veryVeryVeryVeryVeryLongVariableCalledB ? 1 : 2 ) {}