code: function ObjectExpression(node, parent) {
    if (t.isExpressionStatement(parent)) {
      // ({ foo: "bar" });
      return true;
    }
  
    if (t.isMemberExpression(parent) && parent.object === node) {
      // ({ foo: "bar" }).foo
      return true;
    }
  
    return false;
  }
docs: Test if ObjectExpression needs parentheses.