{"action":"opened","issue":{"url":"https://api.github.com/repos/babel/babel/issues/1955","labels_url":"https://api.github.com/repos/babel/babel/issues/1955/labels{/name}","comments_url":"https://api.github.com/repos/babel/babel/issues/1955/comments","events_url":"https://api.github.com/repos/babel/babel/issues/1955/events","html_url":"https://github.com/babel/babel/issues/1955","id":93913812,"number":1955,"title":"Automatically adding some decorator(s) to React.createClass","user":{"login":"timbur","id":7020411,"avatar_url":"https://avatars.githubusercontent.com/u/7020411?v=3","gravatar_id":"","url":"https://api.github.com/users/timbur","html_url":"https://github.com/timbur","followers_url":"https://api.github.com/users/timbur/followers","following_url":"https://api.github.com/users/timbur/following{/other_user}","gists_url":"https://api.github.com/users/timbur/gists{/gist_id}","starred_url":"https://api.github.com/users/timbur/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timbur/subscriptions","organizations_url":"https://api.github.com/users/timbur/orgs","repos_url":"https://api.github.com/users/timbur/repos","events_url":"https://api.github.com/users/timbur/events{/privacy}","received_events_url":"https://api.github.com/users/timbur/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-07-08T23:37:13Z","updated_at":"2015-07-08T23:37:13Z","closed_at":null,"body":"I'm an AST noob so I'm hoping maybe @sebmck or someone would be so kind as to help me out here.  Originally, to simulate a decorator, I was using something like this:\r\n```js\r\nfunction transform (babel) {\r\n  var t = babel.types;\r\n\r\n  return new babel.Transformer(pluginPath, {\r\n    CallExpression: function (node, parent, scope, file) {\r\n      var callee = this.get('callee');\r\n      if (!callee.matchesPattern('React.createClass')) {\r\n        return;\r\n      }\r\n\r\n      callee.getStatementParent().insertAfter(\r\n        t.assignmentExpression(\r\n          '=',\r\n          t.identifier(parent.id.name),\r\n          t.callExpression(\r\n            someDecorator,\r\n            [t.identifier(parent.id.name)]\r\n          )\r\n        )\r\n      );\r\n    }\r\n  });\r\n}\r\n```\r\n\r\nBut as you might imagine, that doesn't work for stuff like this:\r\n```js\r\nexport default React.createClass({...});\r\n```\r\n\r\nI'm aware of `node.decorators.push(t.decorator(...))`, but I can't figure out how to make this work for variations of `export default React.createClass({...})` and `const SomeComponent = React.createClass({...})`."}}