UpdateExpressions as callees must be parenthesized (#6922)

This commit is contained in:
Nicolò Ribaudo 2017-11-27 23:31:24 +01:00 committed by GitHub
parent 58962c35b5
commit 18c8d97c3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 2 deletions

View File

@ -38,9 +38,13 @@ export function NullableTypeAnnotation(node: Object, parent: Object): boolean {
export { NullableTypeAnnotation as FunctionTypeAnnotation }; export { NullableTypeAnnotation as FunctionTypeAnnotation };
export function UpdateExpression(node: Object, parent: Object): boolean { export function UpdateExpression(node: Object, parent: Object): boolean {
// (foo++).test()
return ( return (
(t.isMemberExpression(parent) && parent.object === node) || // (foo++).test(), (foo++)[0]
t.isMemberExpression(parent, { object: node }) ||
// (foo++)()
t.isCallExpression(parent, { callee: node }) ||
// new (foo++)()
t.isNewExpression(parent, { callee: node }) ||
isClassExtendsClause(node, parent) isClassExtendsClause(node, parent)
); );
} }

View File

@ -0,0 +1,8 @@
(++a)();
(a++)();
new (++a)();
new (a++)();
new (++a);
new (a++);

View File

@ -0,0 +1,6 @@
(++a)();
(a++)();
new (++a)();
new (a++)();
new (++a)();
new (a++)();