Rule options
Markdown for agentsEach rule can have these options. A table and a shorthand can have them too, except name on a
table, which is its first argument.
| Option | Type | Default | What it does |
|---|---|---|---|
name |
string | from the condition | The name in each report, in off, in exception comments and in the baseline. |
because |
string | none | The reason. Each report shows it. |
link |
string | none | A link. Each report shows it. |
severity |
'error', 'warn' |
'error' |
'warn' reports each violation as a warning, and the check passes, as for a deprecation. check --max-warnings <count> fails past a count. |
imports |
'all', 'runtime', 'static', 'types' |
'all' |
The imports that the rule counts. 'runtime' for noCycles and a transitive rule. |
examples |
{ accepted, rejected } |
none | Code that the rule must accept, and code that it must reject. |
severity
Section titled “severity”A rule with severity: 'warn' reports each violation as a warning, and the check passes. Use it
for a deprecation, while the code that uses the old module moves:
rule('no-moment', { files: 'feature', mayNotImport: { packages: ['moment'] }, severity: 'warn' })archangel check --max-warnings 0 fails on any warning, for a CI job that keeps the count at zero.
Write the name first, or as an option. These two rules are the same:
rule('no-react-in-shared', { files: 'shared', mayNotImport: { packages: ['react'] }, examples: { rejected: ['src/shared/a.ts imports react'] } })rule({ name: 'no-react-in-shared', files: 'shared', mayNotImport: { packages: ['react'] }, examples: { rejected: ['src/shared/a.ts imports react'] } })- Without a name, archangel uses the rule itself, for example
isolate(feature). A rule withsentencesmust have a name. - Two rules cannot have one name:
rule-name-duplicate. A rule and a table cannot have one name either. - Your own names cannot have a
/. A/separates the name of a preset from its rules. To replace a preset rule, write a rule with the same name, such asfsd/public-api.
because
Section titled “because”Tell the reader why the rule exists. A person or a coding agent reads it when the rule refuses their code.
isolate('feature', { because: 'A feature changes alone. Code that two features need goes in shared.', examples: { rejected: ['src/features/login/a.ts imports src/features/cart/b.ts'] } })Each report shows it on a line = note: because: .... A config that uses the older spelling
reason shows reason:.
A link to more information, for example your architecture decision record. Each report shows it
on a line = note: see: ....
imports
Section titled “imports”Read Import options.
examples
Section titled “examples”Read Examples.