{"action":"opened","issue":{"url":"https://api.github.com/repos/Shopify/javascript/issues/156","repository_url":"https://api.github.com/repos/Shopify/javascript","labels_url":"https://api.github.com/repos/Shopify/javascript/issues/156/labels{/name}","comments_url":"https://api.github.com/repos/Shopify/javascript/issues/156/comments","events_url":"https://api.github.com/repos/Shopify/javascript/issues/156/events","html_url":"https://github.com/Shopify/javascript/issues/156","id":158429128,"number":156,"title":"Improve `switch`es with complex conditions","user":{"login":"GoodForOneFare","id":673655,"avatar_url":"https://avatars.githubusercontent.com/u/673655?v=3","gravatar_id":"","url":"https://api.github.com/users/GoodForOneFare","html_url":"https://github.com/GoodForOneFare","followers_url":"https://api.github.com/users/GoodForOneFare/followers","following_url":"https://api.github.com/users/GoodForOneFare/following{/other_user}","gists_url":"https://api.github.com/users/GoodForOneFare/gists{/gist_id}","starred_url":"https://api.github.com/users/GoodForOneFare/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoodForOneFare/subscriptions","organizations_url":"https://api.github.com/users/GoodForOneFare/orgs","repos_url":"https://api.github.com/users/GoodForOneFare/repos","events_url":"https://api.github.com/users/GoodForOneFare/events{/privacy}","received_events_url":"https://api.github.com/users/GoodForOneFare/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Shopify/javascript/labels/decaf","name":"decaf","color":"1d76db"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-06-03T18:41:58Z","updated_at":"2016-06-03T18:41:58Z","closed_at":null,"body":"If a switch does something more than an equality check, it generates a `switch (false)` that tends towards incomprehensible:\r\n\r\n`ChangeThemeLanguageModal` is the worst offender because it negates the original comparison _then negates the result_ (I've verified that js2.coffee generates a slightly saner result).\r\n```js\r\n  newKey() {\r\n    switch (false) {\r\n    case !(this.languageSelect !== 'custom'):\r\n      return this.languageSelect;\r\n    case !(this.regionSelect === 'all'):\r\n      return this.customLanguageSelect;\r\n    case !(this.regionSelect === 'custom' && !this.region):\r\n      return this.customLanguageSelect;\r\n    case !(this.regionSelect !== 'custom'):\r\n      return this.regionSelect;\r\n    default:\r\n      return `${this.customLanguageSelect}-${this.region}`;\r\n    }\r\n```\r\n\r\nAlso affected: `OfferFunnel`, `ChannelDashboards`, `settings/Image`, `ImagePicker`.\r\n"}}
{"actor":{"display_login":"GoodForOneFare"}}