Skip to content

Commit

Permalink
feat: eslint v9 Support
Browse files Browse the repository at this point in the history
  • Loading branch information
AhmedBaset committed Jul 20, 2024
1 parent 2c78bdb commit 620fba9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
15 changes: 9 additions & 6 deletions src/rules/deprecation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -109,8 +109,11 @@ function createRuleForIdentifier(
};
}

function getParent(context: TSESLint.RuleContext<MessageIds, Options>) {
const ancestors = context.getAncestors();
function getParent(
context: TSESLint.RuleContext<MessageIds, Options>,
node: TSESTree.Node,
) {
const ancestors = context.sourceCode.getAncestors(node);
return ancestors.length > 0 ? ancestors[ancestors.length - 1] : undefined;
}

Expand All @@ -122,7 +125,7 @@ function isDeclaration(
id: TSESTree.Identifier | TSESTree.JSXIdentifier,
context: TSESLint.RuleContext<MessageIds, Options>,
) {
const parent = getParent(context);
const parent = getParent(context, id);

switch (parent?.type) {
case 'TSEnumDeclaration':
Expand Down Expand Up @@ -277,7 +280,7 @@ function getCallExpression(
context: TSESLint.RuleContext<MessageIds, Options>,
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;
Expand Down

0 comments on commit 620fba9

Please sign in to comment.