Skip to content
LogoLogo

Configuration reference

The oxcruise config file. Oxcruise reads oxcruise.config.ts or .oxcruiserc.json. See Configuration for a guide. The config rejects keys that this page does not list. A key of type string or a list takes globs. A leading ! negates a glob: ["src/**", "!src/**/*.test.ts"].

$schema

Type: string.

The URL or path of the JSON schema, for editors.

calls

Type: list of string.

Names of functions whose first string argument is a dependency, for example jest.mock.

categories

Type: object of Level, by name.

The level of each category of built-in rules. The categories are correctness, suspicious, style, restriction and nursery. The default is correctness: error, suspicious: warn.

doNotFollow

Type: string or a list.

Globs of modules that stay in the graph. Oxcruise does not parse their imports.

entries

Type: string or a list.

Files, directories or globs where the graph starts. The default is ["."].

extends

Type: list of string.

Paths to other config files. Their settings are the base, and this file changes them.

forbid

Type: list of ForbidRule.

Forbidden dependencies, written as rules.

ignorePatterns

Type: string or a list.

Globs of modules to leave out of the graph. Oxcruise also uses the rules of .gitignore when it looks for modules.

jsPlugins

Type: list of JsPlugin.

JS or TS plugins: paths or package names.

overrides

Type: list of Override.

Settings that change rules for some modules.

resolve

Type: ResolveSection.

How oxcruise resolves imports.

rules

Type: Rules.

The built-in and plugin rules, by name. A rule listed here wins over its category.

symbols

Type: boolean. Default: false.

Extract exports and the names that each import uses, for json output and plugins. Rules that need them enable this option.

Types

The keys above refer to these types.

AliasedPlugin

KeyTypeDefaultDescription
name (required)stringThe prefix of the rules: <name>/<rule>. It replaces the meta.name of the plugin.
specifier (required)stringA path or a package name.

Case

The case of a name.

ValueDescription
"kebab-case"my-file
"camel-case"myFile
"pascal-case"MyFile
"snake-case"my_file

CircularFolder

One entry of folders: the folders whose dependencies on each other the rule checks.

KeyTypeDefaultDescription
path (required)string or a listGlobs of the folders. {name} captures a path segment. A module below a matching folder belongs to it. A glob matches only the folder it names.

ConventionFilter

Which conventions a rule takes into account: true (all, the default), false (none) or the names of the ones to use.

One of:

  • boolean
  • list of string

DepSectionName

Allowed values: "dependencies" or "devDependencies" or "peerDependencies" or "optionalDependencies".

FolderStructureFolder

One entry of folders: the folders it matches and the checks for each of them.

KeyTypeDefaultDescription
allowstring or a listGlobs of the names that the files and folders directly in the folder can have. A glob that starts with ! forbids a name. A list of only such globs allows every other name.
caseCaseThe case that the names of the files and folders directly in the folder must have. The rule checks the name before its first ., so Button.test.tsx is checked as Button.
messagestringOxcruise shows this text instead of the generic message of the violations of this entry.
path (required)string or a listGlobs of the folders to check. {name} captures a path segment, and require and allow can use the capture. A glob matches only the folder it names. A glob can also match a file. Then the checks apply to the folder of the file.
requirestring or a listGlobs of the files and folders that must be in the folder. A glob is relative to the folder and can contain /. Each glob needs a match.

ForbidRule

A dependency that the project does not allow. An import from a module that matches from to a target that matches to is a violation.

KeyTypeDefaultDescription
fromstring or a listGlobs of the importing module. {name} captures a path segment, and to can use the capture.
levelLevel"error"The level of the rule.
messagestringWhy the dependency is forbidden. Oxcruise shows it instead of the generic message.
name (required)stringThe name of the rule. Reports and overrides use it.
toToSpecThe target of the dependency: globs, or an object with conditions.

JsPlugin

A JS or TS plugin: a path or package name, or an object that also gives the prefix of its rules.

One of:

  • string: A path, such as "./tools/acme.ts", or a package name, such as "acme". For a package name, oxcruise tries oxcruise-plugin-acme first and then acme.
  • AliasedPlugin: An object with the specifier of the plugin and the prefix of its rules.

Level

The level of a rule. off disables the rule, warn reports violations as warnings, and error reports them as errors.

Allowed values: "off" or "warn" or "error".

ModuleKind

What a module is. The names are the ones the config (to.kind), the JSON and plugins use.

ValueDescription
"local"A file of the project, parsed.
"package"A file inside node_modules: resolved, not parsed.
"builtin"A Node.js built-in module.
"unresolved"An import that could not be resolved.

Override

