Skip to content

Commit

Permalink
fix: support ESLint v9 getScope() (#399)
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu authored Mar 25, 2024
1 parent 975c983 commit bbe0130
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/rules/no-disabled-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ export default createEslintRule<Options, MESSAGE_ID>({
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)
Expand Down
8 changes: 6 additions & 2 deletions src/utils/parseVitestFnCall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -316,9 +316,13 @@ interface ResolvedVitestFnType {

const resolveVitestFn = (
context: TSESLint.RuleContext<string, unknown[]>,
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
Expand Down

0 comments on commit bbe0130

Please sign in to comment.