Skip to content

Commit

Permalink
prefer-top-level-await: Fix crash on for..of loop (#1950)
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker authored Nov 7, 2022
1 parent 59d25a2 commit 00a29c8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion rules/prefer-top-level-await.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ function create(context) {
? definition.node.init
: definition.node;
if (
!(
!value
|| !(
(
value.type === 'ArrowFunctionExpression'
|| value.type === 'FunctionExpression'
Expand Down
1 change: 1 addition & 0 deletions test/prefer-top-level-await.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ test.snapshot({
const foo = async () => {};
await foo();
`,
'for (const statement of statements) { statement() };',
],
invalid: [
outdent`
Expand Down

0 comments on commit 00a29c8

Please sign in to comment.