diff --git a/CHANGELOG.md b/CHANGELOG.md index f126e45d1..8cca87815 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel - [`order`]/[`newline-after-import`]: ignore TypeScript's "export import object" ([#1830], thanks [@be5invis]) - [`dynamic-import-chunkname`]/TypeScript: supports `@typescript-eslint/parser` ([#1833], thanks [@noelebrun]) - [`order`]/TypeScript: ignore ordering of object imports ([#1831], thanks [@manuth]) +- [`namespace`]: do not report on shadowed import names ([#518], thanks [@ljharb]) ### Changed - [`no-extraneous-dependencies`]: add tests for importing types ([#1824], thanks [@taye]) @@ -887,6 +888,7 @@ for info on changes for earlier releases. [#555]: https://github.com/benmosher/eslint-plugin-import/pull/555 [#538]: https://github.com/benmosher/eslint-plugin-import/pull/538 [#527]: https://github.com/benmosher/eslint-plugin-import/pull/527 +[#518]: https://github.com/benmosher/eslint-plugin-import/pull/518 [#509]: https://github.com/benmosher/eslint-plugin-import/pull/509 [#508]: https://github.com/benmosher/eslint-plugin-import/pull/508 [#503]: https://github.com/benmosher/eslint-plugin-import/pull/503 diff --git a/src/rules/namespace.js b/src/rules/namespace.js index 013e04d72..90784c076 100644 --- a/src/rules/namespace.js +++ b/src/rules/namespace.js @@ -106,6 +106,7 @@ module.exports = { MemberExpression(dereference) { if (dereference.object.type !== 'Identifier') return if (!namespaces.has(dereference.object.name)) return + if (declaredScope(context, dereference.object.name) !== 'module') return if (dereference.parent.type === 'AssignmentExpression' && dereference.parent.left === dereference) { context.report( diff --git a/tests/files/color.js b/tests/files/color.js new file mode 100644 index 000000000..dcdbf84ac --- /dev/null +++ b/tests/files/color.js @@ -0,0 +1 @@ +export const example = 'example'; diff --git a/tests/src/rules/namespace.js b/tests/src/rules/namespace.js index 1f594dbbd..93d503eb4 100644 --- a/tests/src/rules/namespace.js +++ b/tests/src/rules/namespace.js @@ -164,6 +164,14 @@ const valid = [ ]), ...SYNTAX_CASES, + + test({ + code: ` + import * as color from './color'; + export const getBackgroundFromColor = (color) => color.bg; + export const getExampleColor = () => color.example + `, + }), ] const invalid = [