Don't pass too many arguments to functions (#1750)

Found using Flow.
master
Simon Lydell 2017-05-26 22:01:03 +02:00 committed by Christopher Chedeau
parent f9e324c4d0
commit fe48638376
2 changed files with 7 additions and 9 deletions

View File

@ -954,9 +954,7 @@ function printComments(path, print, options, needsSemi) {
leadingParts.push(hardline); leadingParts.push(hardline);
} }
} else if (trailing) { } else if (trailing) {
trailingParts.push( trailingParts.push(printTrailingComment(commentPath, print, options));
printTrailingComment(commentPath, print, options, parent)
);
} }
}, "comments"); }, "comments");

View File

@ -1559,7 +1559,7 @@ function genericPrintNoParens(path, options, print, args) {
() => printJSXElement(path, options, print), () => printJSXElement(path, options, print),
options options
); );
return maybeWrapJSXElementInParens(path, elem, options); return maybeWrapJSXElementInParens(path, elem);
} }
case "JSXOpeningElement": { case "JSXOpeningElement": {
const n = path.getValue(); const n = path.getValue();
@ -1658,7 +1658,7 @@ function genericPrintNoParens(path, options, print, args) {
if (n.static) { if (n.static) {
parts.push("static "); parts.push("static ");
} }
const variance = getFlowVariance(n, options); const variance = getFlowVariance(n);
if (variance) { if (variance) {
parts.push(variance); parts.push(variance);
} }
@ -1870,7 +1870,7 @@ function genericPrintNoParens(path, options, print, args) {
const parentParentParent = path.getParentNode(2); const parentParentParent = path.getParentNode(2);
let isArrowFunctionTypeAnnotation = let isArrowFunctionTypeAnnotation =
n.type === "TSFunctionType" || n.type === "TSFunctionType" ||
!((!getFlowVariance(parent, options) && !((!getFlowVariance(parent) &&
!parent.optional && !parent.optional &&
parent.type === "ObjectTypeProperty") || parent.type === "ObjectTypeProperty") ||
parent.type === "ObjectTypeCallProperty" || parent.type === "ObjectTypeCallProperty" ||
@ -2052,7 +2052,7 @@ function genericPrintNoParens(path, options, print, args) {
return concat(parts); return concat(parts);
case "ObjectTypeIndexer": { case "ObjectTypeIndexer": {
const variance = getFlowVariance(n, options); const variance = getFlowVariance(n);
return concat([ return concat([
variance || "", variance || "",
"[", "[",
@ -2064,7 +2064,7 @@ function genericPrintNoParens(path, options, print, args) {
]); ]);
} }
case "ObjectTypeProperty": { case "ObjectTypeProperty": {
const variance = getFlowVariance(n, options); const variance = getFlowVariance(n);
return concat([ return concat([
n.static ? "static " : "", n.static ? "static " : "",
@ -2135,7 +2135,7 @@ function genericPrintNoParens(path, options, print, args) {
case "TypeParameterInstantiation": case "TypeParameterInstantiation":
return printTypeParameters(path, options, print, "params"); return printTypeParameters(path, options, print, "params");
case "TypeParameter": { case "TypeParameter": {
const variance = getFlowVariance(n, options); const variance = getFlowVariance(n);
if (variance) { if (variance) {
parts.push(variance); parts.push(variance);