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 = {
120
120
":function:exit" ( ) {
121
121
functionDepth --
122
122
} ,
123
- "AwaitExpression, ForOfStatement[await=true]" ( node ) {
123
+ "AwaitExpression, ForOfStatement[await=true], VariableDeclaration[kind='await using']" (
124
+ node
125
+ ) {
124
126
if ( functionDepth > 0 ) {
125
127
// not top-level
126
128
return
Original file line number Diff line number Diff line change 7
7
const { RuleTester } = require ( "#test-helpers" )
8
8
const rule = require ( "../../../lib/rules/no-top-level-await.js" )
9
9
const path = require ( "path" )
10
+ const tsParser = require ( "@typescript-eslint/parser" )
10
11
11
12
/**
12
13
* Makes a file path to a fixture.
@@ -100,6 +101,12 @@ new RuleTester({
100
101
} ,
101
102
] ,
102
103
} ,
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
+ } ,
103
110
// files field of `package.json` with convertPath
104
111
{
105
112
filename : fixture ( "simple-files/test/a.ts" ) ,
@@ -230,5 +237,19 @@ new RuleTester({
230
237
} ,
231
238
] ,
232
239
} ,
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
+ } ,
233
254
] ,
234
255
} )
You can’t perform that action at this time.
0 commit comments