Add parenthesis around assignment for arrow function body (#422)

Fixes #412
This commit is contained in:
Christopher Chedeau authored and GitHub committed 2017-01-22 19:04:00 -08:00
1 parent d57d8450dc
commit 2acc3e5ea6
3 files changed
+12

No files matched your search

+6
View File
@@ -376,6 +376,12 @@ FPp.needsParens = function(assumeExpressionContext) {
parent.object === node;
case "AssignmentExpression":
if (parent.type === "ArrowFunctionExpression" &&
parent.body === node &&
node.left.type === "ObjectPattern") {
return true;
}
case "ConditionalExpression":
switch (parent.type) {
case "TaggedTemplateExpression":
@@ -64,6 +64,8 @@ exports[`test arrows.js 1`] = `
return images.find(image => image.width >= maxPixelWidth) ||
images[images.length - 1];
}
a = () => ({} = this);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function selectBestEffortImageForWidth(
maxWidth: number,
@@ -75,6 +77,8 @@ function selectBestEffortImageForWidth(
return images.find(image => image.width >= maxPixelWidth) ||
images[images.length - 1];
}
a = () => ({} = this);
"
`;
+2
View File
@@ -8,3 +8,5 @@ function selectBestEffortImageForWidth(
return images.find(image => image.width >= maxPixelWidth) ||
images[images.length - 1];
}
a = () => ({} = this);