{"action":"created","issue":{"url":"https://api.github.com/repos/eslint/eslint/issues/7785","repository_url":"https://api.github.com/repos/eslint/eslint","labels_url":"https://api.github.com/repos/eslint/eslint/issues/7785/labels{/name}","comments_url":"https://api.github.com/repos/eslint/eslint/issues/7785/comments","events_url":"https://api.github.com/repos/eslint/eslint/issues/7785/events","html_url":"https://github.com/eslint/eslint/issues/7785","id":196130414,"number":7785,"title":"Option to permit no-useless-return inside blocks","user":{"login":"felixsanz","id":6182099,"avatar_url":"https://avatars.githubusercontent.com/u/6182099?v=3","gravatar_id":"","url":"https://api.github.com/users/felixsanz","html_url":"https://github.com/felixsanz","followers_url":"https://api.github.com/users/felixsanz/followers","following_url":"https://api.github.com/users/felixsanz/following{/other_user}","gists_url":"https://api.github.com/users/felixsanz/gists{/gist_id}","starred_url":"https://api.github.com/users/felixsanz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/felixsanz/subscriptions","organizations_url":"https://api.github.com/users/felixsanz/orgs","repos_url":"https://api.github.com/users/felixsanz/repos","events_url":"https://api.github.com/users/felixsanz/events{/privacy}","received_events_url":"https://api.github.com/users/felixsanz/received_events","type":"User","site_admin":false},"labels":[{"id":45711352,"url":"https://api.github.com/repos/eslint/eslint/labels/enhancement","name":"enhancement","color":"84b6eb","default":true},{"id":255319420,"url":"https://api.github.com/repos/eslint/eslint/labels/evaluating","name":"evaluating","color":"fef2c0","default":false},{"id":45798639,"url":"https://api.github.com/repos/eslint/eslint/labels/rule","name":"rule","color":"fbca04","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2016-12-16T18:57:10Z","updated_at":"2016-12-16T23:11:04Z","closed_at":null,"body":"As discussed in https://github.com/airbnb/javascript/issues/1210, it will be great if `no-useless-return` offers an option to allow `return` **inside blocks**, to benefit consistency between blocks when using a useless `return` to quit the function execution at that point.\r\n\r\nHere is an example:\r\n\r\n```javascript\r\nasync function f(p) {\r\n  if (p === 'a') {\r\n    // some lines of code\r\n    await fn()\r\n    \r\n    return\r\n  }\r\n  \r\n  if (p === 'b') {\r\n    // some lines of code\r\n    await fn()\r\n    \r\n    return\r\n  }\r\n\r\n  if (p === 'c') {\r\n    // some lines of code\r\n    await fn()\r\n    \r\n    return // <-- option to allow tihs one\r\n  }\r\n}\r\n```\r\n\r\nHaving them separated by blank lines make it clearer and easy to maintain instead of having a big `if-else if-else` block.\r\n\r\nHaving this last useless return **enforces consistency** with other blocks and also, if you add a new block below, you will **not have to modify** the (until now) last one block to add a `return` into it."},"comment":{"url":"https://api.github.com/repos/eslint/eslint/issues/comments/267718478","html_url":"https://github.com/eslint/eslint/issues/7785#issuecomment-267718478","issue_url":"https://api.github.com/repos/eslint/eslint/issues/7785","id":267718478,"user":{"login":"kaicataldo","id":7041728,"avatar_url":"https://avatars.githubusercontent.com/u/7041728?v=3","gravatar_id":"","url":"https://api.github.com/users/kaicataldo","html_url":"https://github.com/kaicataldo","followers_url":"https://api.github.com/users/kaicataldo/followers","following_url":"https://api.github.com/users/kaicataldo/following{/other_user}","gists_url":"https://api.github.com/users/kaicataldo/gists{/gist_id}","starred_url":"https://api.github.com/users/kaicataldo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kaicataldo/subscriptions","organizations_url":"https://api.github.com/users/kaicataldo/orgs","repos_url":"https://api.github.com/users/kaicataldo/repos","events_url":"https://api.github.com/users/kaicataldo/events{/privacy}","received_events_url":"https://api.github.com/users/kaicataldo/received_events","type":"User","site_admin":false},"created_at":"2016-12-16T23:11:04Z","updated_at":"2016-12-16T23:11:04Z","body":"> it will be great if no-useless-return offers an option to allow return inside blocks\r\n\r\n> Having this last useless return **enforces consistency** with other blocks and also, if you add a new block below, you will **not have to modify** the (until now) last one block to add a `return` into it.\r\n\r\nI'm a little confused here. It sounds like the proposal is to add an option that relaxes the check for the final `return` in blocks, which doesn't actually enforce consistency - it just allows it.\r\n\r\nAlso, when you mention blocks are you just referring to `if`/`else` blocks? Either way, this feels like it's going exactly against the purpose of this rule to me. I agree with @platinumazure and @not-an-aardvark and think `eslint-disable` comments should be used or the rule should be disabled entirely."}}
{"actor":{"display_login":"kaicataldo"}}