import-js/eslint-plugin-import

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

开放

#1,716 创建于 2020年4月2日

 (1 条评论) (0 个反应) (0 位负责人)JavaScript (1,549 个派生)batch import
bughelp wanted

仓库指标

星标
 (5,938 个星标)
PR 合并指标
 (平均合并 138天 22小时) (30 天内合并 3 个 PR)

描述

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"

贡献者指南