Skip to content

layer-check.mjs

Refuses an import that runs against the layer direction.

Contributor toolinglayer-check.mjs

What it does

Reads every tracked source file in a layer, resolves each import it carries, and fails when one reaches a layer that layer may not reach. The direction is engine at the bottom, imported by catalog and gameplay, those two imported by server; the client reaches all three and never src/server. A file no layer claims is not judged.

Usage

Run the check over the whole tree:

bash
npm run layers:check

The command takes no arguments.

Options

No options.

Inputs and outputs

Reads the tracked file list, the source of every file under a layer, and the imports alias map in package.json. Writes nothing.

On success it exits 0 and prints the file count, the number of cross-layer imports it judged, and a zero violation count. On failure it exits 1 and prints one line per offending import — the importing file, the direction it ran, and the specifier as written.

Examples

Check the direction over the whole tree, which is what the gate runs:

bash
npm run layers:check

Notes

There is no baseline. The tree carried no violation when this check was written, so it starts at zero and stays there. A layer that has to be crossed is a decision for a record under docs/adr/, not a baseline entry.

The judged count in the passing line is the guard against a silent scan. A run reporting zero violations over zero crossings has proved nothing, so the number of cross-layer imports it actually judged is printed next to the result.

The scan reads tracked files, so a file written and not yet staged is invisible until it is staged.

Source

tools/layer-check.mjs — part of Contributor tooling

See also: tools/import-graph-check.mjs the design-world strip check over the client entry