Skip to content

Commit

Permalink
fix(eslint-plugin): [require-await] add support for "await using" (#7866
Browse files Browse the repository at this point in the history
)
  • Loading branch information
auvred committed Nov 1, 2023
1 parent 11e57c5 commit 855abea
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/eslint-plugin/src/rules/require-await.ts
Expand Up @@ -149,6 +149,7 @@ export default createRule({
'ArrowFunctionExpression:exit': exitFunction,

AwaitExpression: markAsHasAwait,
'VariableDeclaration[kind = "await using"]': markAsHasAwait,
'ForOfStatement[await = true]': markAsHasAwait,
'YieldExpression[delegate = true]': markAsHasDelegateGen,

Expand Down
20 changes: 20 additions & 0 deletions packages/eslint-plugin/tests/rules/require-await.test.ts
Expand Up @@ -232,6 +232,11 @@ async function* foo(): Promise<string> {
yield* x;
}
`,
`
const fn = async () => {
await using foo = new Bar();
};
`,
],

invalid: [
Expand Down Expand Up @@ -410,6 +415,21 @@ async function* asyncGenerator() {
},
],
},
{
code: `
const fn = async () => {
using foo = new Bar();
};
`,
errors: [
{
messageId: 'missingAwait',
data: {
name: "Async arrow function 'fn'",
},
},
],
},
],
});
// base eslint tests
Expand Down

0 comments on commit 855abea

Please sign in to comment.