Skip to content

Commit cecf7a2

Browse files
futpibnovemberborn
authored andcommitted
Fix async function with for-await-of loop being reported
1 parent 8ebbca0 commit cecf7a2

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

rules/no-async-fn-without-await.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const create = context => {
2727
}),
2828
AwaitExpression: registerUseOfAwait,
2929
YieldExpression: registerUseOfAwait,
30+
'ForOfStatement[await=true]': registerUseOfAwait,
3031
'CallExpression:exit': visitIf([
3132
ava.isInTestFile,
3233
ava.isTestNode

test/no-async-fn-without-await.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ for (const options of ruleTesterOptions) {
3434
`${header}test(async function(t) { await foo(); });`,
3535
`${header}test(async t => { if (bar) { await foo(); } });`,
3636
`${header}test(async t => { if (bar) {} else { await foo(); } });`,
37+
`${header}test(async t => { for await (const foo of bar) {} });`,
3738
`${header}test.after(async () => { await foo(); });`,
3839
`${header}test('title', fn);`,
3940
`${header}test('title', function(t) {});`,

0 commit comments

Comments
 (0)