From 297d9379bad916d86558e18dcc2d300742dcf987 Mon Sep 17 00:00:00 2001 From: John Date: Wed, 1 May 2019 15:15:42 -0700 Subject: [PATCH] Indicates usage, plugin defaults to no-op, and add description to main README.md https://github.com/benmosher/eslint-plugin-import/issues/1351 --- README.md | 2 ++ docs/rules/no-unused-modules.md | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3e60280a80..9c4a6bc5b1 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,7 @@ This plugin intends to support linting of ES2015+ (ES6+) import/export syntax, a * Report imported names marked with `@deprecated` documentation tag ([`no-deprecated`]) * Forbid the use of extraneous packages ([`no-extraneous-dependencies`]) * Forbid the use of mutable exports with `var` or `let`. ([`no-mutable-exports`]) +* Report modules without exports, or exports without matching import in another module ([`no-unused-modules`]) [`export`]: ./docs/rules/export.md [`no-named-as-default`]: ./docs/rules/no-named-as-default.md @@ -58,6 +59,7 @@ This plugin intends to support linting of ES2015+ (ES6+) import/export syntax, a [`no-deprecated`]: ./docs/rules/no-deprecated.md [`no-extraneous-dependencies`]: ./docs/rules/no-extraneous-dependencies.md [`no-mutable-exports`]: ./docs/rules/no-mutable-exports.md +[`no-unused-modules`]: ./docs/rules/no-unused-modules.md ### Module systems diff --git a/docs/rules/no-unused-modules.md b/docs/rules/no-unused-modules.md index 96d689123a..32db6465fc 100644 --- a/docs/rules/no-unused-modules.md +++ b/docs/rules/no-unused-modules.md @@ -8,15 +8,26 @@ Note: dynamic imports are currently not supported. ## Rule Details +### Usage + +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) + +Example: +``` +"rules: { + ...otherRules, + "import/no-unused-modules": [1, {"unusedExports": true}] +} +``` ### Options This rule takes the following option: +- **`missingExports`**: if `true`, files without any exports are reported (defaults to `false`) +- **`unusedExports`**: if `true`, exports without any static usage within other modules are reported (defaults to `false`) - `src`: an array with files/paths to be analyzed. It only applies to unused exports. Defaults to `process.cwd()`, if not provided - `ignoreExports`: an array with files/paths for which unused exports will not be reported (e.g module entry points in a published package) -- `missingExports`: if `true`, files without any exports are reported -- `unusedExports`: if `true`, exports without any static usage within other modules are reported. ### Example for missing exports