Forbid AstPath.call without name (#10541)
This commit is contained in:
1 parent
521b63bb27
commit
863eb079dc
14 files changed
+103
-19
No files matched your search
@@ -311,7 +311,7 @@ function genericPrint(path, options, print) {
|
||||
if (node.type === "media-query" && node.value === "") {
|
||||
return;
|
||||
}
|
||||
parts.push(childPath.call(print));
|
||||
parts.push(print(childPath));
|
||||
}, "nodes");
|
||||
|
||||
return group(indent(join(line, parts)));
|
||||
@@ -988,7 +988,7 @@ function printNodeSequence(path, options, print) {
|
||||
options.originalText.slice(locStart(childNode), locEnd(childNode))
|
||||
);
|
||||
} else {
|
||||
parts.push(pathChild.call(print));
|
||||
parts.push(print(pathChild));
|
||||
}
|
||||
|
||||
if (i !== nodes.length - 1) {
|
||||
|
||||
@@ -21,7 +21,7 @@ function genericPrint(path, options, print) {
|
||||
case "Document": {
|
||||
const parts = [];
|
||||
path.each((pathChild, index, definitions) => {
|
||||
parts.push(pathChild.call(print));
|
||||
parts.push(print(pathChild));
|
||||
if (index !== definitions.length - 1) {
|
||||
parts.push(hardline);
|
||||
if (
|
||||
|
||||
@@ -285,7 +285,7 @@ function printBinaryishExpressions(
|
||||
}
|
||||
} else {
|
||||
// Our stopping case. Simply print the node normally.
|
||||
parts.push(group(path.call(print)));
|
||||
parts.push(group(print(path)));
|
||||
}
|
||||
|
||||
return parts;
|
||||
|
||||
@@ -150,7 +150,7 @@ function printCallArguments(path, options, print) {
|
||||
if (shouldGroupFirst && i === 0) {
|
||||
printedExpanded = [
|
||||
[
|
||||
argPath.call((p) => print(p, { expandFirstArg: true })),
|
||||
print(argPath, { expandFirstArg: true }),
|
||||
printedArguments.length > 1 ? "," : "",
|
||||
hasEmptyLineFollowingFirstArg ? hardline : line,
|
||||
hasEmptyLineFollowingFirstArg ? hardline : "",
|
||||
@@ -161,7 +161,7 @@ function printCallArguments(path, options, print) {
|
||||
if (shouldGroupLast && i === args.length - 1) {
|
||||
printedExpanded = [
|
||||
...printedArguments.slice(0, -1),
|
||||
argPath.call((p) => print(p, { expandLastArg: true })),
|
||||
print(argPath, { expandLastArg: true }),
|
||||
];
|
||||
}
|
||||
});
|
||||
|
||||
@@ -65,7 +65,7 @@ function printFunctionParameters(
|
||||
if (isLastParameter && functionNode.rest) {
|
||||
printed.push("...");
|
||||
}
|
||||
printed.push(parameterPath.call(print));
|
||||
printed.push(print(parameterPath));
|
||||
if (isLastParameter) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -250,7 +250,7 @@ function printArrowFunctionExpression(path, options, print, args) {
|
||||
let body;
|
||||
let chainShouldBreak = false;
|
||||
|
||||
path.call(function rec(path) {
|
||||
(function rec(path) {
|
||||
const doc = printArrowFunctionSignature(path, options, print, args);
|
||||
signatures.push(
|
||||
signatures.length === 0 ? doc : printComments(path, doc, options)
|
||||
@@ -272,7 +272,7 @@ function printArrowFunctionExpression(path, options, print, args) {
|
||||
node = node.body;
|
||||
path.call(rec, "body");
|
||||
}
|
||||
});
|
||||
})(path);
|
||||
|
||||
if (signatures.length > 1) {
|
||||
return printArrowChain(
|
||||
|
||||
@@ -135,7 +135,7 @@ function printMemberChain(path, options, print) {
|
||||
} else {
|
||||
printedNodes.unshift({
|
||||
node,
|
||||
printed: path.call(print),
|
||||
printed: print(path),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,7 +169,7 @@ function printUnionType(path, options, print) {
|
||||
// // comment
|
||||
// | child2
|
||||
const printed = path.map((typePath) => {
|
||||
let printedType = typePath.call(print);
|
||||
let printedType = print(typePath);
|
||||
if (!shouldHug) {
|
||||
printedType = align(2, printedType);
|
||||
}
|
||||
|
||||
@@ -702,7 +702,7 @@ function printPathNoParens(path, options, print, args) {
|
||||
path.map((casePath, index, cases) => {
|
||||
const caseNode = casePath.getValue();
|
||||
return [
|
||||
casePath.call(print),
|
||||
print(casePath),
|
||||
index !== cases.length - 1 &&
|
||||
isNextLineEmpty(caseNode, options)
|
||||
? hardline
|
||||
|
||||
@@ -411,8 +411,8 @@ function genericPrint(path, options, print) {
|
||||
printChildren(path, options, print, {
|
||||
processor: (childPath, index) =>
|
||||
index === 0
|
||||
? group([softline, childPath.call(print)])
|
||||
: childPath.call(print),
|
||||
? group([softline, print(childPath)])
|
||||
: print(childPath),
|
||||
})
|
||||
),
|
||||
nextNode && nextNode.type === "footnoteDefinition"
|
||||
@@ -469,13 +469,13 @@ function printListItem(path, options, print, listPrefix) {
|
||||
printChildren(path, options, print, {
|
||||
processor: (childPath, index) => {
|
||||
if (index === 0 && childPath.getValue().type !== "list") {
|
||||
return align(" ".repeat(prefix.length), childPath.call(print));
|
||||
return align(" ".repeat(prefix.length), print(childPath));
|
||||
}
|
||||
|
||||
const alignment = " ".repeat(
|
||||
clamp(options.tabWidth - listPrefix.length, 0, 3) // 4+ will cause indented code block
|
||||
);
|
||||
return [alignment, align(alignment, childPath.call(print))];
|
||||
return [alignment, align(alignment, print(childPath))];
|
||||
},
|
||||
}),
|
||||
];
|
||||
@@ -565,7 +565,7 @@ function printTable(path, options, print) {
|
||||
const contents = path.map(
|
||||
(rowPath) =>
|
||||
rowPath.map((cellPath, columnIndex) => {
|
||||
const text = printDocToString(cellPath.call(print), options).formatted;
|
||||
const text = printDocToString(print(cellPath), options).formatted;
|
||||
const width = getStringWidth(text);
|
||||
columnMaxWidths[columnIndex] = Math.max(
|
||||
columnMaxWidths[columnIndex] || 3, // minimum width = 3 (---, :--, :-:, --:)
|
||||
@@ -691,14 +691,14 @@ function printRoot(path, options, print) {
|
||||
}
|
||||
}
|
||||
|
||||
return childPath.call(print);
|
||||
return print(childPath);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function printChildren(path, options, print, events = {}) {
|
||||
const { postprocessor } = events;
|
||||
const processor = events.processor || ((childPath) => childPath.call(print));
|
||||
const processor = events.processor || ((childPath) => print(childPath));
|
||||
|
||||
const node = path.getValue();
|
||||
const parts = [];
|
||||
|
||||
Reference in new issue
Block a user