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

This commit is contained in:
Lucas Duailibe authored and GitHub committed 2018-10-08 19:28:58 -03:00
1 parent ce952fc8c1
commit b5fd382fe8
5 files changed
+65 -38

No files matched your search

+1
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)))
);
}
@@ -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"
);
`;
+2
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");
+7 -3
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"
});
@@ -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
)
);