Changes the settings of rules for some modules.

KeyTypeDefaultDescription
files (required)string or a listGlobs of the importing modules that this override applies to.
rulesRulesThe built-in and plugin rules, by name. A rule listed here wins over its category.

Relation

How two modules relate, for the relation condition.

ValueDescription
"same-folder"to is in the same folder as from.
"descendant-of-from"to is below the folder of from.
"descendant-of-from-parent"to is below the parent folder of from.
"sibling"to is in a sibling folder of from's folder.
"same-package"to is in the same workspace package as from.
"cross-package"to is in another workspace package than from.

ResolveSection

How oxcruise resolves imports.

KeyTypeDefaultDescription
aliasobject of string or a list, by namePath aliases. For example { "~": "./src" }.
conditionslist of stringExport and import condition names. Oxcruise tries them before import, require, node and default. For example, use ["source"] to resolve workspace packages to their source.
tsconfigstringThe tsconfig for every file. By default, each file uses the nearest tsconfig.

RuleEntry

The setting of a rule: a level, or an object with a level and the options of the rule.

One of:

  • Level
  • object of any, by name

Rules

The built-in and plugin rules, by name. A rule listed here wins over its category.

KeyTypeDefaultDescription
circular-dependenciesLevel or objectReports dependencies that are part of a circular chain of imports. The message shows the shortest cycle through each dependency.
cross-package-relative-dependenciesLevel or objectReports relative imports that reach into another workspace package, for example ../other-package/src/x.
dependencies-on-testsLevel or objectReports a non-test module that imports a test file or a test directory. Test files match *.test.* or *.spec.*. Test directories are test, tests, __tests__ and __mocks__.
deprecated-dependenciesLevel or objectReports imports of deprecated Node.js built-in modules and deprecated npm packages.
dev-dependencies-in-productionLevel or objectReports a production module that imports a package from devDependencies only.
duplicate-packagesLevel or objectReports a package that more than one package.json section declares, for example both dependencies and devDependencies. The rule ignores type-only imports.
folder-structureLevel or objectChecks the shape of the file tree: the files that a folder must have, the names that it can have, and the case of its names. The rule looks at all files in the entry folders, not only at modules. For the folders above the entry folders, such as the root folder, it knows their own files and folders, but not what is inside the other folders. It does not check those other folders.
layersLevel or objectEnforces a layered architecture: a layer can import only the layers that allow lists for it. The rule checks dependencies on local modules. Packages and built-in modules have no layer.
optional-dependenciesLevel or objectReports use of optional dependencies. An install can skip an optional dependency, so the package may not exist at runtime.
orphan-modulesLevel or objectReports modules that no other module imports and that import no module.
peer-dependenciesLevel or objectReports use of peer dependencies. The consuming project must provide a peer dependency.
undeclared-packagesLevel or objectReports imports of installed npm packages that no package.json section declares.
unresolved-dependenciesLevel or objectReports an import that oxcruise cannot resolve to a file or a package.
unused-exportsLevel or objectReports exports that no other module imports. The rule also reports:
unused-modulesLevel or objectReports source modules that no path from an entry point reaches.
unused-packagesLevel or objectReports a package that a package.json declares and that none of its modules imports.
visibilityLevel or objectRestricts what a folder shows to the code outside it. A module inside a folder can import every module in that folder. A module outside it can import only the modules that the folder makes visible. The rule checks dependencies on local modules.

ToCondition

Conditions on the dependency and the module it points to.

KeyTypeDefaultDescription
dynamicbooleanThe dependency is a dynamic import().
kindModuleKind or a listWhat the dependency points to. A dependency matches when it has any of these kinds. By default, every kind matches, except for reachable rules, which check only local and package modules.
pathstring or a listGlobs that the target of the dependency must match.
reachablebooleanto is reachable from from through other modules.
relationRelation or a listHow to relates to from. A dependency matches when it has any of these relations.
typeOnlybooleanThe dependency is only import type or export type.

ToSpec

One of:

  • string or a list: Globs the dependency's target must match.
  • ToCondition: An object with conditions on the dependency and its target.

VisibilityFolder

One entry of folders: a folder and what it shows to the code outside it.

KeyTypeDefaultDescription
messagestringOxcruise shows this text instead of the generic message.
path (required)string or a listGlobs of the folders. {name} captures a path segment, and public and private can use the capture. A glob matches only the folder it names. ** matches every folder.
privatestring or a listGlobs of the modules in the folder that code outside it cannot import. A glob is relative to the folder. private wins over public.
publicstring or a listGlobs of the modules in the folder that code outside it can import. A glob is relative to the folder. Without public, every module is public.