Skip to content

vibator.depcruise namespace

This document is the reference of the depcruise subnamespace as @vibator/depcruise registers it onto the shared vibator object. Importing the package performs the registration; rules then reach it as vibator.depcruise.

The subnamespace drives dependency-cruiser through its JavaScript API (cruise()).

Reference


Functions

DeclarationDescription
configFile(options?: DepcruiseOptions): string | undefinedThe absolute path of the configuration file a run resolves, or undefined when an inline configuration applies or no configuration exists. Throws when a configured path names no file.
needsFullGraph(options?: DepcruiseOptions): Promise<boolean>Whether the loaded ruleset contains rules that need the full module graph (orphan and reachability rules) rather than the graph reachable from a set of entry points.
violations(entries: string[], options?: DepcruiseOptions): Promise<DepcruiseViolation[]>Cruises the dependency graph from the given absolute entry paths and returns every violation of the loaded ruleset, with module paths absolutized.

node_modules is never followed, and the cruise runs with the project root as its base directory.

DepcruiseOptions

The options every call accepts.

DeclarationDescription
config?: ICruiseOptionsComplete cruise options passed programmatically (a ruleset under ruleSet). Takes precedence over configPath and the root configuration files.
configPath?: stringReference to a dependency-cruiser configuration file: a ./ path from the project root, an absolute path, a package:path reference such as @vibator/gate:depcruise.cjs, or a package export such as @vibator/gate/depcruise. When omitted, .dependency-cruiser.js, .cjs, .mjs, then .json at the project root are used.

DepcruiseViolation

One dependency-cruiser violation with resolved paths.

DeclarationDescription
rule: stringThe name of the violated rule.
severity: "error" | "warn" | "info" | "ignore"The severity the ruleset assigns the rule.
from: stringThe absolute path of the module the dependency starts from.
to: stringThe absolute path of the module the dependency points at.
cycle?: string[]The module names along the cycle, when the violation is circular.
comment?: stringThe explanation the ruleset carries for the rule, when one is set.

Caching

The resolved cruise options are loaded once per configuration path and reused across calls for the duration of the run.

Released under the MIT License.