Skip to content

Commit

Permalink
fix: replace missed usage of context.getAncestors
Browse files Browse the repository at this point in the history
  • Loading branch information
G-Rath committed Sep 6, 2024
1 parent 934f59e commit 1a51e0f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/importDeclaration.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export default function importDeclaration(context) {
const ancestors = context.getAncestors();
import { getAncestors } from 'eslint-module-utils/contextCompat';

export default function importDeclaration(context, node) {
const ancestors = getAncestors(context, node);
return ancestors[ancestors.length - 1];
}
2 changes: 1 addition & 1 deletion src/rules/namespace.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ module.exports = {

// same as above, but does not add names to local map
ExportNamespaceSpecifier(namespace) {
const declaration = importDeclaration(context);
const declaration = importDeclaration(context, namespace);

const imports = ExportMapBuilder.get(declaration.source.value, context);
if (imports == null) { return null; }
Expand Down
2 changes: 1 addition & 1 deletion src/rules/no-named-as-default-member.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ module.exports = {

return {
ImportDefaultSpecifier(node) {
const declaration = importDeclaration(context);
const declaration = importDeclaration(context, node);
const exportMap = ExportMapBuilder.get(declaration.source.value, context);
if (exportMap == null) { return; }

Expand Down
2 changes: 1 addition & 1 deletion src/rules/no-named-as-default.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module.exports = {
// #566: default is a valid specifier
if (defaultSpecifier[nameKey].name === 'default') { return; }

const declaration = importDeclaration(context);
const declaration = importDeclaration(context, defaultSpecifier);

const imports = ExportMapBuilder.get(declaration.source.value, context);
if (imports == null) { return; }
Expand Down

0 comments on commit 1a51e0f

Please sign in to comment.