{"action":"created","comment":{"url":"https://api.github.com/repos/eslint/eslint/pulls/comments/86680533","pull_request_review_id":7328117,"id":86680533,"diff_hunk":"@@ -0,0 +1,37 @@\n+/**\n+ * @fileoverview Disallows unnecessary `return await`\n+ * @author Jordan Harband\n+ */\n+\"use strict\";\n+\n+//------------------------------------------------------------------------------\n+// Rule Definition\n+//------------------------------------------------------------------------------\n+\n+module.exports = {\n+    meta: {\n+        docs: {\n+            description: \"disallow unnecessary `return await`\",\n+            category: \"Best Practices\",\n+            recommended: false // TODO: set to true\n+        },\n+        fixable: false,\n+        schema: [\n+        ]\n+    },\n+\n+    create(context) {\n+        return {\n+            ReturnStatement(node) {\n+                if (node.argument && node.argument.type === \"AwaitExpression\") {\n+                    context.report({\n+                        node,\n+                        loc: node.argument.loc,\n+                        message: \"`return await` from an `async function` is redundant - just `return` the value directly.\",\n+                    });\n+                }\n+            },\n+\n+        };\n+    }","path":"lib/rules/no-return-await.js","position":36,"original_position":36,"commit_id":"ca21f8bc09ba648968c913b6e2b21c1b80311066","original_commit_id":"ca21f8bc09ba648968c913b6e2b21c1b80311066","user":{"login":"ljharb","id":45469,"avatar_url":"https://avatars.githubusercontent.com/u/45469?v=3","gravatar_id":"","url":"https://api.github.com/users/ljharb","html_url":"https://github.com/ljharb","followers_url":"https://api.github.com/users/ljharb/followers","following_url":"https://api.github.com/users/ljharb/following{/other_user}","gists_url":"https://api.github.com/users/ljharb/gists{/gist_id}","starred_url":"https://api.github.com/users/ljharb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ljharb/subscriptions","organizations_url":"https://api.github.com/users/ljharb/orgs","repos_url":"https://api.github.com/users/ljharb/repos","events_url":"https://api.github.com/users/ljharb/events{/privacy}","received_events_url":"https://api.github.com/users/ljharb/received_events","type":"User","site_admin":false},"body":"I'm having trouble figuring out how to get at an implicit return expression in an arrow function - any pointers?","created_at":"2016-11-06T07:18:11Z","updated_at":"2016-11-06T07:18:11Z","html_url":"https://github.com/eslint/eslint/pull/7547#discussion_r86680533","pull_request_url":"https://api.github.com/repos/eslint/eslint/pulls/7547","_links":{"self":{"href":"https://api.github.com/repos/eslint/eslint/pulls/comments/86680533"},"html":{"href":"https://github.com/eslint/eslint/pull/7547#discussion_r86680533"},"pull_request":{"href":"https://api.github.com/repos/eslint/eslint/pulls/7547"}}},"pull_request":{"url":"https://api.github.com/repos/eslint/eslint/pulls/7547","id":92478360,"html_url":"https://github.com/eslint/eslint/pull/7547","diff_url":"https://github.com/eslint/eslint/pull/7547.diff","patch_url":"https://github.com/eslint/eslint/pull/7547.patch","issue_url":"https://api.github.com/repos/eslint/eslint/issues/7547","number":7547,"state":"open","locked":false,"title":"New: `no-return-await` rule. (fixes #7537)","user":{"login":"ljharb","id":45469,"avatar_url":"https://avatars.githubusercontent.com/u/45469?v=3","gravatar_id":"","url":"https://api.github.com/users/ljharb","html_url":"https://github.com/ljharb","followers_url":"https://api.github.com/users/ljharb/followers","following_url":"https://api.github.com/users/ljharb/following{/other_user}","gists_url":"https://api.github.com/users/ljharb/gists{/gist_id}","starred_url":"https://api.github.com/users/ljharb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ljharb/subscriptions","organizations_url":"https://api.github.com/users/ljharb/orgs","repos_url":"https://api.github.com/users/ljharb/repos","events_url":"https://api.github.com/users/ljharb/events{/privacy}","received_events_url":"https://api.github.com/users/ljharb/received_events","type":"User","site_admin":false},"body":"**What is the purpose of this pull request? (put an \"X\" next to item)**\r\n\r\n[ ] Documentation update\r\n[ ] Bug fix ([template](https://raw.githubusercontent.com/eslint/eslint/master/templates/bug-report.md))\r\n[x] New rule ([template](https://raw.githubusercontent.com/eslint/eslint/master/templates/rule-proposal.md))\r\n[ ] Changes an existing rule ([template](https://raw.githubusercontent.com/eslint/eslint/master/templates/rule-change-proposal.md))\r\n[ ] Add autofixing to a rule\r\n[ ] Add a CLI option\r\n[ ] Add something to the core\r\n[ ] Other, please explain:\r\n\r\n**Please describe what the rule should do:**\r\nInside an `async function`, `return await` is useless. Since the return value of an `async function` is always wrapped in `Promise.resolve`, `return await` doesn't actually do anything except add an extra tick before the overarching promise resolves/rejects. This pattern is almost certainly due to programmer ignorance of the return semantics of `async function`s.\r\n\r\n**What category of rule is this? (place an \"X\" next to just one item)**\r\n\r\n[ ] Enforces code style\r\n[ ] Warns about a potential error\r\n[x] Suggests an alternate way of doing something\r\n[ ] Other (please specify:)\r\n\r\n**Provide 2-3 code examples that this rule will warn about:**\r\n\r\n```js\r\nasync function foo() {\r\n  return await bar;\r\n}\r\n```\r\n\r\nin favor of:\r\n```js\r\nasync function foo() {\r\n  return bar;\r\n}\r\n```\r\n\r\n**Why should this rule be included in ESLint (instead of a plugin)?**\r\nPeople are very anxious to use `await`, and will likely overuse it. This rule prevents a common hazard, and also helps educate developers about how `async function` works.\r\n\r\n**What changes did you make? (Give an overview)**\r\nI added a rule file, a test file, and a docs file. The rule checks for return statements whose argument is an await expression.\r\n\r\n**Is there anything you'd like reviewers to focus on?**\r\n¯\\\\\\_(ツ)_/¯","created_at":"2016-11-06T06:00:26Z","updated_at":"2016-11-06T07:18:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8e70cc7945c8d6ae186744753ad2141bae220370","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/eslint/eslint/pulls/7547/commits","review_comments_url":"https://api.github.com/repos/eslint/eslint/pulls/7547/comments","review_comment_url":"https://api.github.com/repos/eslint/eslint/pulls/comments{/number}","comments_url":"https://api.github.com/repos/eslint/eslint/issues/7547/comments","statuses_url":"https://api.github.com/repos/eslint/eslint/statuses/ca21f8bc09ba648968c913b6e2b21c1b80311066","head":{"label":"ljharb:no-return-await","ref":"no-return-await","sha":"ca21f8bc09ba648968c913b6e2b21c1b80311066","user":{"login":"ljharb","id":45469,"avatar_url":"https://avatars.githubusercontent.com/u/45469?v=3","gravatar_id":"","url":"https://api.github.com/users/ljharb","html_url":"https://github.com/ljharb","followers_url":"https://api.github.com/users/ljharb/followers","following_url":"https://api.github.com/users/ljharb/following{/other_user}","gists_url":"https://api.github.com/users/ljharb/gists{/gist_id}","starred_url":"https://api.github.com/users/ljharb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ljharb/subscriptions","organizations_url":"https://api.github.com/users/ljharb/orgs","repos_url":"https://api.github.com/users/ljharb/repos","events_url":"https://api.github.com/users/ljharb/events{/privacy}","received_events_url":"https://api.github.com/users/ljharb/received_events","type":"User","site_admin":false},"repo":{"id":27574511,"name":"eslint","full_name":"ljharb/eslint","owner":{"login":"ljharb","id":45469,"avatar_url":"https://avatars.githubusercontent.com/u/45469?v=3","gravatar_id":"","url":"https://api.github.com/users/ljharb","html_url":"https://github.com/ljharb","followers_url":"https://api.github.com/users/ljharb/followers","following_url":"https://api.github.com/users/ljharb/following{/other_user}","gists_url":"https://api.github.com/users/ljharb/gists{/gist_id}","starred_url":"https://api.github.com/users/ljharb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ljharb/subscriptions","organizations_url":"https://api.github.com/users/ljharb/orgs","repos_url":"https://api.github.com/users/ljharb/repos","events_url":"https://api.github.com/users/ljharb/events{/privacy}","received_events_url":"https://api.github.com/users/ljharb/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ljharb/eslint","description":"A fully pluggable tool for identifying and reporting on patterns in JavaScript.","fork":true,"url":"https://api.github.com/repos/ljharb/eslint","forks_url":"https://api.github.com/repos/ljharb/eslint/forks","keys_url":"https://api.github.com/repos/ljharb/eslint/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ljharb/eslint/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ljharb/eslint/teams","hooks_url":"https://api.github.com/repos/ljharb/eslint/hooks","issue_events_url":"https://api.github.com/repos/ljharb/eslint/issues/events{/number}","events_url":"https://api.github.com/repos/ljharb/eslint/events","assignees_url":"https://api.github.com/repos/ljharb/eslint/assignees{/user}","branches_url":"https://api.github.com/repos/ljharb/eslint/branches{/branch}","tags_url":"https://api.github.com/repos/ljharb/eslint/tags","blobs_url":"https://api.github.com/repos/ljharb/eslint/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ljharb/eslint/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ljharb/eslint/git/refs{/sha}","trees_url":"https://api.github.com/repos/ljharb/eslint/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ljharb/eslint/statuses/{sha}","languages_url":"https://api.github.com/repos/ljharb/eslint/languages","stargazers_url":"https://api.github.com/repos/ljharb/eslint/stargazers","contributors_url":"https://api.github.com/repos/ljharb/eslint/contributors","subscribers_url":"https://api.github.com/repos/ljharb/eslint/subscribers","subscription_url":"https://api.github.com/repos/ljharb/eslint/subscription","commits_url":"https://api.github.com/repos/ljharb/eslint/commits{/sha}","git_commits_url":"https://api.github.com/repos/ljharb/eslint/git/commits{/sha}","comments_url":"https://api.github.com/repos/ljharb/eslint/comments{/number}","issue_comment_url":"https://api.github.com/repos/ljharb/eslint/issues/comments{/number}","contents_url":"https://api.github.com/repos/ljharb/eslint/contents/{+path}","compare_url":"https://api.github.com/repos/ljharb/eslint/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ljharb/eslint/merges","archive_url":"https://api.github.com/repos/ljharb/eslint/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ljharb/eslint/downloads","issues_url":"https://api.github.com/repos/ljharb/eslint/issues{/number}","pulls_url":"https://api.github.com/repos/ljharb/eslint/pulls{/number}","milestones_url":"https://api.github.com/repos/ljharb/eslint/milestones{/number}","notifications_url":"https://api.github.com/repos/ljharb/eslint/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ljharb/eslint/labels{/name}","releases_url":"https://api.github.com/repos/ljharb/eslint/releases{/id}","deployments_url":"https://api.github.com/repos/ljharb/eslint/deployments","created_at":"2014-12-05T04:34:56Z","updated_at":"2016-03-09T08:37:59Z","pushed_at":"2016-11-06T05:57:24Z","git_url":"git://github.com/ljharb/eslint.git","ssh_url":"git@github.com:ljharb/eslint.git","clone_url":"https://github.com/ljharb/eslint.git","svn_url":"https://github.com/ljharb/eslint","homepage":"http://eslint.org","size":13346,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"eslint:master","ref":"master","sha":"e117b80cf2ed7b712057d3c2194c1c626edd3ce3","user":{"login":"eslint","id":6019716,"avatar_url":"https://avatars.githubusercontent.com/u/6019716?v=3","gravatar_id":"","url":"https://api.github.com/users/eslint","html_url":"https://github.com/eslint","followers_url":"https://api.github.com/users/eslint/followers","following_url":"https://api.github.com/users/eslint/following{/other_user}","gists_url":"https://api.github.com/users/eslint/gists{/gist_id}","starred_url":"https://api.github.com/users/eslint/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eslint/subscriptions","organizations_url":"https://api.github.com/users/eslint/orgs","repos_url":"https://api.github.com/users/eslint/repos","events_url":"https://api.github.com/users/eslint/events{/privacy}","received_events_url":"https://api.github.com/users/eslint/received_events","type":"Organization","site_admin":false},"repo":{"id":11061773,"name":"eslint","full_name":"eslint/eslint","owner":{"login":"eslint","id":6019716,"avatar_url":"https://avatars.githubusercontent.com/u/6019716?v=3","gravatar_id":"","url":"https://api.github.com/users/eslint","html_url":"https://github.com/eslint","followers_url":"https://api.github.com/users/eslint/followers","following_url":"https://api.github.com/users/eslint/following{/other_user}","gists_url":"https://api.github.com/users/eslint/gists{/gist_id}","starred_url":"https://api.github.com/users/eslint/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eslint/subscriptions","organizations_url":"https://api.github.com/users/eslint/orgs","repos_url":"https://api.github.com/users/eslint/repos","events_url":"https://api.github.com/users/eslint/events{/privacy}","received_events_url":"https://api.github.com/users/eslint/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/eslint/eslint","description":"A fully pluggable tool for identifying and reporting on patterns in JavaScript.","fork":false,"url":"https://api.github.com/repos/eslint/eslint","forks_url":"https://api.github.com/repos/eslint/eslint/forks","keys_url":"https://api.github.com/repos/eslint/eslint/keys{/key_id}","collaborators_url":"https://api.github.com/repos/eslint/eslint/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/eslint/eslint/teams","hooks_url":"https://api.github.com/repos/eslint/eslint/hooks","issue_events_url":"https://api.github.com/repos/eslint/eslint/issues/events{/number}","events_url":"https://api.github.com/repos/eslint/eslint/events","assignees_url":"https://api.github.com/repos/eslint/eslint/assignees{/user}","branches_url":"https://api.github.com/repos/eslint/eslint/branches{/branch}","tags_url":"https://api.github.com/repos/eslint/eslint/tags","blobs_url":"https://api.github.com/repos/eslint/eslint/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/eslint/eslint/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/eslint/eslint/git/refs{/sha}","trees_url":"https://api.github.com/repos/eslint/eslint/git/trees{/sha}","statuses_url":"https://api.github.com/repos/eslint/eslint/statuses/{sha}","languages_url":"https://api.github.com/repos/eslint/eslint/languages","stargazers_url":"https://api.github.com/repos/eslint/eslint/stargazers","contributors_url":"https://api.github.com/repos/eslint/eslint/contributors","subscribers_url":"https://api.github.com/repos/eslint/eslint/subscribers","subscription_url":"https://api.github.com/repos/eslint/eslint/subscription","commits_url":"https://api.github.com/repos/eslint/eslint/commits{/sha}","git_commits_url":"https://api.github.com/repos/eslint/eslint/git/commits{/sha}","comments_url":"https://api.github.com/repos/eslint/eslint/comments{/number}","issue_comment_url":"https://api.github.com/repos/eslint/eslint/issues/comments{/number}","contents_url":"https://api.github.com/repos/eslint/eslint/contents/{+path}","compare_url":"https://api.github.com/repos/eslint/eslint/compare/{base}...{head}","merges_url":"https://api.github.com/repos/eslint/eslint/merges","archive_url":"https://api.github.com/repos/eslint/eslint/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/eslint/eslint/downloads","issues_url":"https://api.github.com/repos/eslint/eslint/issues{/number}","pulls_url":"https://api.github.com/repos/eslint/eslint/pulls{/number}","milestones_url":"https://api.github.com/repos/eslint/eslint/milestones{/number}","notifications_url":"https://api.github.com/repos/eslint/eslint/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/eslint/eslint/labels{/name}","releases_url":"https://api.github.com/repos/eslint/eslint/releases{/id}","deployments_url":"https://api.github.com/repos/eslint/eslint/deployments","created_at":"2013-06-29T23:59:48Z","updated_at":"2016-11-06T03:14:51Z","pushed_at":"2016-11-06T06:32:13Z","git_url":"git://github.com/eslint/eslint.git","ssh_url":"git@github.com:eslint/eslint.git","clone_url":"https://github.com/eslint/eslint.git","svn_url":"https://github.com/eslint/eslint","homepage":"http://eslint.org","size":19952,"stargazers_count":6216,"watchers_count":6216,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1195,"mirror_url":null,"open_issues_count":251,"forks":1195,"open_issues":251,"watchers":6216,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/eslint/eslint/pulls/7547"},"html":{"href":"https://github.com/eslint/eslint/pull/7547"},"issue":{"href":"https://api.github.com/repos/eslint/eslint/issues/7547"},"comments":{"href":"https://api.github.com/repos/eslint/eslint/issues/7547/comments"},"review_comments":{"href":"https://api.github.com/repos/eslint/eslint/pulls/7547/comments"},"review_comment":{"href":"https://api.github.com/repos/eslint/eslint/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/eslint/eslint/pulls/7547/commits"},"statuses":{"href":"https://api.github.com/repos/eslint/eslint/statuses/ca21f8bc09ba648968c913b6e2b21c1b80311066"}}}}
{"actor":{"display_login":"ljharb"}}