{"action":"opened","number":20,"pull_request":{"url":"https://api.github.com/repos/holidayextras/culture/pulls/20","id":40112193,"html_url":"https://github.com/holidayextras/culture/pull/20","diff_url":"https://github.com/holidayextras/culture/pull/20.diff","patch_url":"https://github.com/holidayextras/culture/pull/20.patch","issue_url":"https://api.github.com/repos/holidayextras/culture/issues/20","number":20,"state":"open","locked":false,"title":"Drop consistent-return eslint rule","user":{"login":"hxoliverrumbelow","id":3088374,"avatar_url":"https://avatars.githubusercontent.com/u/3088374?v=3","gravatar_id":"","url":"https://api.github.com/users/hxoliverrumbelow","html_url":"https://github.com/hxoliverrumbelow","followers_url":"https://api.github.com/users/hxoliverrumbelow/followers","following_url":"https://api.github.com/users/hxoliverrumbelow/following{/other_user}","gists_url":"https://api.github.com/users/hxoliverrumbelow/gists{/gist_id}","starred_url":"https://api.github.com/users/hxoliverrumbelow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hxoliverrumbelow/subscriptions","organizations_url":"https://api.github.com/users/hxoliverrumbelow/orgs","repos_url":"https://api.github.com/users/hxoliverrumbelow/repos","events_url":"https://api.github.com/users/hxoliverrumbelow/events{/privacy}","received_events_url":"https://api.github.com/users/hxoliverrumbelow/received_events","type":"User","site_admin":false},"body":"The eslint rule `consistent-return` defaults to enabled. In short, if a function does a `return` at any point, it requires all code paths to `return`. Here's their example: \r\n```\r\nfunction doSomething(condition) {\r\n    if (condition) {\r\n        return true;\r\n    } else {\r\n        return;\r\n    }\r\n}\r\n```\r\n\r\nI'd like to drop this default rule for 4 reasons:\r\n\r\n- Within async functions (for reference 38% of function declarations in HAPI are async) we're using the `return` statement to prevent further code execution, not to return any data. eslint can't tell that `callback`s never return anything, so it's static analysis complains of the missing `returns` when we invoke an async function.\r\n- Our best practices doc clearly states that functions must either `return` data, or `callback` with data. We will not accept code that combines both: https://github.com/holidayextras/culture/blob/master/serverside-javascript-best-practices.md#functions-must-either-return-data-or-callback-with-data\r\n- We expect test coverage over each return statement, all return paths of synchronous functions will have assertions to prove the correct data is being return'd: https://github.com/holidayextras/culture/blob/master/testing-standard.md#each-test-should-1\r\n - When using an async function, we have to plaster additional `return`s before every single async function invocation. This makes our code harder to read and does not add any value. Here's a very simple example for reference: \r\n```\r\n// before\r\nvar doSomeStuff = function(params, callback) {\r\n  if (!params.something) return callback(\"Invalid request\");\r\n  \r\n  otherModule.get(params.something, function(err, newItems) {\r\n    if (err) return callback(err);\r\n    var flatArray = [].concat.apply([], newItems);\r\n    \r\n    return callback(null, flatArray);\r\n  });\r\n};\r\n\r\n// after\r\nvar doSomeStuff = function(params, callback) {\r\n  if (!params.something) return callback(\"Invalid request\");\r\n  \r\n  return otherModule.get(params.something, function(err, newItems) {\r\n    if (err) return callback(err);\r\n    var flatArray = [].concat.apply([], newItems);\r\n    \r\n    return callback(null, flatArray);\r\n  });\r\n};\r\n```\r\n\r\n[ ] MarkT\r\n[ ] MikeC\r\n[ ] OllieB\r\n[ ] Jodie\r\n[ ] Kev","created_at":"2015-07-16T09:53:02Z","updated_at":"2015-07-16T09:53:02Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/holidayextras/culture/pulls/20/commits","review_comments_url":"https://api.github.com/repos/holidayextras/culture/pulls/20/comments","review_comment_url":"https://api.github.com/repos/holidayextras/culture/pulls/comments{/number}","comments_url":"https://api.github.com/repos/holidayextras/culture/issues/20/comments","statuses_url":"https://api.github.com/repos/holidayextras/culture/statuses/e4c0508153d8ebd40f9a85da76d7227a3e54bccb","head":{"label":"holidayextras:eslint-returns","ref":"eslint-returns","sha":"e4c0508153d8ebd40f9a85da76d7227a3e54bccb","user":{"login":"holidayextras","id":286993,"avatar_url":"https://avatars.githubusercontent.com/u/286993?v=3","gravatar_id":"","url":"https://api.github.com/users/holidayextras","html_url":"https://github.com/holidayextras","followers_url":"https://api.github.com/users/holidayextras/followers","following_url":"https://api.github.com/users/holidayextras/following{/other_user}","gists_url":"https://api.github.com/users/holidayextras/gists{/gist_id}","starred_url":"https://api.github.com/users/holidayextras/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/holidayextras/subscriptions","organizations_url":"https://api.github.com/users/holidayextras/orgs","repos_url":"https://api.github.com/users/holidayextras/repos","events_url":"https://api.github.com/users/holidayextras/events{/privacy}","received_events_url":"https://api.github.com/users/holidayextras/received_events","type":"Organization","site_admin":false},"repo":{"id":35272731,"name":"culture","full_name":"holidayextras/culture","owner":{"login":"holidayextras","id":286993,"avatar_url":"https://avatars.githubusercontent.com/u/286993?v=3","gravatar_id":"","url":"https://api.github.com/users/holidayextras","html_url":"https://github.com/holidayextras","followers_url":"https://api.github.com/users/holidayextras/followers","following_url":"https://api.github.com/users/holidayextras/following{/other_user}","gists_url":"https://api.github.com/users/holidayextras/gists{/gist_id}","starred_url":"https://api.github.com/users/holidayextras/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/holidayextras/subscriptions","organizations_url":"https://api.github.com/users/holidayextras/orgs","repos_url":"https://api.github.com/users/holidayextras/repos","events_url":"https://api.github.com/users/holidayextras/events{/privacy}","received_events_url":"https://api.github.com/users/holidayextras/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/holidayextras/culture","description":"Coding culture for HX","fork":false,"url":"https://api.github.com/repos/holidayextras/culture","forks_url":"https://api.github.com/repos/holidayextras/culture/forks","keys_url":"https://api.github.com/repos/holidayextras/culture/keys{/key_id}","collaborators_url":"https://api.github.com/repos/holidayextras/culture/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/holidayextras/culture/teams","hooks_url":"https://api.github.com/repos/holidayextras/culture/hooks","issue_events_url":"https://api.github.com/repos/holidayextras/culture/issues/events{/number}","events_url":"https://api.github.com/repos/holidayextras/culture/events","assignees_url":"https://api.github.com/repos/holidayextras/culture/assignees{/user}","branches_url":"https://api.github.com/repos/holidayextras/culture/branches{/branch}","tags_url":"https://api.github.com/repos/holidayextras/culture/tags","blobs_url":"https://api.github.com/repos/holidayextras/culture/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/holidayextras/culture/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/holidayextras/culture/git/refs{/sha}","trees_url":"https://api.github.com/repos/holidayextras/culture/git/trees{/sha}","statuses_url":"https://api.github.com/repos/holidayextras/culture/statuses/{sha}","languages_url":"https://api.github.com/repos/holidayextras/culture/languages","stargazers_url":"https://api.github.com/repos/holidayextras/culture/stargazers","contributors_url":"https://api.github.com/repos/holidayextras/culture/contributors","subscribers_url":"https://api.github.com/repos/holidayextras/culture/subscribers","subscription_url":"https://api.github.com/repos/holidayextras/culture/subscription","commits_url":"https://api.github.com/repos/holidayextras/culture/commits{/sha}","git_commits_url":"https://api.github.com/repos/holidayextras/culture/git/commits{/sha}","comments_url":"https://api.github.com/repos/holidayextras/culture/comments{/number}","issue_comment_url":"https://api.github.com/repos/holidayextras/culture/issues/comments{/number}","contents_url":"https://api.github.com/repos/holidayextras/culture/contents/{+path}","compare_url":"https://api.github.com/repos/holidayextras/culture/compare/{base}...{head}","merges_url":"https://api.github.com/repos/holidayextras/culture/merges","archive_url":"https://api.github.com/repos/holidayextras/culture/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/holidayextras/culture/downloads","issues_url":"https://api.github.com/repos/holidayextras/culture/issues{/number}","pulls_url":"https://api.github.com/repos/holidayextras/culture/pulls{/number}","milestones_url":"https://api.github.com/repos/holidayextras/culture/milestones{/number}","notifications_url":"https://api.github.com/repos/holidayextras/culture/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/holidayextras/culture/labels{/name}","releases_url":"https://api.github.com/repos/holidayextras/culture/releases{/id}","created_at":"2015-05-08T10:13:05Z","updated_at":"2015-06-27T17:37:45Z","pushed_at":"2015-07-16T09:20:11Z","git_url":"git://github.com/holidayextras/culture.git","ssh_url":"git@github.com:holidayextras/culture.git","clone_url":"https://github.com/holidayextras/culture.git","svn_url":"https://github.com/holidayextras/culture","homepage":null,"size":340,"stargazers_count":5,"watchers_count":5,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":2,"forks":3,"open_issues":2,"watchers":5,"default_branch":"master"}},"base":{"label":"holidayextras:master","ref":"master","sha":"1b5504f6728b7f57d59f44ae4a8133c09b5f9e56","user":{"login":"holidayextras","id":286993,"avatar_url":"https://avatars.githubusercontent.com/u/286993?v=3","gravatar_id":"","url":"https://api.github.com/users/holidayextras","html_url":"https://github.com/holidayextras","followers_url":"https://api.github.com/users/holidayextras/followers","following_url":"https://api.github.com/users/holidayextras/following{/other_user}","gists_url":"https://api.github.com/users/holidayextras/gists{/gist_id}","starred_url":"https://api.github.com/users/holidayextras/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/holidayextras/subscriptions","organizations_url":"https://api.github.com/users/holidayextras/orgs","repos_url":"https://api.github.com/users/holidayextras/repos","events_url":"https://api.github.com/users/holidayextras/events{/privacy}","received_events_url":"https://api.github.com/users/holidayextras/received_events","type":"Organization","site_admin":false},"repo":{"id":35272731,"name":"culture","full_name":"holidayextras/culture","owner":{"login":"holidayextras","id":286993,"avatar_url":"https://avatars.githubusercontent.com/u/286993?v=3","gravatar_id":"","url":"https://api.github.com/users/holidayextras","html_url":"https://github.com/holidayextras","followers_url":"https://api.github.com/users/holidayextras/followers","following_url":"https://api.github.com/users/holidayextras/following{/other_user}","gists_url":"https://api.github.com/users/holidayextras/gists{/gist_id}","starred_url":"https://api.github.com/users/holidayextras/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/holidayextras/subscriptions","organizations_url":"https://api.github.com/users/holidayextras/orgs","repos_url":"https://api.github.com/users/holidayextras/repos","events_url":"https://api.github.com/users/holidayextras/events{/privacy}","received_events_url":"https://api.github.com/users/holidayextras/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/holidayextras/culture","description":"Coding culture for HX","fork":false,"url":"https://api.github.com/repos/holidayextras/culture","forks_url":"https://api.github.com/repos/holidayextras/culture/forks","keys_url":"https://api.github.com/repos/holidayextras/culture/keys{/key_id}","collaborators_url":"https://api.github.com/repos/holidayextras/culture/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/holidayextras/culture/teams","hooks_url":"https://api.github.com/repos/holidayextras/culture/hooks","issue_events_url":"https://api.github.com/repos/holidayextras/culture/issues/events{/number}","events_url":"https://api.github.com/repos/holidayextras/culture/events","assignees_url":"https://api.github.com/repos/holidayextras/culture/assignees{/user}","branches_url":"https://api.github.com/repos/holidayextras/culture/branches{/branch}","tags_url":"https://api.github.com/repos/holidayextras/culture/tags","blobs_url":"https://api.github.com/repos/holidayextras/culture/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/holidayextras/culture/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/holidayextras/culture/git/refs{/sha}","trees_url":"https://api.github.com/repos/holidayextras/culture/git/trees{/sha}","statuses_url":"https://api.github.com/repos/holidayextras/culture/statuses/{sha}","languages_url":"https://api.github.com/repos/holidayextras/culture/languages","stargazers_url":"https://api.github.com/repos/holidayextras/culture/stargazers","contributors_url":"https://api.github.com/repos/holidayextras/culture/contributors","subscribers_url":"https://api.github.com/repos/holidayextras/culture/subscribers","subscription_url":"https://api.github.com/repos/holidayextras/culture/subscription","commits_url":"https://api.github.com/repos/holidayextras/culture/commits{/sha}","git_commits_url":"https://api.github.com/repos/holidayextras/culture/git/commits{/sha}","comments_url":"https://api.github.com/repos/holidayextras/culture/comments{/number}","issue_comment_url":"https://api.github.com/repos/holidayextras/culture/issues/comments{/number}","contents_url":"https://api.github.com/repos/holidayextras/culture/contents/{+path}","compare_url":"https://api.github.com/repos/holidayextras/culture/compare/{base}...{head}","merges_url":"https://api.github.com/repos/holidayextras/culture/merges","archive_url":"https://api.github.com/repos/holidayextras/culture/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/holidayextras/culture/downloads","issues_url":"https://api.github.com/repos/holidayextras/culture/issues{/number}","pulls_url":"https://api.github.com/repos/holidayextras/culture/pulls{/number}","milestones_url":"https://api.github.com/repos/holidayextras/culture/milestones{/number}","notifications_url":"https://api.github.com/repos/holidayextras/culture/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/holidayextras/culture/labels{/name}","releases_url":"https://api.github.com/repos/holidayextras/culture/releases{/id}","created_at":"2015-05-08T10:13:05Z","updated_at":"2015-06-27T17:37:45Z","pushed_at":"2015-07-16T09:20:11Z","git_url":"git://github.com/holidayextras/culture.git","ssh_url":"git@github.com:holidayextras/culture.git","clone_url":"https://github.com/holidayextras/culture.git","svn_url":"https://github.com/holidayextras/culture","homepage":null,"size":340,"stargazers_count":5,"watchers_count":5,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":2,"forks":3,"open_issues":2,"watchers":5,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/holidayextras/culture/pulls/20"},"html":{"href":"https://github.com/holidayextras/culture/pull/20"},"issue":{"href":"https://api.github.com/repos/holidayextras/culture/issues/20"},"comments":{"href":"https://api.github.com/repos/holidayextras/culture/issues/20/comments"},"review_comments":{"href":"https://api.github.com/repos/holidayextras/culture/pulls/20/comments"},"review_comment":{"href":"https://api.github.com/repos/holidayextras/culture/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/holidayextras/culture/pulls/20/commits"},"statuses":{"href":"https://api.github.com/repos/holidayextras/culture/statuses/e4c0508153d8ebd40f9a85da76d7227a3e54bccb"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":1,"additions":2,"deletions":1,"changed_files":1}}