File tree Expand file tree Collapse file tree 2 files changed +7
-8
lines changed Expand file tree Collapse file tree 2 files changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -20,18 +20,16 @@ module.exports = {
20
20
type : "problem" ,
21
21
} ,
22
22
create ( context ) {
23
- let inFunction = null
23
+ let functionDepth = 0
24
24
return {
25
- ":function" ( node ) {
26
- inFunction = node
25
+ ":function" ( ) {
26
+ functionDepth ++
27
27
} ,
28
- ":function:exit" ( node ) {
29
- if ( inFunction === node ) {
30
- inFunction = null
31
- }
28
+ ":function:exit" ( ) {
29
+ functionDepth --
32
30
} ,
33
31
"AwaitExpression, ForOfStatement[await=true]" ( node ) {
34
- if ( inFunction ) {
32
+ if ( functionDepth > 0 ) {
35
33
// not top-level
36
34
return
37
35
}
Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ new RuleTester({
28
28
"async function f() { for await (var a of b); }" ,
29
29
"async function f() { for await (let a of b); }" ,
30
30
"async function f() { for await (const a of b); }" ,
31
+ "async function f() { function g() {}; await expr; }" ,
31
32
"function f() { async function f() { await expr } }" ,
32
33
] ,
33
34
invalid : [
You can’t perform that action at this time.
0 commit comments