diff --git a/CHANGELOG.md b/CHANGELOG.md index 948bbbc53..c9ee1593a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,7 +28,8 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange - [`dynamic-import-chunkname`]: prevent false report on a valid webpack magic comment ([#2330], thanks [@mhmadhamster]) - [`export`]: do not error on TS export overloads ([#1590], thanks [@ljharb]) - [`no-unresolved`], [`extensions`]: ignore type only exports ([#2436], thanks [@Lukas-Kullmann]) -- [Fix] `ExportMap`: add missing param to function ([#2589], thanks [@Fdawgs]) +- `ExportMap`: add missing param to function ([#2589], thanks [@Fdawgs]) +- [`no-unused-modules`]: `checkPkgFieldObject` filters boolean fields from checks ([#2598], thanks [@mpint]) ### Changed - [Tests] [`named`]: Run all TypeScript test ([#2427], thanks [@ProdigySim]) @@ -1022,6 +1023,7 @@ for info on changes for earlier releases. [`memo-parser`]: ./memo-parser/README.md +[#2598]: https://github.com/import-js/eslint-plugin-import/pull/2598 [#2589]: https://github.com/import-js/eslint-plugin-import/pull/2589 [#2588]: https://github.com/import-js/eslint-plugin-import/pull/2588 [#2582]: https://github.com/import-js/eslint-plugin-import/pull/2582 @@ -1697,6 +1699,7 @@ for info on changes for earlier releases. [@mgwalker]: https://github.com/mgwalker [@mhmadhamster]: https://github.com/MhMadHamster [@MikeyBeLike]: https://github.com/MikeyBeLike +[@mpint]: https://github.com/mpint [@mplewis]: https://github.com/mplewis [@mrmckeb]: https://github.com/mrmckeb [@msvab]: https://github.com/msvab diff --git a/src/rules/no-unused-modules.js b/src/rules/no-unused-modules.js index 8f8b4b634..bd8c524ab 100644 --- a/src/rules/no-unused-modules.js +++ b/src/rules/no-unused-modules.js @@ -364,7 +364,10 @@ const fileIsInPkg = file => { }; const checkPkgFieldObject = pkgField => { - const pkgFieldFiles = values(pkgField).map(value => join(basePath, value)); + const pkgFieldFiles = values(pkgField) + .filter((value) => typeof value !== 'boolean') + .map(value => join(basePath, value)); + if (includes(pkgFieldFiles, file)) { return true; } diff --git a/tests/files/no-unused-modules/browserObject/package.json b/tests/files/no-unused-modules/browserObject/package.json index 28272c6fe..7cf213f81 100644 --- a/tests/files/no-unused-modules/browserObject/package.json +++ b/tests/files/no-unused-modules/browserObject/package.json @@ -1,5 +1,6 @@ { "browser": { - "browserObject": "./index.js" + "browserObject": "./index.js", + "an-ignored-module": false } }