diff --git a/package-lock.json b/package-lock.json index a87978b..c179f04 100644 --- a/package-lock.json +++ b/package-lock.json @@ -40,7 +40,7 @@ "typescript": "^5.0.2" }, "peerDependencies": { - "eslint": "^8.0.0", + "eslint": "^8.0.0 || ^9.0.0", "typescript": "^4.2.4 || ^5.0.0" } }, diff --git a/package.json b/package.json index d241b82..021a9f5 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "ts-api-utils": "^1.3.0" }, "peerDependencies": { - "eslint": "^8.0.0", + "eslint": "^8.0.0 || ^9.0.0", "typescript": "^4.2.4 || ^5.0.0" }, "devDependencies": { diff --git a/src/rules/deprecation.ts b/src/rules/deprecation.ts index a07416c..c683b96 100644 --- a/src/rules/deprecation.ts +++ b/src/rules/deprecation.ts @@ -85,8 +85,8 @@ function createRuleForIdentifier( } // - Inside an import - const isInsideImport = context - .getAncestors() + const isInsideImport = context.sourceCode + .getAncestors(id) .some((anc) => anc.type.includes('Import')); if (isInsideImport) { @@ -109,8 +109,11 @@ function createRuleForIdentifier( }; } -function getParent(context: TSESLint.RuleContext) { - const ancestors = context.getAncestors(); +function getParent( + context: TSESLint.RuleContext, + node: TSESTree.Node, +) { + const ancestors = context.sourceCode.getAncestors(node); return ancestors.length > 0 ? ancestors[ancestors.length - 1] : undefined; } @@ -122,7 +125,7 @@ function isDeclaration( id: TSESTree.Identifier | TSESTree.JSXIdentifier, context: TSESLint.RuleContext, ) { - const parent = getParent(context); + const parent = getParent(context, id); switch (parent?.type) { case 'TSEnumDeclaration': @@ -277,7 +280,7 @@ function getCallExpression( context: TSESLint.RuleContext, id: TSESTree.Node, ): TSESTree.CallExpression | TSESTree.TaggedTemplateExpression | undefined { - const ancestors = context.getAncestors(); + const ancestors = context.sourceCode.getAncestors(id); let callee = id; let parent = ancestors.length > 0 ? ancestors[ancestors.length - 1] : undefined;