Skip to content

Commit 3e1dd0b

Browse files
committed
[Fix] no-unused-modules: improve schema
- allow empty arrays in `src` and `ignoreExports` - enforce uniqueness in `src` and `ignoreExport` lists - allow false/true combo on missingExports/unusedExports
1 parent a6de522 commit 3e1dd0b

File tree

3 files changed

+14
-28
lines changed

3 files changed

+14
-28
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ 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])
1819

1920
### Changed
2021
- [Docs] [`no-duplicates`]: fix example schema ([#2684], thanks [@simmo])

docs/rules/no-unused-modules.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Reports:
1212

1313
### Usage
1414

15-
In order for this plugin to work, one of the options `missingExports` or `unusedExports` must be enabled (see "Options" section below). In the future, these options will be enabled by default (see https://github.com/import-js/eslint-plugin-import/issues/1324)
15+
In order for this plugin to work, at least one of the options `missingExports` or `unusedExports` must be enabled (see "Options" section below). In the future, these options will be enabled by default (see https://github.com/import-js/eslint-plugin-import/issues/1324)
1616

1717
Example:
1818
```

src/rules/no-unused-modules.js

+12-27
Original file line numberDiff line numberDiff line change
@@ -416,17 +416,16 @@ module.exports = {
416416
src: {
417417
description: 'files/paths to be analyzed (only for unused exports)',
418418
type: 'array',
419-
minItems: 1,
419+
uniqueItems: true,
420420
items: {
421421
type: 'string',
422422
minLength: 1,
423423
},
424424
},
425425
ignoreExports: {
426-
description:
427-
'files/paths for which unused exports will not be reported (e.g module entry points)',
426+
description: 'files/paths for which unused exports will not be reported (e.g module entry points)',
428427
type: 'array',
429-
minItems: 1,
428+
uniqueItems: true,
430429
items: {
431430
type: 'string',
432431
minLength: 1,
@@ -441,37 +440,23 @@ module.exports = {
441440
type: 'boolean',
442441
},
443442
},
444-
not: {
445-
properties: {
446-
unusedExports: { enum: [false] },
447-
missingExports: { enum: [false] },
448-
},
449-
},
450-
anyOf: [{
451-
not: {
443+
anyOf: [
444+
{
452445
properties: {
453446
unusedExports: { enum: [true] },
447+
src: {
448+
minItems: 1,
449+
},
454450
},
451+
required: ['unusedExports'],
455452
},
456-
required: ['missingExports'],
457-
}, {
458-
not: {
453+
{
459454
properties: {
460455
missingExports: { enum: [true] },
461456
},
457+
required: ['missingExports'],
462458
},
463-
required: ['unusedExports'],
464-
}, {
465-
properties: {
466-
unusedExports: { enum: [true] },
467-
},
468-
required: ['unusedExports'],
469-
}, {
470-
properties: {
471-
missingExports: { enum: [true] },
472-
},
473-
required: ['missingExports'],
474-
}],
459+
],
475460
}],
476461
},
477462

0 commit comments

Comments
 (0)