{"action":"created","issue":{"url":"https://api.github.com/repos/eslint/eslint/issues/5042","labels_url":"https://api.github.com/repos/eslint/eslint/issues/5042/labels{/name}","comments_url":"https://api.github.com/repos/eslint/eslint/issues/5042/comments","events_url":"https://api.github.com/repos/eslint/eslint/issues/5042/events","html_url":"https://github.com/eslint/eslint/issues/5042","id":128345379,"number":5042,"title":"no-empty-label errors on labelled if statement","user":{"login":"Qix-","id":885648,"avatar_url":"https://avatars.githubusercontent.com/u/885648?v=3","gravatar_id":"","url":"https://api.github.com/users/Qix-","html_url":"https://github.com/Qix-","followers_url":"https://api.github.com/users/Qix-/followers","following_url":"https://api.github.com/users/Qix-/following{/other_user}","gists_url":"https://api.github.com/users/Qix-/gists{/gist_id}","starred_url":"https://api.github.com/users/Qix-/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Qix-/subscriptions","organizations_url":"https://api.github.com/users/Qix-/orgs","repos_url":"https://api.github.com/users/Qix-/repos","events_url":"https://api.github.com/users/Qix-/events{/privacy}","received_events_url":"https://api.github.com/users/Qix-/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/eslint/eslint/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/eslint/eslint/labels/proposal","name":"proposal","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":15,"created_at":"2016-01-23T18:45:56Z","updated_at":"2016-01-27T00:29:56Z","closed_at":null,"body":"Labels apply to statements, not loops specifically. This is defined in §12.12 in the [Ecmascript 3](http://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf) and [Ecmascript 5](http://www.ecma-international.org/ecma-262/5.1/#sec-12.12) standards, as well as §13.13 in the [Ecmascript 2015 (6.0) standard](http://www.ecma-international.org/ecma-262/6.0/index.html#sec-labelled-statements).\r\n\r\nGrammar (ES3/5):\r\n```\r\nLabelledStatement :\r\n    Identifier : Statement\r\n```\r\n<sup>ES6 (ES2015) grammar not shown since it spans multiple rules</sup>\r\n\r\nThis means labels also apply to if statements.\r\n\r\n```js\r\nsomeLabel:\r\nif (true) {\r\n\tconsole.log('first');\r\n\tbreak someLabel;\r\n\tconsole.log('second');\r\n}\r\n```\r\n\r\noutputs:\r\n\r\n```console\r\n$ node iflabel.js\r\nfirst\r\n```\r\n\r\nESLint seems to treating labelled if statements as invalid. In fact, it appears other block statements are being considered as invalid as well.\r\n\r\n```js\r\nvar obj = {foo: 'bar', qux: 'qix'};\r\n\r\nsomeLabel:\r\nwith (obj) {\r\n\tconsole.log(qux);\r\n\tbreak someLabel;\r\n\tconsole.log(foo);\r\n}\r\n```\r\n\r\noutputs:\r\n\r\n```console\r\n$ node withlabel.js\r\nqix\r\n```\r\n\r\nand even normal blocks:\r\n\r\n```js\r\nsomeLabel: {\r\n\tconsole.log('first');\r\n\tbreak someLabel;\r\n\tconsole.log('second');\r\n}\r\n```\r\n\r\noutputs:\r\n\r\n```console\r\n$ node blocklabel.js\r\nfirst\r\n````\r\n\r\nHowever, with the following `.eslintrc`\r\n\r\n```json\r\n{\r\n  \"rules\": {\r\n    \"no-empty-label\": 2\r\n  }\r\n}\r\n```\r\n\r\nESLint errors out with:\r\n\r\n```\r\n3:1  error  Unexpected label \"someLabel\"  no-empty-label\r\n```\r\n\r\nWhich is incorrect.\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/30144606-no-empty-label-errors-on-labelled-if-statement?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>"},"comment":{"url":"https://api.github.com/repos/eslint/eslint/issues/comments/175312409","html_url":"https://github.com/eslint/eslint/issues/5042#issuecomment-175312409","issue_url":"https://api.github.com/repos/eslint/eslint/issues/5042","id":175312409,"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-01-27T00:29:55Z","updated_at":"2016-01-27T00:29:55Z","body":"IMO, if this rule's behavior is changed to warn only non-block statements, the rule almost comes to overlap with #5052.\r\nMaybe this is a good timing to rename this rule?"}}