{"action":"created","issue":{"url":"https://api.github.com/repos/millermedeiros/esformatter/issues/242","labels_url":"https://api.github.com/repos/millermedeiros/esformatter/issues/242/labels{/name}","comments_url":"https://api.github.com/repos/millermedeiros/esformatter/issues/242/comments","events_url":"https://api.github.com/repos/millermedeiros/esformatter/issues/242/events","html_url":"https://github.com/millermedeiros/esformatter/issues/242","id":58338273,"number":242,"title":"Use `esprima-fb` in rocambole in order to support React JSX syntax","user":{"login":"royriojas","id":131290,"avatar_url":"https://avatars.githubusercontent.com/u/131290?v=3","gravatar_id":"","url":"https://api.github.com/users/royriojas","html_url":"https://github.com/royriojas","followers_url":"https://api.github.com/users/royriojas/followers","following_url":"https://api.github.com/users/royriojas/following{/other_user}","gists_url":"https://api.github.com/users/royriojas/gists{/gist_id}","starred_url":"https://api.github.com/users/royriojas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/royriojas/subscriptions","organizations_url":"https://api.github.com/users/royriojas/orgs","repos_url":"https://api.github.com/users/royriojas/repos","events_url":"https://api.github.com/users/royriojas/events{/privacy}","received_events_url":"https://api.github.com/users/royriojas/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/millermedeiros/esformatter/labels/enhancement","name":"enhancement","color":"84b6eb"},{"url":"https://api.github.com/repos/millermedeiros/esformatter/labels/feature","name":"feature","color":"d7e102"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-02-20T11:12:50Z","updated_at":"2015-02-23T23:47:39Z","closed_at":null,"body":"Not sure where to report this issue.  I could report it on rocambole, but I would also like esformatter to use a version of rocambole that uses esprima-fb instead of esprima in order to support the `jsx` syntax\r\n\r\nThis is what I ended doing in order to make `esformatter` to tolerate the `jsx` syntax\r\n\r\n```javascript\r\n   // needed for grunt.file.expand\r\n    var grunt = require('grunt');\r\n\r\n    // use it with care, I haven't check if there\r\n    // isn't any side effect from using proxyquire to \r\n    // inject esprima-fb into the esformatter\r\n    // but this type of dependency replacement\r\n    // seems to be very fragile... if rocambole deps change \r\n    // this will certainly break, same is true for esprima-fb\r\n    // use it with care\r\n    var proxyquire = require('proxyquire');\r\n    var rocambole = proxyquire('rocambole', {\r\n      'esprima': require('esprima-fb')\r\n    });\r\n\r\n    var esformatter = proxyquire('esformatter', {\r\n      rocambole: rocambole\r\n    });\r\n\r\n    // path to your esformatter configuration\r\n    var cfg = grunt.file.readJSON('./esformatter.json');\r\n\r\n    // expand the files from the glob\r\n    var files = grunt.file.expand('./frontend-app/reader/js/**/*.jsx');\r\n\r\n    // do the actual formatting\r\n    files.forEach(function (fIn) {\r\n      console.log('formatting', fIn);\r\n      var output = esformatter.format(grunt.file.read(fIn), cfg);\r\n      grunt.file.write(fIn, output);\r\n    });\r\n```\r\n\r\nAs you can see it might be simple a change from `esprima` to `esprima-fb`. Maybe make the parser module a property of esformatter that way it can be injected in a cleaner way\r\n\r\nsomething like\r\n\r\n```javascript\r\nvar esformatter = require('esformatter');\r\nesformatter.setParser(require('esprima-fb')); // if not call use regular esprima.\r\n```\r\nRegards"},"comment":{"url":"https://api.github.com/repos/millermedeiros/esformatter/issues/comments/75663926","html_url":"https://github.com/millermedeiros/esformatter/issues/242#issuecomment-75663926","issue_url":"https://api.github.com/repos/millermedeiros/esformatter/issues/242","id":75663926,"user":{"login":"royriojas","id":131290,"avatar_url":"https://avatars.githubusercontent.com/u/131290?v=3","gravatar_id":"","url":"https://api.github.com/users/royriojas","html_url":"https://github.com/royriojas","followers_url":"https://api.github.com/users/royriojas/followers","following_url":"https://api.github.com/users/royriojas/following{/other_user}","gists_url":"https://api.github.com/users/royriojas/gists{/gist_id}","starred_url":"https://api.github.com/users/royriojas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/royriojas/subscriptions","organizations_url":"https://api.github.com/users/royriojas/orgs","repos_url":"https://api.github.com/users/royriojas/repos","events_url":"https://api.github.com/users/royriojas/events{/privacy}","received_events_url":"https://api.github.com/users/royriojas/received_events","type":"User","site_admin":false},"created_at":"2015-02-23T23:47:39Z","updated_at":"2015-02-23T23:47:39Z","body":"Rocambole tests are passing, will try esformatter with that version. Will\nlet you know\n\nRoy Ronald Riojas Montenegro\n\n\nOn Mon, Feb 23, 2015 at 3:45 PM, Miller Medeiros <notifications@github.com>\nwrote:\n\n> if the esformatter tests passes with esprima-fb maybe we should just keep\n> it as the default and don't worry about the config options.\n>\n> —\n> Reply to this email directly or view it on GitHub\n> <https://github.com/millermedeiros/esformatter/issues/242#issuecomment-75663519>\n> .\n>\n"}}