Skip to content

Commit

Permalink
skipping prettier#7884 for migrationg prettier from 1.x to 3.x
Browse files Browse the repository at this point in the history
  • Loading branch information
vishnu-meera committed Dec 20, 2023
1 parent b86701d commit b354648
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 7 additions & 0 deletions src/language-js/options.js
Expand Up @@ -93,6 +93,13 @@ const options = {
],
},
singleAttributePerLine: commonOptions.singleAttributePerLine,
respectLongMethodChains: {
category: CATEGORY_JAVASCRIPT,
type: "boolean",
default: true,
description:
"Will not break method chains with more than 3 method calls, like Prettier 1.x.",
}
};

export default options;
6 changes: 3 additions & 3 deletions src/language-js/print/member-chain.js
Expand Up @@ -371,13 +371,13 @@ function printMemberChain(path, options, print) {
let result;

// We don't want to print in one line if at least one of these conditions occurs:
// * option has respectLongMethodChains as true
// * the chain has comments,
// * the chain is an expression statement and all the arguments are literal-like ("fluent configuration" pattern),
// * the chain is longer than 2 calls and has non-trivial arguments or more than 2 arguments in any call but the first one,
// * any group but the last one has a hard line,
// * the last call's arguments have a hard line and other calls have non-trivial arguments.
// * any group but the last one has a hard line
if (
nodeHasComment ||
options.respectLongMethodChains || nodeHasComment ||
(callExpressions.length > 2 &&
callExpressions.some(
(expr) => !expr.arguments.every((arg) => isSimpleCallArgument(arg)),
Expand Down

0 comments on commit b354648

Please sign in to comment.