diff --git a/src/importDeclaration.js b/src/importDeclaration.js index 0d5e1870a..49446b260 100644 --- a/src/importDeclaration.js +++ b/src/importDeclaration.js @@ -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]; } diff --git a/src/rules/namespace.js b/src/rules/namespace.js index 60a4220de..6feee0d23 100644 --- a/src/rules/namespace.js +++ b/src/rules/namespace.js @@ -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; } diff --git a/src/rules/no-named-as-default-member.js b/src/rules/no-named-as-default-member.js index 54bec64a2..c6abc46a8 100644 --- a/src/rules/no-named-as-default-member.js +++ b/src/rules/no-named-as-default-member.js @@ -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; } diff --git a/src/rules/no-named-as-default.js b/src/rules/no-named-as-default.js index 5b24f8e88..c5adc7afe 100644 --- a/src/rules/no-named-as-default.js +++ b/src/rules/no-named-as-default.js @@ -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; }