no-unassigned-import
Added in v0.9.4Configuration
Rule Details
Disallow imports whose result is not assigned or otherwise used. A bare import
or require() can load a module only for its side effects, making dependencies
harder to understand and test.
Examples of incorrect code:
Examples of correct code:
The rule checks standalone require() calls with exactly one string literal
argument. It does not check dynamic import(), dynamic require() arguments,
or calls whose result is used by another expression. It provides no automatic
fixes or suggestions because removing an import can remove side effects.
Options
allow
An array of glob patterns for imports that may be used only for side effects.
The default is [], which allows no imports solely for their side effects.
Package names match as written. Import paths beginning with . or / match
their absolute paths, resolved from the importing file. Patterns also match
relative to the linter's working directory, usually the project root.
For example, in src/app.js, import './styles/app.css' is allowed by
src/styles/** or **/*.css, but not by styles/*.css.
The upstream schema also accepts devDependencies, optionalDependencies, and
peerDependencies as booleans or arrays. These options have no effect on this
rule, matching upstream behavior.