unused-modules
Category: nursery. Default: off. Fixable: no. Since: 0.1.0.
What it does
Reports source modules that no path from an entry point reaches.
Why is this bad?
A module that nothing leads to is dead code.
Unlike orphan-modules, this rule also finds groups of modules that import each other and that nothing else uses.
Entry points
The rule finds the entry points by itself:
- the files that
package.jsonpublishes (main,module,types,binandexports) index,mainandclifiles- the files that the tools in
package.jsonload, such as tests, routes and configuration files of tools - the entry points of plugins
- the modules that the
entriesoption lists
The rule maps build output back to source files.
It reports nothing when it finds no entry point.
To keep a module and the modules that it imports, mark it with // oxcruise-ignore-file.
Options
production: tests are not entry points, and the rule does not report them. A module that only tests use is then a violation.oxcruise --productionenables it.test: globs of test modules. These globs add to*.test.*,*.spec.*and test directories.entries: globs of more entry points.ignore: globs of modules to skip. These globs add to dotfiles, declaration files and*.config.*.conventions:false, or a list of names, to use only some tool conventions.
Configure the rule
{
"rules": {
"unused-modules": "error"
}
}To set options, use an object: the level, then the options of the rule.

