Skip to content

Commit

Permalink
[Fix] no-unused-modules: checkPkgFieldObject filters boolean fiel…
Browse files Browse the repository at this point in the history
…ds from checks
  • Loading branch information
mpint authored and ljharb committed Nov 15, 2022
1 parent 9964463 commit 48e8130
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Expand Up @@ -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])
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion src/rules/no-unused-modules.js
Expand Up @@ -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;
}
Expand Down
3 changes: 2 additions & 1 deletion tests/files/no-unused-modules/browserObject/package.json
@@ -1,5 +1,6 @@
{
"browser": {
"browserObject": "./index.js"
"browserObject": "./index.js",
"an-ignored-module": false
}
}

0 comments on commit 48e8130

Please sign in to comment.