{"action":"closed","issue":{"url":"https://api.github.com/repos/eslint/eslint/issues/2017","labels_url":"https://api.github.com/repos/eslint/eslint/issues/2017/labels{/name}","comments_url":"https://api.github.com/repos/eslint/eslint/issues/2017/comments","events_url":"https://api.github.com/repos/eslint/eslint/issues/2017/events","html_url":"https://github.com/eslint/eslint/issues/2017","id":61019733,"number":2017,"title":"Rule to sort properties in object literal","user":{"login":"jacobrask","id":58563,"avatar_url":"https://avatars.githubusercontent.com/u/58563?v=3","gravatar_id":"","url":"https://api.github.com/users/jacobrask","html_url":"https://github.com/jacobrask","followers_url":"https://api.github.com/users/jacobrask/followers","following_url":"https://api.github.com/users/jacobrask/following{/other_user}","gists_url":"https://api.github.com/users/jacobrask/gists{/gist_id}","starred_url":"https://api.github.com/users/jacobrask/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacobrask/subscriptions","organizations_url":"https://api.github.com/users/jacobrask/orgs","repos_url":"https://api.github.com/users/jacobrask/repos","events_url":"https://api.github.com/users/jacobrask/events{/privacy}","received_events_url":"https://api.github.com/users/jacobrask/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/eslint/eslint/labels/question","name":"question","color":"cc317c"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-03-13T09:16:33Z","updated_at":"2015-03-13T20:56:19Z","closed_at":"2015-03-13T20:56:19Z","body":"Similar to `sort-vars`, how about a rule to always sort object properties alphabetically when defining an object literal?\r\n\r\nIt would be really useful for things like options objects. I realize that the property order can matter in iteration, but it's nothing you should rely on anyway. With the new ES6 data structures, I think the use case for object literals is shrinking to be a lot about options objects, including in native APIs.\r\n\r\nYou could argue that it will cause a huge number of warnings in existing code and thus not be useful at all. I'm not completely sure, I just know that I often use vim's `sort` command, but it doesn't work well if a property value spans several lines.\r\n\r\nWarnings:\r\n\r\n    var obj = {\r\n      c: \"foo\",\r\n      a: \"bar\",\r\n      b: {\r\n        e: 1,\r\n        d: 2,\r\n      }\r\n    };\r\n\r\nOK:\r\n\r\n    var obj = {\r\n      a: \"bar\",\r\n      b: {\r\n        d: 2,\r\n        e: 1,\r\n      },\r\n      c: \"foo\",\r\n    };\r\n\r\n\r\n<bountysource-plugin>\r\n---\r\nWant to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/9512120-rule-to-sort-properties-in-object-literal?utm_campaign=plugin&utm_content=tracker%2F282608&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F282608&utm_medium=issues&utm_source=github).\r\n</bountysource-plugin>"}}