{"action":"created","issue":{"url":"https://api.github.com/repos/eslint/eslint/issues/5601","repository_url":"https://api.github.com/repos/eslint/eslint","labels_url":"https://api.github.com/repos/eslint/eslint/issues/5601/labels{/name}","comments_url":"https://api.github.com/repos/eslint/eslint/issues/5601/comments","events_url":"https://api.github.com/repos/eslint/eslint/issues/5601/events","html_url":"https://github.com/eslint/eslint/issues/5601","id":141646599,"number":5601,"title":"[no-unreachable] switch statement","user":{"login":"galambalazs","id":309987,"avatar_url":"https://avatars.githubusercontent.com/u/309987?v=3","gravatar_id":"","url":"https://api.github.com/users/galambalazs","html_url":"https://github.com/galambalazs","followers_url":"https://api.github.com/users/galambalazs/followers","following_url":"https://api.github.com/users/galambalazs/following{/other_user}","gists_url":"https://api.github.com/users/galambalazs/gists{/gist_id}","starred_url":"https://api.github.com/users/galambalazs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/galambalazs/subscriptions","organizations_url":"https://api.github.com/users/galambalazs/orgs","repos_url":"https://api.github.com/users/galambalazs/repos","events_url":"https://api.github.com/users/galambalazs/events{/privacy}","received_events_url":"https://api.github.com/users/galambalazs/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":"closed","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2016-03-17T17:11:42Z","updated_at":"2016-03-21T03:54:58Z","closed_at":"2016-03-20T21:55:58Z","body":"When `break` is used consistently to avoid programmer errors in the future, eslint will warn about having `return` & `break` (the `break` being unreachable).\r\n\r\nI think this is similar to the (redundant) trailing commas where they are *preventing future errors* so this should be allowed:\r\n\r\n```js\r\nswitch (cond) {\r\n  case 'one':\r\n    if (cond1) \r\n      return 'denied';\r\n    else \r\n      return 'good'\r\n  break; // <--- this will trigger the warning of unreachable code\r\n  case 'two':\r\n    simple code..\r\n    just statements..\r\n  break;\r\n  default: \r\n    return 'unexpected';\r\n}\r\n```\r\n\r\n(note: it may also be a stylistic/formatting preference that all cases have break pairs)"},"comment":{"url":"https://api.github.com/repos/eslint/eslint/issues/comments/199102451","html_url":"https://github.com/eslint/eslint/issues/5601#issuecomment-199102451","issue_url":"https://api.github.com/repos/eslint/eslint/issues/5601","id":199102451,"user":{"login":"ilyavolodin","id":1380062,"avatar_url":"https://avatars.githubusercontent.com/u/1380062?v=3","gravatar_id":"","url":"https://api.github.com/users/ilyavolodin","html_url":"https://github.com/ilyavolodin","followers_url":"https://api.github.com/users/ilyavolodin/followers","following_url":"https://api.github.com/users/ilyavolodin/following{/other_user}","gists_url":"https://api.github.com/users/ilyavolodin/gists{/gist_id}","starred_url":"https://api.github.com/users/ilyavolodin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ilyavolodin/subscriptions","organizations_url":"https://api.github.com/users/ilyavolodin/orgs","repos_url":"https://api.github.com/users/ilyavolodin/repos","events_url":"https://api.github.com/users/ilyavolodin/events{/privacy}","received_events_url":"https://api.github.com/users/ilyavolodin/received_events","type":"User","site_admin":false},"created_at":"2016-03-21T03:54:58Z","updated_at":"2016-03-21T03:54:58Z","body":"> This may work as you guys intended, but then your intentions simply don't cover all the cases. :)\r\n\r\nWe never intended to cover all the cases. That's simply not possible. You use-case seems to be an edge case. I understand that's your preferred style, but I haven't seen this pattern used widely and I'm not sure I understand why you would want to do that. If you can point us to a popular style-guide or very popular library using this patter, we would be happy to revisit this discussion. If not - you always have an option of creating a plugin that would flag/not flag exactly the cases that you prefer."}}