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;
|
parent.object === node;
|
||||||
|
|
||||||
case "AssignmentExpression":
|
case "AssignmentExpression":
|
||||||
|
if (parent.type === "ArrowFunctionExpression" &&
|
||||||
|
parent.body === node &&
|
||||||
|
node.left.type === "ObjectPattern") {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
case "ConditionalExpression":
|
case "ConditionalExpression":
|
||||||
switch (parent.type) {
|
switch (parent.type) {
|
||||||
case "TaggedTemplateExpression":
|
case "TaggedTemplateExpression":
|
||||||
|
|||||||
@@ -64,6 +64,8 @@ exports[`test arrows.js 1`] = `
|
|||||||
return images.find(image => image.width >= maxPixelWidth) ||
|
return images.find(image => image.width >= maxPixelWidth) ||
|
||||||
images[images.length - 1];
|
images[images.length - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
a = () => ({} = this);
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
function selectBestEffortImageForWidth(
|
function selectBestEffortImageForWidth(
|
||||||
maxWidth: number,
|
maxWidth: number,
|
||||||
@@ -75,6 +77,8 @@ function selectBestEffortImageForWidth(
|
|||||||
return images.find(image => image.width >= maxPixelWidth) ||
|
return images.find(image => image.width >= maxPixelWidth) ||
|
||||||
images[images.length - 1];
|
images[images.length - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
a = () => ({} = this);
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
|||||||
@@ -8,3 +8,5 @@ function selectBestEffortImageForWidth(
|
|||||||
return images.find(image => image.width >= maxPixelWidth) ||
|
return images.find(image => image.width >= maxPixelWidth) ||
|
||||||
images[images.length - 1];
|
images[images.length - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
a = () => ({} = this);
|
||||||
Reference in new issue
Block a user