From 411cdc838ea43700c9039ef86e395f0efdd62ec7 Mon Sep 17 00:00:00 2001 From: auvred Date: Wed, 1 Nov 2023 16:17:21 +0000 Subject: [PATCH] fix(eslint-plugin): [require-await] add support for "await using" --- .../eslint-plugin/src/rules/require-await.ts | 1 + .../tests/rules/require-await.test.ts | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/packages/eslint-plugin/src/rules/require-await.ts b/packages/eslint-plugin/src/rules/require-await.ts index 86049b04e587..c2dd66f8252d 100644 --- a/packages/eslint-plugin/src/rules/require-await.ts +++ b/packages/eslint-plugin/src/rules/require-await.ts @@ -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, diff --git a/packages/eslint-plugin/tests/rules/require-await.test.ts b/packages/eslint-plugin/tests/rules/require-await.test.ts index 6e36dcf10c22..7bcb1d6a0b4f 100644 --- a/packages/eslint-plugin/tests/rules/require-await.test.ts +++ b/packages/eslint-plugin/tests/rules/require-await.test.ts @@ -232,6 +232,11 @@ async function* foo(): Promise { yield* x; } `, + ` + const fn = async () => { + await using foo = new Bar(); + }; + `, ], invalid: [ @@ -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 pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy