{"action":"created","issue":{"url":"https://api.github.com/repos/eslint/eslint/issues/7563","repository_url":"https://api.github.com/repos/eslint/eslint","labels_url":"https://api.github.com/repos/eslint/eslint/issues/7563/labels{/name}","comments_url":"https://api.github.com/repos/eslint/eslint/issues/7563/comments","events_url":"https://api.github.com/repos/eslint/eslint/issues/7563/events","html_url":"https://github.com/eslint/eslint/pull/7563","id":188068858,"number":7563,"title":"New: Add no-await-in-loop rule","user":{"login":"nmote","id":7988361,"avatar_url":"https://avatars.githubusercontent.com/u/7988361?v=3","gravatar_id":"","url":"https://api.github.com/users/nmote","html_url":"https://github.com/nmote","followers_url":"https://api.github.com/users/nmote/followers","following_url":"https://api.github.com/users/nmote/following{/other_user}","gists_url":"https://api.github.com/users/nmote/gists{/gist_id}","starred_url":"https://api.github.com/users/nmote/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nmote/subscriptions","organizations_url":"https://api.github.com/users/nmote/orgs","repos_url":"https://api.github.com/users/nmote/repos","events_url":"https://api.github.com/users/nmote/events{/privacy}","received_events_url":"https://api.github.com/users/nmote/received_events","type":"User","site_admin":false},"labels":[{"id":131106229,"url":"https://api.github.com/repos/eslint/eslint/labels/accepted","name":"accepted","color":"0052cc","default":false},{"id":45711352,"url":"https://api.github.com/repos/eslint/eslint/labels/enhancement","name":"enhancement","color":"84b6eb","default":true},{"id":253473350,"url":"https://api.github.com/repos/eslint/eslint/labels/feature","name":"feature","color":"bfd4f2","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":10,"created_at":"2016-11-08T18:32:50Z","updated_at":"2016-11-09T17:07:01Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/eslint/eslint/pulls/7563","html_url":"https://github.com/eslint/eslint/pull/7563","diff_url":"https://github.com/eslint/eslint/pull/7563.diff","patch_url":"https://github.com/eslint/eslint/pull/7563.patch"},"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\n\r\nThis rule disallows the use of `await` within the body of a loop.\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[x] Warns about a potential error\r\n[ ] 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(things) {\r\n  const results = [];\r\n  for (const thing of things) {\r\n    results.push(await bar(thing));\r\n  }\r\n  return baz(results);\r\n}\r\n\r\nasync function baz() {\r\n  for (var i; await bar(i); i++) {\r\n  }\r\n}\r\n```\r\n\r\n**Why should this rule be included in ESLint (instead of a plugin)?**\r\n\r\nUsing `await` inside of a loop is a bad pattern no matter what codebase you are operating in. There are occasional places where it is desirable but it is typically a sign that you have done something wrong. As ES2017 features become more widely adopted it is important that the tools help people avoid common pitfalls.\r\n\r\n**What changes did you make? (Give an overview)**\r\n\r\nI added the `no-await-in-loop` rule, along with tests and docs.\r\n\r\nFixes #4166\r\n\r\n**Is there anything you'd like reviewers to focus on?**\r\n\r\n* I used a `Set` which I assume is okay now because I saw it used in the `class-methods-use-this` rule.\r\n* I didn't come across a precedent for my `wrapTest` function but I think it is worthwhile to not have to repeat the parser config in each test case.\r\n"},"comment":{"url":"https://api.github.com/repos/eslint/eslint/issues/comments/259467932","html_url":"https://github.com/eslint/eslint/pull/7563#issuecomment-259467932","issue_url":"https://api.github.com/repos/eslint/eslint/issues/7563","id":259467932,"user":{"login":"nmote","id":7988361,"avatar_url":"https://avatars.githubusercontent.com/u/7988361?v=3","gravatar_id":"","url":"https://api.github.com/users/nmote","html_url":"https://github.com/nmote","followers_url":"https://api.github.com/users/nmote/followers","following_url":"https://api.github.com/users/nmote/following{/other_user}","gists_url":"https://api.github.com/users/nmote/gists{/gist_id}","starred_url":"https://api.github.com/users/nmote/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nmote/subscriptions","organizations_url":"https://api.github.com/users/nmote/orgs","repos_url":"https://api.github.com/users/nmote/repos","events_url":"https://api.github.com/users/nmote/events{/privacy}","received_events_url":"https://api.github.com/users/nmote/received_events","type":"User","site_admin":false},"created_at":"2016-11-09T17:07:01Z","updated_at":"2016-11-09T17:07:01Z","body":"Ideas for phrasing? `// allow await` ?"}}
{"actor":{"display_login":"nmote"}}