Exports
exports restricts which files may import a named symbol from a module. Use it when
importers of the same file need different rules, such as a factory only a composition root may call.
exports: - name: bus-factories-at-composition-roots message: "Build a bus only at a composition root." module: "**/node_modules/@org/cqrs/**" symbols: [makeCommandBus, makeQueryBus] except: ["@/server.ts", "@/platform/cqrs/**"]exports is a top-level manifest key, not a node field.
Fields
Section titled “Fields”| Field | Meaning |
|---|---|
name |
Rule id, reported on a violation. Required. |
message |
Why. Required. |
module |
Globs matched against the module’s resolved path. Required. |
symbols |
Exact exported names. Omit to mean any import of the selected kinds from that module. |
kinds |
Binding forms the rule applies to: named, default, namespace. Default ["named"]. |
except |
Importers the rule doesn’t apply to. |
fix |
"subpath-namespace-import" offers an autofix (see below). |
probe |
{ source, symbol }, an import the rule must cover. See Authored probes. |
Names are matched as the source module exports them, so aliasing doesn’t escape a rule:
import { makeCommandBus as make } is still makeCommandBus.
Binding forms
Section titled “Binding forms”A rule only sees named imports unless kinds says otherwise. A default import’s symbol is
default and a namespace import’s is *, whatever the importer calls it.
namespace covers every form that takes the whole module: import * as, export *,
export * as, import x = require(), import() and require(). With no symbols, it
forbids those forms, for example to stop a barrel re-exporting an internal folder:
- name: no-barrel-laundering message: "Re-export internal symbols by name." module: "src/**/internal/**" kinds: [namespace] except: ["src/**/index.ts"]exports ignores side-effect imports (import "m").
Autofix
Section titled “Autofix”fix: "subpath-namespace-import" rewrites a named import into namespace imports from matching
subpaths. It applies only to rules without symbols.
// beforeimport { Effect, Layer } from "effect";
// afterimport * as Effect from "effect/Effect";import * as Layer from "effect/Layer";Authored probes
Section titled “Authored probes”An authored probe proves the rule catches the import form you mean. Every import in
source is treated as reaching module, and the rule must cover symbol ("default" or "*"
for those forms), or the policy fails to load.
probe: source: 'import { makeCommandBus } from "@org/cqrs";' symbol: makeCommandBusSee Probes.