Skip to main content

Defaults

<defaults> is a file block that gives every rule in its file a category and a severity to fall back on. It is a structured block (see Structured blocks), and a file has at most one, before its first entry (see Top level).

  • Its value MUST be a mapping with no keys other than category and severity. category is a string that matches the category pattern ^[a-z][a-z0-9_]*$, and severity is blocking or advisory. Any other shape, such as an unknown key, severity: critical or a list, is invalid-defaults. The shape is also given as defaults.schema.json.
  • A category that is not a known category for the file (see Categories and severity) is unknown-category.
  • <defaults> takes no attributes. An attribute on it is unknown-attribute.
  • A tool checks the block in this order, and reports the first problem it finds: the checks of Structured blocks, then invalid-defaults, then unknown-category.
  • Every error in <defaults> is file-level, unknown-category included. The whole file is excluded, even its rules that set their own category, because the file as written is wrong. Apart from a YAML problem, the error's line is the <defaults> opening tag line.

A rule's own category and severity attributes take precedence over the defaults. Defaults never apply to a context. Here the first rule takes both defaults, the second sets both itself, and the context has neither:

Example 38 (parse)​

apps/web/src/checkout/.lore/pricing.lore
<defaults>
category: functional_correctness
severity: blocking
</defaults>

<rule id="price-from-quote">
A displayed price must come from the quote that produced it.
</rule>

<rule id="price-test-per-currency" category="test_coverage" severity="advisory">
A change to price formatting adds a test for each supported currency.
</rule>

<context id="checkout-architecture" src="ARCHITECTURE.md">
Read before judging any change to how a price is computed.
</context>
Expected output
{
"entries": [
{
"kind": "rule", "id": "price-from-quote", "file": "apps/web/src/checkout/.lore/pricing.lore",
"category": "functional_correctness", "severity": "blocking", "disabled": false,
"scopes": [{ "files": ["apps/web/src/checkout/**"], "ignores": [] }],
"when": null, "checks": [], "meta": null,
"summary": "A displayed price must come from the quote that produced it.",
"prose": "A displayed price must come from the quote that produced it.",
"src": null,
"sources": []
},
{
"kind": "rule", "id": "price-test-per-currency", "file": "apps/web/src/checkout/.lore/pricing.lore",
"category": "test_coverage", "severity": "advisory", "disabled": false,
"scopes": [{ "files": ["apps/web/src/checkout/**"], "ignores": [] }],
"when": null, "checks": [], "meta": null,
"summary": "A change to price formatting adds a test for each supported currency.",
"prose": "A change to price formatting adds a test for each supported currency.",
"src": null,
"sources": []
},
{
"kind": "context", "id": "checkout-architecture", "file": "apps/web/src/checkout/.lore/pricing.lore",
"category": null, "severity": null, "disabled": false,
"scopes": [{ "files": ["apps/web/src/checkout/**"], "ignores": [] }],
"when": null, "checks": [], "meta": null,
"summary": "Read before judging any change to how a price is computed.",
"prose": "Read before judging any change to how a price is computed.",
"src": "apps/web/src/checkout/ARCHITECTURE.md",
"sources": []
}
],
"errors": [],
"warnings": []
}

A severity the format does not define, or a key it does not define, excludes the file:

Example 39 (parse)​

.lore/checkout.lore
<defaults>
category: functional_correctness
severity: critical
</defaults>

<rule id="price-from-quote">
A displayed price must come from the quote that produced it.
</rule>
.lore/display.lore
<defaults>
category: functional_correctness
owner: web
</defaults>

<rule id="currency-from-settings">
Display text never hard-codes a currency code.
</rule>
Expected output
{
"entries": [],
"errors": [
{ "name": "invalid-defaults", "file": ".lore/checkout.lore", "entry": null, "line": 1 },
{ "name": "invalid-defaults", "file": ".lore/display.lore", "entry": null, "line": 1 }
],
"warnings": []
}