From 6dcbfe5cf6853f2f2c4cf9e23248a68737f12e91 Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Sat, 23 Mar 2024 15:46:54 +0100 Subject: [PATCH] fix: support ESLint v9 getScope() --- src/rules/no-disabled-tests.ts | 6 +++++- src/utils/parseVitestFnCall.ts | 8 ++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/rules/no-disabled-tests.ts b/src/rules/no-disabled-tests.ts index fccae82..d087d11 100644 --- a/src/rules/no-disabled-tests.ts +++ b/src/rules/no-disabled-tests.ts @@ -69,7 +69,11 @@ export default createEslintRule({ testDepth-- }, 'CallExpression[callee.name="pending"]'(node) { - if (resolveScope(context.getScope(), 'pending')) + const scope = context.sourceCode.getScope + ? context.sourceCode.getScope(node) + : context.getScope() + + if (resolveScope(scope, 'pending')) return if (testDepth > 0) diff --git a/src/utils/parseVitestFnCall.ts b/src/utils/parseVitestFnCall.ts index 2383d18..ad59d3c 100644 --- a/src/utils/parseVitestFnCall.ts +++ b/src/utils/parseVitestFnCall.ts @@ -242,7 +242,7 @@ const parseVitestFnCallWithReasonInner = ( if (node.callee.type === AST_NODE_TYPES.TaggedTemplateExpression && lastLink !== 'each') return null - const resolved = resolveVitestFn(context, getAccessorValue(first)) + const resolved = resolveVitestFn(context, node, getAccessorValue(first)) if (!resolved) return null @@ -316,9 +316,13 @@ interface ResolvedVitestFnType { const resolveVitestFn = ( context: TSESLint.RuleContext, + node: TSESTree.Node, identifier: string ): ResolvedVitestFnType | null => { - const maybeImport = resolveScope(context.getScope(), identifier) + const scope = context.sourceCode.getScope + ? context.sourceCode.getScope(node) + : context.getScope() + const maybeImport = resolveScope(scope, identifier) if (maybeImport === 'local') return null