import-js/eslint-plugin-import

[import/no-unused-modules] Doesn't detect unused exports through an export all

オープン

#2,688 opened on 2023/01/21

 (3 件のコメント) (3 件のリアクション) (0 人の担当者)JavaScript (1,549 件のフォーク)batch import
bughelp wanted

Repository metrics

Stars
 (5,939 個のスター)
PR merge metrics
 (平均マージ 138d 22h) (30d で 3 merged PRs)

説明

I'd be happy to contribute the fix if wanted

I'd expect n.js to report it's export is unused, but it doesn't:

import { u1 } from './reexport'
//reexport.js`

export * from './n'
export * from './u'
// n.js
export const n1 = 'n
// u.js
export const u1 = 1

I've looked into trying to address this but it was more complicated than initially expected so i wanted to check in before diving down some road. All the approaches i've initially tried end up being limited by how exportList tracks ExportAllDeclarations, in that it only marks them as used if it was directly used by an importing module, but not if there is a re-export in between. AFAICT there wasn't an obvious place to extend to add this, but i assume somewhere in the importList/exportList creation?

コントリビューターガイド