Skip to content

Commit 90e2dfa

Browse files
Chamionljharb
authored andcommitted
[Fix] no-unused-modules: report error on binding instead of parent export
1 parent d3aa478 commit 90e2dfa

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

CHANGELOG.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
1515
- [`order`]: partial fix for [#2687] (thanks [@ljharb])
1616
- [`no-duplicates`]: Detect across type and regular imports ([#2835], thanks [@benkrejci])
1717
- [`extensions`]: handle `.` and `..` properly ([#2778], thanks [@benasher44])
18-
- [`no-unused-modules`]: improve schema (thanks [@ljharb])
18+
- [`no-unused-modules`]: improve schema (thanks [@ljharb])
19+
- [`no-unused-modules`]: report error on binding instead of parent export ([#2842], thanks [@Chamion])
1920

2021
### Changed
2122
- [Docs] [`no-duplicates`]: fix example schema ([#2684], thanks [@simmo])
@@ -1076,6 +1077,7 @@ for info on changes for earlier releases.
10761077

10771078
[`memo-parser`]: ./memo-parser/README.md
10781079

1080+
[#2842]: https://github.com/import-js/eslint-plugin-import/pull/2842
10791081
[#2835]: https://github.com/import-js/eslint-plugin-import/pull/2835
10801082
[#2832]: https://github.com/import-js/eslint-plugin-import/pull/2832
10811083
[#2778]: https://github.com/import-js/eslint-plugin-import/pull/2778
@@ -1666,6 +1668,7 @@ for info on changes for earlier releases.
16661668
[@bradzacher]: https://github.com/bradzacher
16671669
[@brendo]: https://github.com/brendo
16681670
[@brettz9]: https://github.com/brettz9
1671+
[@Chamion]: https://github.com/Chamion
16691672
[@charlessuh]: https://github.com/charlessuh
16701673
[@charpeni]: https://github.com/charpeni
16711674
[@cherryblossom000]: https://github.com/cherryblossom000

src/rules/no-unused-modules.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -931,7 +931,7 @@ module.exports = {
931931
},
932932
ExportNamedDeclaration(node) {
933933
node.specifiers.forEach((specifier) => {
934-
checkUsage(node, specifier.exported.name || specifier.exported.value);
934+
checkUsage(specifier, specifier.exported.name || specifier.exported.value);
935935
});
936936
forEachDeclarationIdentifier(node.declaration, (name) => {
937937
checkUsage(node, name);

tests/src/rules/no-unused-modules.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -184,17 +184,17 @@ ruleTester.run('no-unused-modules', rule, {
184184
{
185185
message: `exported declaration 'default' not used within other modules`,
186186
line: 12,
187-
column: 9,
187+
column: 18,
188188
},
189189
{
190190
message: `exported declaration 'o0' not used within other modules`,
191191
line: 12,
192-
column: 9,
192+
column: 27,
193193
},
194194
{
195195
message: `exported declaration 'o3' not used within other modules`,
196196
line: 12,
197-
column: 9,
197+
column: 31,
198198
},
199199
error(`exported declaration 'p' not used within other modules`),
200200
],

0 commit comments

Comments
 (0)