diff --git a/CHANGELOG.md b/CHANGELOG.md index c85317cca..2f9e67189 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,8 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange - [`order`]: partial fix for [#2687] (thanks [@ljharb]) - [`no-duplicates`]: Detect across type and regular imports ([#2835], thanks [@benkrejci]) - [`extensions`]: handle `.` and `..` properly ([#2778], thanks [@benasher44]) - - [`no-unused-modules`]: improve schema (thanks [@ljharb]) +- [`no-unused-modules`]: improve schema (thanks [@ljharb]) +- [`no-unused-modules`]: report error on binding instead of parent export ([#2842], thanks [@Chamion]) ### Changed - [Docs] [`no-duplicates`]: fix example schema ([#2684], thanks [@simmo]) @@ -1076,6 +1077,7 @@ for info on changes for earlier releases. [`memo-parser`]: ./memo-parser/README.md +[#2842]: https://github.com/import-js/eslint-plugin-import/pull/2842 [#2835]: https://github.com/import-js/eslint-plugin-import/pull/2835 [#2832]: https://github.com/import-js/eslint-plugin-import/pull/2832 [#2778]: https://github.com/import-js/eslint-plugin-import/pull/2778 @@ -1666,6 +1668,7 @@ for info on changes for earlier releases. [@bradzacher]: https://github.com/bradzacher [@brendo]: https://github.com/brendo [@brettz9]: https://github.com/brettz9 +[@Chamion]: https://github.com/Chamion [@charlessuh]: https://github.com/charlessuh [@charpeni]: https://github.com/charpeni [@cherryblossom000]: https://github.com/cherryblossom000 diff --git a/src/rules/no-unused-modules.js b/src/rules/no-unused-modules.js index f3d56e429..c8a20f8c0 100644 --- a/src/rules/no-unused-modules.js +++ b/src/rules/no-unused-modules.js @@ -931,7 +931,7 @@ module.exports = { }, ExportNamedDeclaration(node) { node.specifiers.forEach((specifier) => { - checkUsage(node, specifier.exported.name || specifier.exported.value); + checkUsage(specifier, specifier.exported.name || specifier.exported.value); }); forEachDeclarationIdentifier(node.declaration, (name) => { checkUsage(node, name); diff --git a/tests/src/rules/no-unused-modules.js b/tests/src/rules/no-unused-modules.js index 80f0fee73..77fb608cc 100644 --- a/tests/src/rules/no-unused-modules.js +++ b/tests/src/rules/no-unused-modules.js @@ -184,17 +184,17 @@ ruleTester.run('no-unused-modules', rule, { { message: `exported declaration 'default' not used within other modules`, line: 12, - column: 9, + column: 18, }, { message: `exported declaration 'o0' not used within other modules`, line: 12, - column: 9, + column: 27, }, { message: `exported declaration 'o3' not used within other modules`, line: 12, - column: 9, + column: 31, }, error(`exported declaration 'p' not used within other modules`), ],