Path: blob/main/docs/rules/max-dependencies.md
829 views
import/max-dependencies
Forbid modules to have too many dependencies (import or require statements).
This is a useful rule because a module with too many dependencies is a code smell, and usually indicates the module is doing too much and/or should be broken up into smaller modules.
Importing multiple named exports from a single module will only count once (e.g. import {x, y, z} from './foo' will only count as a single dependency).
Options
This rule has the following options, with these defaults:
max
This option sets the maximum number of dependencies allowed. Anything over will trigger the rule. Default is 10 if the rule is enabled and no max is specified.
Given a max value of {"max": 2}:
Fail
Pass
ignoreTypeImports
Ignores type imports. Type imports are a feature released in TypeScript 3.8, you can read more here. Defaults to false.
Given {"max": 2, "ignoreTypeImports": true}:
Fail
Pass
When Not To Use It
If you don't care how many dependencies a module has.