packages/core/rules-catalog
(part of 's epic, "Rules 3") -- a read-only metadata catalog of every rule construct validate can report: id, owning module, the layer(s) it applies to, whether it only needs one file's own source (scope: 'buffer'...
Core engine, next. Source: packages/core/rules-catalog.mjs.
Variables#
RULE_METADATA#
constRULE_METADATA:Record<string, {expected:string[];fix:string;layers:string[];module:string;scope:"buffer"|"project";why:string; }>
Defined in: packages/core/rules-catalog.mjs:59
The static per-rule metadata table: id -> {module, layers, scope, defaultSeverity, why, expected, fix}. defaultSeverity/name mirror DEFAULT_RULES (packages/core/config.mjs);
why/expected/fix (fix is the rule's suggestedFix text where a real one exists at its
call site(s), else null) are copied from the enforcer that actually emits each rule.
Functions#
catalogRules()#
catalogRules():
object[]
Defined in: packages/core/rules-catalog.mjs:408
Every rule this catalog knows about, defaultSeverity/name sourced from DEFAULT_RULES
(packages/core/config.mjs) merged with this file's own RULE_METADATA, with no project's
architecture.yml applied -- see listRules(root) for the effective, per-project severity.
Returns#
object[]
Sorted by id.
Since#
0.11
Example#
catalogRules().find((r) => r.id === 'PAGE-001').defaultSeverity; // => 'warning'
listRules()#
listRules(
root?):object[]
Defined in: packages/core/rules-catalog.mjs:441
Every rule construct validate can report, with severity resolved against root's effective
architecture.yml (an override there wins over the built-in default). Call with no root (or a
root with no architecture.yml) to get every rule at its built-in default severity.
Parameters#
root?
string
Project root that contains (or should contain) architecture.yml.
Returns#
object[]
Sorted by id.
Since#
0.11
Example#
const rules = listRules(root);
rules.find((r) => r.id === 'CLIENT-001').severity; // => 'off' unless architecture.yml overrides it