Cannot read property 'forEach' of null
TypeError: Cannot read property 'forEach' of null
at dependencies.forEach.dep (/node_modules/eslint-plugin-import/lib/ExportMap.js:182:43)
at Map.forEach (native)
at ExportMap.forEach (/node_modules/eslint-plugin-import/lib/ExportMap.js:182:23)
at EventEmitter.ExportAllDeclaration (/node_modules/eslint-plugin-import/lib/rules/export.js:62:23)
at emitOne (events.js:101:20)
at EventEmitter.emit (events.js:188:7)
at NodeEventGenerator.enterNode (/node_modules/eslint/lib/util/node-event-generator.js:39:22)
at CodePathAnalyzer.enterNode (/node_modules/eslint/lib/code-path-analysis/code-path-analyzer.js:607:23)
at CommentEventGenerator.enterNode (/node_modules/eslint/lib/util/comment-event-generator.js:97:23)
at Controller.enter (/node_modules/eslint/lib/eslint.js:928:36)
I'm using airbnb rules on WebStorm editor.
My .eslintrc is the following:
{
"parser": "babel-eslint",
"extends": "airbnb",
"env": {
"es6": true,
"jest": true
},
"plugins": [
"babel",
"flowtype",
"import",
"react",
"react-native"
],
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"sourceType": "module"
},
"settings": {
"import/extensions": [".js", ".jsx", ".android.js", ".ios.js"]
},
"rules": {
"react/jsx-filename-extension": ["off"],
"react/prefer-stateless-function": ["error", {
"ignorePureComponents": true
}],
"no-case-declarations": ["off"],
"no-underscore-dangle": ["off"],
"no-nested-ternary": ["off"],
"arrow-parens": 0,
"babel/arrow-parens": 1,
"react-native/no-unused-styles": 2,
"react-native/split-platform-components": 2,
"react-native/no-inline-styles": 2,
"react-native/no-color-literals": 2
}
}
Possibly related to #348 because I'm using export * from './file' kinda often, in a nested way, like:
fileA.js
export * from './fileB
fileB.js
export * from './fileC
fileC.js
export * from './fileD
Confirmed that this bug happens when using exports like in the comment above.
Can you help? cc @benmosher @jfmengels
Line of code: ExportMap.js#L154
Found more details. This was causing the issue:
fileB.js
export * from 'warna';
Replaced it by:
export const darken = warna.darken;
export const lighten = warna.lighten;
and now the error is gone.
this same warna: https://www.npmjs.com/package/warna?
I suspect there's a bug with export * from '[commonjs module in node_modules]'
Yes
Run into this as well. Any workaround?
@jamiter check your export * from, at least one of them are causing the problem, probably if the package is written in es5 not es6. Workaround is to not use export *
What is the workarround ?
@cgarnier the problem is with deep imports that terminate in a commonjs module reference. really I just need to test #797 though
@cgarnier https://github.com/benmosher/eslint-plugin-import/issues/717#issuecomment-292973979
Workaround is to not use export *
reopening to remember to create test
Same problem if I use this (ember 3.1)
export default {
name: 'zero',
initialize: initialize
};
@leoplct can you file a separate issue for that?
Workaround is to not use export *
I can't really enumerate all the exports of the dependency I have. Rather, I could, but it would be pretty obnoxious because the dep is Ramda and it has probably 100 exports. Is there any other solution/work around?
@rjhilgefort is this still an issue with the latest version?
I believe so. I just upgraded to 2.13.0 and I'm seeing the issue when I try to do export * from 'Ramda'. When I comment out that export, the eslint failure error is gone and I'm left with expected linter warns about the Ramda methods that aren't being exported.
TypeError: Cannot read property 'size' of null
at dependencies.forEach.dep (/Users/rjhilgefort/Projects/charter/distillery-lint/node_modules/eslint-plugin-import/lib/ExportMap.js:71:51)
at Set.forEach (<anonymous>)
at ExportMap.get size [as size] (/Users/rjhilgefort/Projects/charter/distillery-lint/node_modules/eslint-plugin-import/lib/ExportMap.js:71:23)
at processBodyStatement (/Users/rjhilgefort/Projects/charter/distillery-lint/node_modules/eslint-plugin-import/lib/rules/namespace.js:77:30)
at Array.forEach (<anonymous>)
at Program (/Users/rjhilgefort/Projects/charter/distillery-lint/node_modules/eslint-plugin-import/lib/rules/namespace.js:95:14)
at listeners.(anonymous function).forEach.listener (/Users/rjhilgefort/Projects/charter/distillery-lint/node_modules/eslint/lib/util/safe-emitter.js:47:58)
at Array.forEach (<anonymous>)
at Object.emit (/Users/rjhilgefort/Projects/charter/distillery-lint/node_modules/eslint/lib/util/safe-emitter.js:47:38)
at NodeEventGenerator.applySelector (/Users/rjhilgefort/Projects/charter/distillery-lint/node_modules/eslint/lib/util/node-event-generator.js:251:26)
Though, Ramda doesn't have a size method... so that's a bit perplexing...
the internal Map in ExportMap does, however. Thanks, that's helpful.
@rjhilgefort i think your issue will be fixed in the next release.
Leaving this open so a test can be added.
Awesome, thanks for the update and the work on this project!