{"action":"created","issue":{"url":"https://api.github.com/repos/eslint/eslint/issues/5438","repository_url":"https://api.github.com/repos/eslint/eslint","labels_url":"https://api.github.com/repos/eslint/eslint/issues/5438/labels{/name}","comments_url":"https://api.github.com/repos/eslint/eslint/issues/5438/comments","events_url":"https://api.github.com/repos/eslint/eslint/issues/5438/events","html_url":"https://github.com/eslint/eslint/issues/5438","id":137375997,"number":5438,"title":"Proposal addition to object-shorthand: add consistent and consistent-as-needed","user":{"login":"martijndeh","id":178230,"avatar_url":"https://avatars.githubusercontent.com/u/178230?v=3","gravatar_id":"","url":"https://api.github.com/users/martijndeh","html_url":"https://github.com/martijndeh","followers_url":"https://api.github.com/users/martijndeh/followers","following_url":"https://api.github.com/users/martijndeh/following{/other_user}","gists_url":"https://api.github.com/users/martijndeh/gists{/gist_id}","starred_url":"https://api.github.com/users/martijndeh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/martijndeh/subscriptions","organizations_url":"https://api.github.com/users/martijndeh/orgs","repos_url":"https://api.github.com/users/martijndeh/repos","events_url":"https://api.github.com/users/martijndeh/events{/privacy}","received_events_url":"https://api.github.com/users/martijndeh/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/eslint/eslint/labels/enhancement","name":"enhancement","color":"84b6eb"},{"url":"https://api.github.com/repos/eslint/eslint/labels/evaluating","name":"evaluating","color":"fef2c0"},{"url":"https://api.github.com/repos/eslint/eslint/labels/rule","name":"rule","color":"fbca04"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":18,"created_at":"2016-02-29T21:08:36Z","updated_at":"2016-05-26T03:29:53Z","closed_at":null,"body":"**When does this rule warn? Please describe and show example code:**\r\nSimilar to the `quote-props` rule, where it's possible to set the rule to `consistent` and `consistent-as-needed`, I'd like the `object-shorthand` rule to include these options as well.\r\n\r\nWhen `object-shorthand` set to `consistent`, the below should not be considered a problem:\r\n```js\r\nlet obj1 = {\r\n    foo: foo,\r\n    bar: 'This is a string',\r\n};\r\n```\r\nNo problem:\r\n```js\r\nlet obj2 = {\r\n    foo,\r\n    bar,\r\n};\r\n```\r\n\r\nThe following should be considered a problem:\r\n```js\r\nlet obj1 = {\r\n    foo,\r\n    bar: 'This is a string',\r\n};\r\n```\r\n\r\nProblem:\r\n```js\r\nlet obj2 = {\r\n    a() {},\r\n    bar: foo,\r\n};\r\n```\r\n\r\nThe `consistent-as-needed` is very similar, but if all keys are redundant, the following pattern is considered a problem:\r\n```js\r\nlet obj3 = {\r\n    foo: foo,\r\n    bar: bar,\r\n};\r\n```\r\n\r\nThe options apply to both properties and methods.\r\n\r\n**Is this rule preventing an error or is it stylistic?**\r\nStylistic. Personally, I feel the shorthand syntax is great, but mixing it with the longform syntax makes it harder to scan/read code. In my rules, I want to allow the shorthand syntax, but only if it's consistent in that object literal.\r\n\r\n**Why is this rule a candidate for inclusion instead of creating a custom rule?**\r\nI think this is in line with other rules which also provide consistent and consistent-as-needed options (e.g. `quote-props`).\r\n\r\n**Are you willing to create the rule yourself?**\r\nYes."},"comment":{"url":"https://api.github.com/repos/eslint/eslint/issues/comments/221768737","html_url":"https://github.com/eslint/eslint/issues/5438#issuecomment-221768737","issue_url":"https://api.github.com/repos/eslint/eslint/issues/5438","id":221768737,"user":{"login":"mysticatea","id":1937871,"avatar_url":"https://avatars.githubusercontent.com/u/1937871?v=3","gravatar_id":"","url":"https://api.github.com/users/mysticatea","html_url":"https://github.com/mysticatea","followers_url":"https://api.github.com/users/mysticatea/followers","following_url":"https://api.github.com/users/mysticatea/following{/other_user}","gists_url":"https://api.github.com/users/mysticatea/gists{/gist_id}","starred_url":"https://api.github.com/users/mysticatea/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mysticatea/subscriptions","organizations_url":"https://api.github.com/users/mysticatea/orgs","repos_url":"https://api.github.com/users/mysticatea/repos","events_url":"https://api.github.com/users/mysticatea/events{/privacy}","received_events_url":"https://api.github.com/users/mysticatea/received_events","type":"User","site_admin":false},"created_at":"2016-05-26T03:29:53Z","updated_at":"2016-05-26T03:29:53Z","body":"Sounds good to me :+1: "}}
{"actor":{"display_login":"mysticatea"}}