Skip to content

Commit 2f85fbe

Browse files
johndeveduljharb
authored andcommitted
[Docs] no-unused-modules: Indicates usage, plugin defaults to no-op, and add description to main README.md
Fixes #1351
1 parent 7c13a4f commit 2f85fbe

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,15 @@ This plugin intends to support linting of ES2015+ (ES6+) import/export syntax, a
5353
* Report imported names marked with `@deprecated` documentation tag ([`no-deprecated`])
5454
* Forbid the use of extraneous packages ([`no-extraneous-dependencies`])
5555
* Forbid the use of mutable exports with `var` or `let`. ([`no-mutable-exports`])
56+
* Report modules without exports, or exports without matching import in another module ([`no-unused-modules`])
5657

5758
[`export`]: ./docs/rules/export.md
5859
[`no-named-as-default`]: ./docs/rules/no-named-as-default.md
5960
[`no-named-as-default-member`]: ./docs/rules/no-named-as-default-member.md
6061
[`no-deprecated`]: ./docs/rules/no-deprecated.md
6162
[`no-extraneous-dependencies`]: ./docs/rules/no-extraneous-dependencies.md
6263
[`no-mutable-exports`]: ./docs/rules/no-mutable-exports.md
64+
[`no-unused-modules`]: ./docs/rules/no-unused-modules.md
6365

6466
### Module systems
6567

docs/rules/no-unused-modules.md

+13-2
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,26 @@ Note: dynamic imports are currently not supported.
88

99
## Rule Details
1010

11+
### Usage
12+
13+
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/benmosher/eslint-plugin-import/issues/1324)
14+
15+
Example:
16+
```
17+
"rules: {
18+
...otherRules,
19+
"import/no-unused-modules": [1, {"unusedExports": true}]
20+
}
21+
```
1122

1223
### Options
1324

1425
This rule takes the following option:
1526

27+
- **`missingExports`**: if `true`, files without any exports are reported (defaults to `false`)
28+
- **`unusedExports`**: if `true`, exports without any static usage within other modules are reported (defaults to `false`)
1629
- `src`: an array with files/paths to be analyzed. It only applies to unused exports. Defaults to `process.cwd()`, if not provided
1730
- `ignoreExports`: an array with files/paths for which unused exports will not be reported (e.g module entry points in a published package)
18-
- `missingExports`: if `true`, files without any exports are reported
19-
- `unusedExports`: if `true`, exports without any static usage within other modules are reported.
2031

2132

2233
### Example for missing exports

0 commit comments

Comments
 (0)