Remove Parens from SequenceExpressions in ForStatements (#1597)
* Remove Parens from SequenceExpressions in ForStatements Closes #1594 * Add Braces around Assignment Casemaster
parent
54ad598acc
commit
2fc6024a20
|
@ -448,7 +448,9 @@ FPp.needsParens = function() {
|
||||||
parent.object === node
|
parent.object === node
|
||||||
);
|
);
|
||||||
|
|
||||||
case "AssignmentExpression":
|
case "AssignmentExpression": {
|
||||||
|
const grandParent = this.getParentNode(1)
|
||||||
|
|
||||||
if (parent.type === "ArrowFunctionExpression" && parent.body === node) {
|
if (parent.type === "ArrowFunctionExpression" && parent.body === node) {
|
||||||
return true;
|
return true;
|
||||||
} else if (
|
} else if (
|
||||||
|
@ -468,9 +470,16 @@ FPp.needsParens = function() {
|
||||||
return node.left.type === "ObjectPattern";
|
return node.left.type === "ObjectPattern";
|
||||||
} else if (parent.type === "AssignmentExpression") {
|
} else if (parent.type === "AssignmentExpression") {
|
||||||
return false;
|
return false;
|
||||||
|
} else if (
|
||||||
|
parent.type === "SequenceExpression" &&
|
||||||
|
grandParent &&
|
||||||
|
grandParent.type === "ForStatement" &&
|
||||||
|
(grandParent.init === parent || grandParent.update === parent)
|
||||||
|
) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
case "ConditionalExpression":
|
case "ConditionalExpression":
|
||||||
switch (parent.type) {
|
switch (parent.type) {
|
||||||
case "TaggedTemplateExpression":
|
case "TaggedTemplateExpression":
|
||||||
|
|
|
@ -20,3 +20,22 @@ computedDescriptionLines =
|
||||||
(focused && !loading && descriptionLinesFocused) || descriptionLines;
|
(focused && !loading && descriptionLinesFocused) || descriptionLines;
|
||||||
|
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`sequence.js 1`] = `
|
||||||
|
for ((i = 0), (len = arr.length); i < len; i++) {
|
||||||
|
console.log(arr[i])
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0, len = arr.length; i < len; i++) {
|
||||||
|
console.log(arr[i])
|
||||||
|
}
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
for (i = 0, len = arr.length; i < len; i++) {
|
||||||
|
console.log(arr[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0, len = arr.length; i < len; i++) {
|
||||||
|
console.log(arr[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
`;
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
for ((i = 0), (len = arr.length); i < len; i++) {
|
||||||
|
console.log(arr[i])
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0, len = arr.length; i < len; i++) {
|
||||||
|
console.log(arr[i])
|
||||||
|
}
|
Loading…
Reference in New Issue