Skip to content

Commit

Permalink
fix: pass option to printer
Browse files Browse the repository at this point in the history
  • Loading branch information
zackad committed Nov 28, 2024
1 parent 5a1ebef commit b24006a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/print/CallExpression.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {

const { group, softline, line, indent, join } = doc.builders;

const p = (node, path, print) => {
const p = (node, path, print, options) => {
node[EXPRESSION_NEEDED] = false;
node[STRING_NEEDS_QUOTES] = true;
const mappedArguments = path.map(print, "arguments");
Expand All @@ -22,6 +22,8 @@ const p = (node, path, print) => {
// Optimization: No line break between "(" and "{" if
// there is exactly one object parameter
parts.push(mappedArguments[0], ")");
} else if (options.experimentalMethodChainIndentation) {
parts.push(indent([join([","], mappedArguments)]), ")");
} else {
parts.push(
indent([softline, join([",", line], mappedArguments)]),
Expand Down
12 changes: 9 additions & 3 deletions src/print/MemberExpression.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,19 @@ import {
wrapExpressionIfNeeded
} from "../util/index.js";

const { group } = doc.builders;
const { group, softline, indent } = doc.builders;

const p = (node, path, print) => {
const p = (node, path, print, options) => {
node[EXPRESSION_NEEDED] = false;
node[STRING_NEEDS_QUOTES] = true;
const parts = [path.call(print, "object")];
parts.push(node.computed ? "[" : ".");
if (node.computed) {
parts.push("[");
} else if (options.experimentalMethodChainIndentation) {
parts.push(indent([softline, "."]));
} else {
parts.push(".");
}
parts.push(path.call(print, "property"));
if (node.computed) {
parts.push("]");
Expand Down

0 comments on commit b24006a

Please sign in to comment.