File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -120,7 +120,9 @@ module.exports = {
120120            ":function:exit" ( )  { 
121121                functionDepth -- 
122122            } , 
123-             "AwaitExpression, ForOfStatement[await=true]" ( node )  { 
123+             "AwaitExpression, ForOfStatement[await=true], VariableDeclaration[kind='await using']" ( 
124+                 node 
125+             )  { 
124126                if  ( functionDepth  >  0 )  { 
125127                    // not top-level 
126128                    return 
Original file line number Diff line number Diff line change 77const  {  RuleTester }  =  require ( "#test-helpers" ) 
88const  rule  =  require ( "../../../lib/rules/no-top-level-await.js" ) 
99const  path  =  require ( "path" ) 
10+ const  tsParser  =  require ( "@typescript-eslint/parser" ) 
1011
1112/** 
1213 * Makes a file path to a fixture. 
@@ -100,6 +101,12 @@ new RuleTester({
100101                } , 
101102            ] , 
102103        } , 
104+         // await using 
105+         { 
106+             filename : fixture ( "simple-files/lib/a.js" ) , 
107+             code : "async function f() { await using foo = x }" , 
108+             languageOptions : {  parser : tsParser  } , 
109+         } , 
103110        // files field of `package.json` with convertPath 
104111        { 
105112            filename : fixture ( "simple-files/test/a.ts" ) , 
@@ -230,5 +237,19 @@ new RuleTester({
230237                } , 
231238            ] , 
232239        } , 
240+         // await using 
241+         { 
242+             filename : fixture ( "simple-files/lib/a.js" ) , 
243+             code : "await using foo = x" , 
244+             languageOptions : {  parser : tsParser  } , 
245+             errors : [ 
246+                 { 
247+                     message :
248+                         "Top-level `await` is forbidden in published modules." , 
249+                     line : 1 , 
250+                     column : 1 , 
251+                 } , 
252+             ] , 
253+         } , 
233254    ] , 
234255} ) 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments