Inline the arguments of an arrow function in the body is conditional expression (#5209)

master
Lucas Duailibe 2018-10-08 19:28:58 -03:00 committed by GitHub
parent ce952fc8c1
commit b5fd382fe8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 65 additions and 38 deletions

View File

@ -3420,6 +3420,7 @@ function couldGroupArg(arg) {
arg.body.type === "ArrayExpression" ||
arg.body.type === "CallExpression" ||
arg.body.type === "OptionalCallExpression" ||
arg.body.type === "ConditionalExpression" ||
isJSXNode(arg.body)))
);
}

View File

@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`arrow_call.js - flow-verify 1`] = `
exports[`arrow_call.js - babylon-verify 1`] = `
const testResults = results.testResults.map(testResult =>
formatResult(testResult, formatter, reporter)
);
@ -43,6 +43,8 @@ const composition = (ViewComponent, ContainerComponent) =>
class extends React.Component {
static propTypes = {};
};
promise.then(result => result.veryLongVariable.veryLongPropertyName > someOtherVariable ? "ok" : "fail");
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
const testResults = results.testResults.map(testResult =>
formatResult(testResult, formatter, reporter)
@ -93,9 +95,15 @@ const composition = (ViewComponent, ContainerComponent) =>
static propTypes = {};
};
promise.then(result =>
result.veryLongVariable.veryLongPropertyName > someOtherVariable
? "ok"
: "fail"
);
`;
exports[`arrow_call.js - flow-verify 2`] = `
exports[`arrow_call.js - babylon-verify 2`] = `
const testResults = results.testResults.map(testResult =>
formatResult(testResult, formatter, reporter)
);
@ -138,6 +146,8 @@ const composition = (ViewComponent, ContainerComponent) =>
class extends React.Component {
static propTypes = {};
};
promise.then(result => result.veryLongVariable.veryLongPropertyName > someOtherVariable ? "ok" : "fail");
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
const testResults = results.testResults.map(testResult =>
formatResult(testResult, formatter, reporter),
@ -188,9 +198,15 @@ const composition = (ViewComponent, ContainerComponent) =>
static propTypes = {};
};
promise.then(result =>
result.veryLongVariable.veryLongPropertyName > someOtherVariable
? "ok"
: "fail",
);
`;
exports[`arrow_call.js - flow-verify 3`] = `
exports[`arrow_call.js - babylon-verify 3`] = `
const testResults = results.testResults.map(testResult =>
formatResult(testResult, formatter, reporter)
);
@ -233,6 +249,8 @@ const composition = (ViewComponent, ContainerComponent) =>
class extends React.Component {
static propTypes = {};
};
promise.then(result => result.veryLongVariable.veryLongPropertyName > someOtherVariable ? "ok" : "fail");
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
const testResults = results.testResults.map((testResult) =>
formatResult(testResult, formatter, reporter)
@ -283,4 +301,10 @@ const composition = (ViewComponent, ContainerComponent) =>
static propTypes = {};
};
promise.then((result) =>
result.veryLongVariable.veryLongPropertyName > someOtherVariable
? "ok"
: "fail"
);
`;

View File

@ -40,3 +40,5 @@ const composition = (ViewComponent, ContainerComponent) =>
class extends React.Component {
static propTypes = {};
};
promise.then(result => result.veryLongVariable.veryLongPropertyName > someOtherVariable ? "ok" : "fail");

View File

@ -1,3 +1,7 @@
run_spec(__dirname, ["flow", "typescript"]);
run_spec(__dirname, ["flow", "typescript"], { trailingComma: "all" });
run_spec(__dirname, ["flow", "typescript"], { arrowParens: "always" });
run_spec(__dirname, ["babylon", "flow", "typescript"]);
run_spec(__dirname, ["babylon", "flow", "typescript"], {
trailingComma: "all"
});
run_spec(__dirname, ["babylon", "flow", "typescript"], {
arrowParens: "always"
});

View File

@ -22,14 +22,13 @@ const funnelSnapshotCard =
) : null;
room = room.map((row, rowIndex) =>
row.map(
(col, colIndex) =>
rowIndex === 0 ||
colIndex === 0 ||
rowIndex === height ||
colIndex === width
? 1
: 0
row.map((col, colIndex) =>
rowIndex === 0 ||
colIndex === 0 ||
rowIndex === height ||
colIndex === width
? 1
: 0
)
);
@ -57,14 +56,13 @@ const funnelSnapshotCard =
) : null;
room = room.map((row, rowIndex) =>
row.map(
(col, colIndex) =>
rowIndex === 0 ||
colIndex === 0 ||
rowIndex === height ||
colIndex === width
? 1
: 0
row.map((col, colIndex) =>
rowIndex === 0 ||
colIndex === 0 ||
rowIndex === height ||
colIndex === width
? 1
: 0
)
);
@ -92,14 +90,13 @@ const funnelSnapshotCard =
) : null;
room = room.map((row, rowIndex) =>
row.map(
(col, colIndex) =>
rowIndex === 0 ||
colIndex === 0 ||
rowIndex === height ||
colIndex === width
? 1
: 0
row.map((col, colIndex) =>
rowIndex === 0 ||
colIndex === 0 ||
rowIndex === height ||
colIndex === width
? 1
: 0
)
);
@ -127,14 +124,13 @@ const funnelSnapshotCard =
) : null;
room = room.map((row, rowIndex) =>
row.map(
(col, colIndex) =>
rowIndex === 0 ||
colIndex === 0 ||
rowIndex === height ||
colIndex === width
? 1
: 0
row.map((col, colIndex) =>
rowIndex === 0 ||
colIndex === 0 ||
rowIndex === height ||
colIndex === width
? 1
: 0
)
);