Repository: import-js/eslint-plugin-import (JavaScript)

Issue:
Cannot read property 'namespace' of null
`eslint` version: 5.2.0
`eslint-plugin-import` version: 2.13.0
Minimal reproduction: https://github.com/riophae/eslint-plugin-import-bug

Steps to reproduce:

```bash
git clone git@github.com:riophae/eslint-plugin-import-bug.git
cd eslint-plugin-import-bug
npm install
npm test
```

Got this:

```
[/mnt/d/Projects/eslint-plugin-import-bug]$ npm test

> eslint-plugin-import-bug@ test /mnt/d/Projects/eslint-plugin-import-bug
> eslint .

Cannot read property 'namespace' of null
TypeError: Cannot read property 'namespace' of null
    at testKey (/mnt/d/Projects/eslint-plugin-import-bug/node_modules/eslint-plugin-import/lib/rules/namespace.js:194:69)
    at VariableDeclarator (/mnt/d/Projects/eslint-plugin-import-bug/node_modules/eslint-plugin-import/lib/rules/namespace.js:199:9)
    at listeners.(anonymous function).forEach.listener (/mnt/d/Projects/eslint-plugin-import-bug/node_modules/eslint/lib/util/safe-emitter.js:45:58)
    at Array.forEach (<anonymous>)
    at Object.emit (/mnt/d/Projects/eslint-plugin-import-bug/node_modules/eslint/lib/util/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/mnt/d/Projects/eslint-plugin-import-bug/node_modules/eslint/lib/util/node-event-generator.js:251:26)
    at NodeEventGenerator.applySelectors (/mnt/d/Projects/eslint-plugin-import-bug/node_modules/eslint/lib/util/node-event-generator.js:280:22)
    at NodeEventGenerator.enterNode (/mnt/d/Projects/eslint-plugin-import-bug/node_modules/eslint/lib/util/node-event-generator.js:294:14)
    at CodePathAnalyzer.enterNode (/mnt/d/Projects/eslint-plugin-import-bug/node_modules/eslint/lib/code-path-analysis/code-path-analyzer.js:632:23)
    at nodeQueue.forEach.traversalInfo (/mnt/d/Projects/eslint-plugin-import-bug/node_modules/eslint/lib/linter.js:860:28)
npm ERR! Test failed.  See above for more details.
```



Discussion:

Patch:
diff --git a/src/rules/namespace.js b/src/rules/namespace.js
index 598b530d02..dd840b86f6 100644
--- a/src/rules/namespace.js
+++ b/src/rules/namespace.js
@@ -187,7 +187,11 @@ module.exports = {
             }
 
             path.push(property.key.name)
-            testKey(property.value, namespace.get(property.key.name).namespace, path)
+            const dependencyExportMap = namespace.get(property.key.name)
+            // could be null when ignored or ambiguous
+            if (dependencyExportMap !== null) {
+              testKey(property.value, dependencyExportMap.namespace, path)
+            }
             path.pop()
           }
         }


Test patch:
diff --git a/tests/files/re-export-common.js b/tests/files/re-export-common.js
new file mode 100644
index 0000000000..3c47cd8c15
--- /dev/null
+++ b/tests/files/re-export-common.js
@@ -0,0 +1,1 @@
+export { a as foo } from './common'
diff --git a/tests/src/rules/namespace.js b/tests/src/rules/namespace.js
index 7fa8cfcdb9..e642a2b484 100644
--- a/tests/src/rules/namespace.js
+++ b/tests/src/rules/namespace.js
@@ -104,6 +104,11 @@ const valid = [
     parser: 'babel-eslint',
   }),
 
+  // #1144: should handle re-export CommonJS as namespace
+  test({
+    code: `import * as ns from './re-export-common'; const {foo} = ns;`,
+  }),
+
   // JSX
   test({
     code: 'import * as Names from "./named-exports"; const Foo = <Names.a/>',