{"action":"created","issue":{"url":"https://api.github.com/repos/jscs-dev/node-jscs/issues/516","labels_url":"https://api.github.com/repos/jscs-dev/node-jscs/issues/516/labels{/name}","comments_url":"https://api.github.com/repos/jscs-dev/node-jscs/issues/516/comments","events_url":"https://api.github.com/repos/jscs-dev/node-jscs/issues/516/events","html_url":"https://github.com/jscs-dev/node-jscs/issues/516","id":37358131,"number":516,"title":"Auto formatting API and option. [$300]","user":{"login":"mikesherov","id":364532,"avatar_url":"https://avatars.githubusercontent.com/u/364532?v=3","gravatar_id":"","url":"https://api.github.com/users/mikesherov","html_url":"https://github.com/mikesherov","followers_url":"https://api.github.com/users/mikesherov/followers","following_url":"https://api.github.com/users/mikesherov/following{/other_user}","gists_url":"https://api.github.com/users/mikesherov/gists{/gist_id}","starred_url":"https://api.github.com/users/mikesherov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mikesherov/subscriptions","organizations_url":"https://api.github.com/users/mikesherov/orgs","repos_url":"https://api.github.com/users/mikesherov/repos","events_url":"https://api.github.com/users/mikesherov/events{/privacy}","received_events_url":"https://api.github.com/users/mikesherov/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/jscs-dev/node-jscs/labels/bounty","name":"bounty","color":"129e5e"},{"url":"https://api.github.com/repos/jscs-dev/node-jscs/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":{"login":"mikesherov","id":364532,"avatar_url":"https://avatars.githubusercontent.com/u/364532?v=3","gravatar_id":"","url":"https://api.github.com/users/mikesherov","html_url":"https://github.com/mikesherov","followers_url":"https://api.github.com/users/mikesherov/followers","following_url":"https://api.github.com/users/mikesherov/following{/other_user}","gists_url":"https://api.github.com/users/mikesherov/gists{/gist_id}","starred_url":"https://api.github.com/users/mikesherov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mikesherov/subscriptions","organizations_url":"https://api.github.com/users/mikesherov/orgs","repos_url":"https://api.github.com/users/mikesherov/repos","events_url":"https://api.github.com/users/mikesherov/events{/privacy}","received_events_url":"https://api.github.com/users/mikesherov/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/jscs-dev/node-jscs/milestones/8","html_url":"https://github.com/jscs-dev/node-jscs/milestones/1.later","labels_url":"https://api.github.com/repos/jscs-dev/node-jscs/milestones/8/labels","id":884292,"number":8,"title":"1.later","description":"Not a priority.","creator":{"login":"mikesherov","id":364532,"avatar_url":"https://avatars.githubusercontent.com/u/364532?v=3","gravatar_id":"","url":"https://api.github.com/users/mikesherov","html_url":"https://github.com/mikesherov","followers_url":"https://api.github.com/users/mikesherov/followers","following_url":"https://api.github.com/users/mikesherov/following{/other_user}","gists_url":"https://api.github.com/users/mikesherov/gists{/gist_id}","starred_url":"https://api.github.com/users/mikesherov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mikesherov/subscriptions","organizations_url":"https://api.github.com/users/mikesherov/orgs","repos_url":"https://api.github.com/users/mikesherov/repos","events_url":"https://api.github.com/users/mikesherov/events{/privacy}","received_events_url":"https://api.github.com/users/mikesherov/received_events","type":"User","site_admin":false},"open_issues":20,"closed_issues":11,"state":"open","created_at":"2014-11-29T15:41:40Z","updated_at":"2015-02-22T18:45:58Z","due_on":null,"closed_at":null},"comments":50,"created_at":"2014-07-08T10:39:51Z","updated_at":"2015-02-25T05:43:19Z","closed_at":null,"body":"JSCS should have the ability to automatically format a given file with the specified rules. There are several challenges here:\r\n\r\nFor now, we are only going to consider whitespace changes. This approach is outlined here:\r\n\r\n1. Change all rules to use the JsFile traversal methods instead of directly referencing the token by index directly. This allows us to change the underlying token data structure at will while only having to change the traversal methods.\r\n2. Make all whitespace only rules use the token-assert framework.\r\n3. Modify the token list so that it includes comment tokens, and a new terminal token called \"EOF\".\r\n3a. Modify traversal methods to ignore comment tokens as necessary.\r\n4. Modify comment tokens to include a property called \"prefix\", which contains the preceding whitespace.\r\n5. Add a function called errors.fixToken (or some other name), which takes in a token, and the updated prefix whitespace, which modifies the prefix of that token.\r\n6. Make token-assert call errors.fixToken appropriately.\r\n7. Modify StringChecker so that it can output the modifed source and save it to disk. It's simply a loop over the token list, printing the prefix followed by the value of the token.\r\n8. Modify CLI to respect a `--fix` parameter, which triggers the autoformat option.\r\n\r\nPlease see https://github.com/mdevils/node-jscs/pull/514 as one possible implementation that ultimately wasn't how we wanted to approach the problem. \r\n\r\n<bountysource-plugin>\r\n---\r\nThere is a **[$300 open bounty](https://www.bountysource.com/issues/3017703-auto-formatting-api-and-option-300?utm_campaign=plugin&utm_content=tracker%2F281640&utm_medium=issues&utm_source=github)** on this issue. Add to the bounty at [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F281640&utm_medium=issues&utm_source=github).\r\n</bountysource-plugin>"},"comment":{"url":"https://api.github.com/repos/jscs-dev/node-jscs/issues/comments/75908848","html_url":"https://github.com/jscs-dev/node-jscs/issues/516#issuecomment-75908848","issue_url":"https://api.github.com/repos/jscs-dev/node-jscs/issues/516","id":75908848,"user":{"login":"TheSavior","id":249164,"avatar_url":"https://avatars.githubusercontent.com/u/249164?v=3","gravatar_id":"","url":"https://api.github.com/users/TheSavior","html_url":"https://github.com/TheSavior","followers_url":"https://api.github.com/users/TheSavior/followers","following_url":"https://api.github.com/users/TheSavior/following{/other_user}","gists_url":"https://api.github.com/users/TheSavior/gists{/gist_id}","starred_url":"https://api.github.com/users/TheSavior/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TheSavior/subscriptions","organizations_url":"https://api.github.com/users/TheSavior/orgs","repos_url":"https://api.github.com/users/TheSavior/repos","events_url":"https://api.github.com/users/TheSavior/events{/privacy}","received_events_url":"https://api.github.com/users/TheSavior/received_events","type":"User","site_admin":false},"created_at":"2015-02-25T05:43:19Z","updated_at":"2015-02-25T05:43:19Z","body":"@millermedeiros Not to speak for the rest of the team, but I really appreciate you coming to provide us this context. Having built esformatter, you definitely have some specific understanding that we may not have.\r\n\r\nThe assertions we use and having that add whitespaceBefore, as you say, seems pretty consistent with how you have things outlined in the file you linked.\r\n\r\nSomething I didn't quite get from your document explaining how esformatter tokenizes and how you guys transform, are specific examples.\r\n\r\nI'd love to get some more understanding and specific examples that you've run into issues with once we try to tackle indentation. I don't believe we have taken any steps in that direction yet."}}