import-js/eslint-plugin-import

[BUG] ESLint crashes with `import/no-unused-modules`: Cannot read property 'get' of undefined

Open

#1716 aperta il 2 apr 2020

Vedi su GitHub
 (1 commento) (0 reazioni) (0 assegnatari)JavaScript (1540 fork)batch import
bughelp wanted

Metriche repository

Star
 (4946 star)
Metriche merge PR
 (Merge medio 138g 22h) (3 PR mergiate in 30 g)

Descrizione

Eslint-plugin-import crashes running eslint with Cannot read property 'get' of undefined error.

The error is in lib/rules/no-unused-module.js on line 262:

exportAll.forEach((value, key) => { value.forEach(val => { **const currentExports = exportList.get(val);** const currentExport = currentExports.get(EXPORT_ALL_DECLARATION); currentExport.whereUsed.add(key); }); }); However, if I add condition:

if (currentExports) { const currentExport = currentExports.get(EXPORT_ALL_DECLARATION); currentExport.whereUsed.add(key); } the lint works and I can see all the lint errors .

For now, I disabled the rule in .eslintrc.js file, but would it be possible to create a fix for it, or can I do it as well?

Version: "eslint-plugin-import": "^2.20.0"

Guida contributor