Add parenthesis around assignment for arrow function body (#422)
Fixes #412
This commit is contained in:
1 parent
d57d8450dc
commit
2acc3e5ea6
3 files changed
+12
No files matched your search
@@ -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);
|
||||
"
|
||||
`;
|
||||
|
||||
|
||||
@@ -8,3 +8,5 @@ function selectBestEffortImageForWidth(
|
||||
return images.find(image => image.width >= maxPixelWidth) ||
|
||||
images[images.length - 1];
|
||||
}
|
||||
|
||||
a = () => ({} = this);
|
||||
Reference in new issue
Block a user