Parsing
A tool reads a Lore file from top to bottom, one top-level element at a time, and interprets each element as it reads it. Every error found while parsing a Lore file is either file-level or entry-level; Error reach lists which is which, and the sections below say so for the errors they define.
- A file-level error excludes the whole file. The document model MUST list that error and nothing else from the file: no entries, no other errors and no warnings. When a file has several file-level errors, the one listed is the first that a top-to-bottom reading meets.
- An entry-level error excludes only its entry. The document model MUST list that error and nothing else from the entry. When an entry has several errors, the one listed is the first met reading the entry from top to bottom: its opening tag, then its indentation, then its children in order.
- A tool MAY show a user more problems than the document model lists.
Each file here has two problems, and only the first is listed. The first file is excluded whole; in the second, only the broken rule is excluded:
Example 5 (parse)
Checkout rules.
<rule id="price-from-quote" category="functional_correctness">
A displayed price must come from the quote that produced it.
</rule>
<notes>
Ask the pricing team before adding rules here.
</notes>
<rule id="currency-from-settings" category="functional_correctness">
<scope>
files: ["**/*.tsx"]
files: ["**/*.ts"]
</scope>
<when>
addedContains: &codes ["'USD'"]
</when>
Display text never hard-codes a currency code.
</rule>
<rule id="dates-from-locale" category="functional_correctness">
Displayed dates are formatted with the shop's locale.
</rule>
{
"entries": [
{
"kind": "rule", "id": "dates-from-locale", "file": ".lore/display.lore",
"category": "functional_correctness", "severity": "advisory", "disabled": false,
"scopes": [{ "files": ["**"], "ignores": [] }],
"when": null, "checks": [], "meta": null,
"summary": "Displayed dates are formatted with the shop's locale.",
"prose": "Displayed dates are formatted with the shop's locale.",
"src": null,
"sources": []
}
],
"errors": [
{ "name": "top-level-text", "file": ".lore/checkout.lore", "entry": null, "line": 1 },
{ "name": "duplicate-key", "file": ".lore/display.lore", "entry": "currency-from-settings", "line": 4 }
],
"warnings": []
}
Lines and tags
The structure of a Lore file is carried by tag lines. A tag line holds one opening tag or one closing tag and nothing else, apart from the leading spaces and tabs a position allows and any trailing spaces and tabs.
- An opening tag is
<, an element name, an attribute list, and>. The attribute list is zero or more attributes, each preceded by one or more spaces or tabs, followed by optional spaces or tabs. - An attribute is
name="value", where the value is any characters other than"and MAY be empty, or a barename(a boolean attribute). - A closing tag is
</, an element name, and>. - Element and attribute names are ASCII letters, digits and
-, and start with a letter. Names are case-sensitive.
A line looks like a tag when, ignoring leading and trailing spaces
and tabs, it starts with < or </ and a name, followed either by >
as the line's last character, or by a space or a tab with the line
ending in >. So <details> and <rule id="a"> look like tags, while
<kbd>Esc</kbd> and <https://example.com> do not.
Where a tag line can appear (at column 0 at the top level, and among an entry's children), a line that looks like a tag is read as one:
- A line that starts with
</MUST be exactly a closing tag. Otherwise it isunreadable-structure, a file-level error. - A line that starts with
<is an opening tag. Its element name is always readable, so the element's extent is known. The name is checked first: at the top level, a name the format does not define isunknown-elementwhatever follows it. - If the text between the name and the final
>is not a valid attribute list, the attributes are malformed:invalid-attribute-value. A tool meets this problem at the first character where the list stops being valid, so a problem with an attribute before that character (see Attributes) is met first. On an entry or one of its children this is an entry-level error; on a file block it is file-level. On a file block, the position errors of Top level (file-block-after-entry, thenduplicate-file-block) are checked before the attributes. - When the entry's own opening tag is malformed, the error's
entryis the entry's readable id (see Attributes) if, reading that tag's attribute list from left to right, its firstidattribute comes before the first character at which the list stops being valid; otherwise it is null. When a child's opening tag is malformed, the entry's own opening tag has already been read, and the error'sentryis the entry's id.
Element contents and attribute values are raw text. A tool MUST NOT
decode entities or process escapes in either: & stays &.
An unquoted attribute value is malformed. The element's extent is still
known, so only that entry is excluded. The unquoted id of
currency-from-settings is itself the malformed value, so its error
names no entry. In dates-from-locale the id is read before the
malformed value, so the error names it. In no-hard-coded-currency, the
malformed tag is a child's, and the error names the entry:
Example 6 (parse)
<rule id="price-from-quote" category="functional_correctness">
A displayed price must come from the quote that produced it.
</rule>
<rule id=currency-from-settings category="functional_correctness">
Display text never hard-codes a currency code.
</rule>
<rule id="dates-from-locale" category=functional_correctness>
Displayed dates are formatted with the shop's locale.
</rule>
<rule id="no-hard-coded-currency" category="functional_correctness">
<check lang=regex>
'USD'
</check>
Display text never hard-codes a currency code.
</rule>
{
"entries": [
{
"kind": "rule", "id": "price-from-quote", "file": ".lore/checkout.lore",
"category": "functional_correctness", "severity": "advisory", "disabled": false,
"scopes": [{ "files": ["**"], "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": []
}
],
"errors": [
{ "name": "invalid-attribute-value", "file": ".lore/checkout.lore", "entry": null, "line": 5 },
{ "name": "invalid-attribute-value", "file": ".lore/checkout.lore", "entry": "dates-from-locale", "line": 9 },
{ "name": "invalid-attribute-value", "file": ".lore/checkout.lore", "entry": "no-hard-coded-currency", "line": 14 }
],
"warnings": []
}
Contents are raw text, so the condition looks for the five characters
&, and the prose keeps them as written:
Example 7 (parse)
<rule id="names-stored-unescaped" category="functional_correctness">
<when>
addedContains: ["&"]
</when>
Product names are stored as written: `Fish & Chips`, never `Fish & Chips`.
</rule>
{
"entries": [
{
"kind": "rule", "id": "names-stored-unescaped", "file": ".lore/catalog.lore",
"category": "functional_correctness", "severity": "advisory", "disabled": false,
"scopes": [{ "files": ["**"], "ignores": [] }],
"when": { "addedContains": ["&"] }, "checks": [], "meta": null,
"summary": "Product names are stored as written: `Fish & Chips`, never `Fish & Chips`.",
"prose": "Product names are stored as written: `Fish & Chips`, never `Fish & Chips`.",
"src": null,
"sources": []
}
],
"errors": [],
"warnings": []
}
Top level
At the top level, a file holds file blocks, entries, comments and blank lines:
| Element | Count |
|---|---|
<defaults> | 0 or 1, before the first entry (see Defaults) |
<scope> | 0 or 1, before the first entry (see Scope and globs) |
<rule> | any number (see Rules) |
<context> | any number (see Context) |
<!-- --> comment | any number |
- Top-level tag lines and comments MUST start at column 0.
- An element runs from its opening tag line to the next line at column 0
that is its closing tag (for an entry, as Entries refines).
The lines strictly between are its contents. An element with no
closing tag before the end of the file is
unreadable-structure. - A comment starts with
<!--at column 0 and ends at the first-->after it, on the same line or a later one. The rest of the line after-->MUST be blank. A tool MUST ignore comments. A comment with no-->isunreadable-structure. - Blank lines MAY appear between elements.
- Any other non-blank line at the top level is
top-level-text, including an indented line and text after a comment's-->. - An opening tag whose name is not
defaults,scope,ruleorcontextisunknown-element. A closing tag at the top level, outside any element, isunreadable-structure. - A
<defaults>or<scope>after the first entry isfile-block-after-entry. Otherwise, a second<defaults>or a second<scope>isduplicate-file-block. Position is checked first, so a second<scope>after an entry isfile-block-after-entry. - Every error in this section is file-level.
Text between two entries excludes the file. The error is reported at the first stray line:
Example 8 (parse)
<rule id="price-from-quote" category="functional_correctness">
A displayed price must come from the quote that produced it.
</rule>
Rules below this line need review.
<rule id="currency-from-settings" category="functional_correctness">
Display text never hard-codes a currency code.
</rule>
{
"entries": [],
"errors": [
{ "name": "top-level-text", "file": ".lore/checkout.lore", "entry": null, "line": 5 }
],
"warnings": []
}
An element the format does not define excludes the file:
Example 9 (parse)
<rule id="price-from-quote" category="functional_correctness">
A displayed price must come from the quote that produced it.
</rule>
<notes>
Ask the pricing team before adding rules here.
</notes>
{
"entries": [],
"errors": [
{ "name": "unknown-element", "file": ".lore/checkout.lore", "entry": null, "line": 5 }
],
"warnings": []
}
A rule left open at the end of the file, and a closing tag with no opening tag, each make the structure unreadable:
Example 10 (parse)
<rule id="price-from-quote" category="functional_correctness">
A displayed price must come from the quote that produced it.
</rule>
<rule id="currency-from-settings" category="functional_correctness">
Display text never hard-codes a currency code.
<rule id="dates-from-locale" category="functional_correctness">
Displayed dates are formatted with the shop's locale.
</rule>
</rule>
{
"entries": [],
"errors": [
{ "name": "unreadable-structure", "file": ".lore/checkout.lore", "entry": null, "line": 5 },
{ "name": "unreadable-structure", "file": ".lore/display.lore", "entry": null, "line": 4 }
],
"warnings": []
}
A file has at most one <scope>:
Example 11 (parse)
<scope>
files: ["**/*.tsx"]
</scope>
<scope>
ignores: ["**/*.test.tsx"]
</scope>
<rule id="price-from-quote" category="functional_correctness">
A displayed price must come from the quote that produced it.
</rule>
{
"entries": [],
"errors": [
{ "name": "duplicate-file-block", "file": ".lore/checkout.lore", "entry": null, "line": 5 }
],
"warnings": []
}
A file block comes before every entry. The file is excluded, so the rule before the block is not listed, and neither is the warning its missing category would raise:
Example 12 (parse)
<rule id="price-from-quote">
A displayed price must come from the quote that produced it.
</rule>
<defaults>
category: functional_correctness
</defaults>
{
"entries": [],
"errors": [
{ "name": "file-block-after-entry", "file": ".lore/checkout.lore", "entry": null, "line": 5 }
],
"warnings": []
}
A second <scope> that also comes after an entry breaks both rules.
Position is checked first:
Example 13 (parse)
<scope>
files: ["**/*.tsx"]
</scope>
<rule id="price-from-quote" category="functional_correctness">
A displayed price must come from the quote that produced it.
</rule>
<scope>
ignores: ["**/*.test.tsx"]
</scope>
{
"entries": [],
"errors": [
{ "name": "file-block-after-entry", "file": ".lore/checkout.lore", "entry": null, "line": 9 }
],
"warnings": []
}
A comment may span lines. Text after its --> is top-level-text, and
a comment that never closes makes the structure unreadable:
Example 14 (parse)
<!--
Owned by the pricing team.
-->
<rule id="price-from-quote" category="functional_correctness">
A displayed price must come from the quote that produced it.
</rule>
<!-- Display rules. --> Owned by the web team.
<rule id="currency-from-settings" category="functional_correctness">
Display text never hard-codes a currency code.
</rule>
<rule id="dates-from-locale" category="functional_correctness">
Displayed dates are formatted with the shop's locale.
</rule>
<!-- Rules below are drafts.
<rule id="times-from-locale" category="functional_correctness">
Displayed times are formatted with the shop's locale.
</rule>
{
"entries": [
{
"kind": "rule", "id": "price-from-quote", "file": ".lore/checkout.lore",
"category": "functional_correctness", "severity": "advisory", "disabled": false,
"scopes": [{ "files": ["**"], "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": []
}
],
"errors": [
{ "name": "unreadable-structure", "file": ".lore/dates.lore", "entry": null, "line": 5 },
{ "name": "top-level-text", "file": ".lore/display.lore", "entry": null, "line": 1 }
],
"warnings": []
}
Entries
An entry's contents are its children, then its prose. A tool reads them line by line after the opening tag:
- Children. Blank lines are skipped, and the entry's closing tag at
column 0 ends the entry. Any other line that looks like a tag,
ignoring leading spaces and tabs, is a child's opening or closing tag.
An opening tag opens a child element, which runs to the next line
that, ignoring leading and trailing spaces and tabs, is the child's
closing tag. While a child is open, the entry's closing tag at column
0 still ends the entry, even when the child has the same name as the
entry; the child is then unclosed:
unreadable-structure. A child still open at the end of the file is unclosed too. A closing tag that closes no child isunreadable-structure. Which children an entry allows is defined in Rules and Context. - Prose. The first line that is neither blank nor looks like a tag
starts the prose. From there on, the only line with meaning is the
entry's closing tag (
</rule>or</context>) at column 0. Every other line, tag-shaped or not, is prose. A comment line among the children starts the prose, since comments are recognized only at the top level. - Fences. Inside a fenced code block in the prose, the closing tag is not recognized either, so a rule can show Lore syntax. A fence opens at a prose line whose first characters after any spaces and tabs are three or more backticks, with no further backtick on the line, or three or more tildes. It closes at the next line that, ignoring leading and trailing spaces and tabs, is a run of the same character at least as long. A fence that never closes runs to the end of the file. This rule follows CommonMark's fenced code blocks but ignores their indentation limit, and decides only where the entry ends.
- To keep a closing-tag line in the prose outside a fence, indent it.
A note for authors: the first line of the prose must not look like a
tag. A prose that opens with a lone HTML tag line, such as <details>
or <a href="#quotes">, has that line read as a child, at any
indentation. Start the prose with text instead.
The entry ends at its closing tag. If the end of the file comes first,
the entry is unreadable-structure. An entry whose closing tag is
missing therefore takes in every following entry, as prose, up to the
next closing tag of its kind at column 0. Every error in this section is
file-level.
A child's contents are the lines strictly between its tags, after the entry's common indentation and then the child's own are removed (see Indentation).
The entry's prose is its lines from the first prose line up to the
closing tag, after the entry's common indentation is removed, with
trailing blank lines dropped, joined with line feeds. Every other byte is
kept as written. An entry with no prose has prose "".
The entry's summary is the first paragraph of its prose: the prose
lines before the first blank line, each with leading and trailing spaces
and tabs removed, joined with single spaces. The paragraph is found by
lines, not by parsing Markdown. An entry with no prose has summary "".
Once the prose starts, tag-shaped lines are prose. This <when> is part
of the rule's text, not a condition:
Example 15 (parse)
<rule id="currency-from-settings" category="functional_correctness">
Display text never hard-codes a currency code.
<when>
addedContains: ["'USD'"]
</when>
</rule>
{
"entries": [
{
"kind": "rule", "id": "currency-from-settings", "file": ".lore/checkout.lore",
"category": "functional_correctness", "severity": "advisory", "disabled": false,
"scopes": [{ "files": ["**"], "ignores": [] }],
"when": null, "checks": [], "meta": null,
"summary": "Display text never hard-codes a currency code.",
"prose": "Display text never hard-codes a currency code.\n\n<when>\naddedContains: [\"'USD'\"]\n</when>",
"src": null,
"sources": []
}
],
"errors": [],
"warnings": []
}
A closing tag inside a fenced code block in the prose does not end the rule:
Example 16 (parse)
<rule id="lore-samples-fenced" category="documentation">
Lore syntax shown in a rule's prose sits in a fenced code block, so its
closing tags do not end the rule.
```
<rule id="price-from-quote">
A displayed price must come from the quote that produced it.
</rule>
```
</rule>
{
"entries": [
{
"kind": "rule", "id": "lore-samples-fenced", "file": ".lore/docs.lore",
"category": "documentation", "severity": "advisory", "disabled": false,
"scopes": [{ "files": ["**"], "ignores": [] }],
"when": null, "checks": [], "meta": null,
"summary": "Lore syntax shown in a rule's prose sits in a fenced code block, so its closing tags do not end the rule.",
"prose": "Lore syntax shown in a rule's prose sits in a fenced code block, so its\nclosing tags do not end the rule.\n\n```\n<rule id=\"price-from-quote\">\nA displayed price must come from the quote that produced it.\n</rule>\n```",
"src": null,
"sources": []
}
],
"errors": [],
"warnings": []
}
An indented closing tag outside a fence is prose too:
Example 17 (parse)
<rule id="closing-tags-at-column-zero" category="documentation">
An entry ends at its closing tag at column 0. An indented closing tag,
like the next line, is prose:
</rule>
The rule continues here.
</rule>
{
"entries": [
{
"kind": "rule", "id": "closing-tags-at-column-zero", "file": ".lore/docs.lore",
"category": "documentation", "severity": "advisory", "disabled": false,
"scopes": [{ "files": ["**"], "ignores": [] }],
"when": null, "checks": [], "meta": null,
"summary": "An entry ends at its closing tag at column 0. An indented closing tag, like the next line, is prose:",
"prose": "An entry ends at its closing tag at column 0. An indented closing tag,\nlike the next line, is prose:\n\n </rule>\n\nThe rule continues here.",
"src": null,
"sources": []
}
],
"errors": [],
"warnings": []
}
A comment at the top level is ignored. Inside an entry, a comment line
starts the prose, so in the second rule the <when> after the comment
is prose and the rule has no condition:
Example 18 (parse)
<!-- Checkout rules, owned by the pricing team. -->
<rule id="price-from-quote" category="functional_correctness">
<!-- Agreed in the 2026 pricing review. -->
A displayed price must come from the quote that produced it.
</rule>
<rule id="currency-from-settings" category="functional_correctness">
<!-- Check new code only. -->
<when>
addedContains: ["'USD'"]
</when>
Display text never hard-codes a currency code.
</rule>
{
"entries": [
{
"kind": "rule", "id": "price-from-quote", "file": ".lore/checkout.lore",
"category": "functional_correctness", "severity": "advisory", "disabled": false,
"scopes": [{ "files": ["**"], "ignores": [] }],
"when": null, "checks": [], "meta": null,
"summary": "<!-- Agreed in the 2026 pricing review. --> A displayed price must come from the quote that produced it.",
"prose": "<!-- Agreed in the 2026 pricing review. -->\nA displayed price must come from the quote that produced it.",
"src": null,
"sources": []
},
{
"kind": "rule", "id": "currency-from-settings", "file": ".lore/checkout.lore",
"category": "functional_correctness", "severity": "advisory", "disabled": false,
"scopes": [{ "files": ["**"], "ignores": [] }],
"when": null, "checks": [], "meta": null,
"summary": "<!-- Check new code only. --> <when> addedContains: [\"'USD'\"] </when> Display text never hard-codes a currency code.",
"prose": "<!-- Check new code only. -->\n<when>\naddedContains: [\"'USD'\"]\n</when>\nDisplay text never hard-codes a currency code.",
"src": null,
"sources": []
}
],
"errors": [],
"warnings": []
}
An entry with no prose has empty prose and summary:
Example 19 (parse)
<rule id="currency-from-settings" category="functional_correctness">
<when>
addedContains: ["'USD'"]
</when>
</rule>
{
"entries": [
{
"kind": "rule", "id": "currency-from-settings", "file": ".lore/checkout.lore",
"category": "functional_correctness", "severity": "advisory", "disabled": false,
"scopes": [{ "files": ["**"], "ignores": [] }],
"when": { "addedContains": ["'USD'"] }, "checks": [], "meta": null,
"summary": "",
"prose": "",
"src": null,
"sources": []
}
],
"errors": [],
"warnings": []
}
A child left open when the entry's closing tag arrives is unclosed, and
the file is excluded. In the second file, the <rule> line among the
children opens a child, and the </rule> at column 0 ends the entry,
not that child:
Example 20 (parse)
<rule id="price-from-quote" category="functional_correctness">
A displayed price must come from the quote that produced it.
</rule>
<rule id="currency-from-settings" category="functional_correctness">
<when>
addedContains: ["'USD'"]
</rule>
<rule id="dates-from-locale" category="functional_correctness">
<rule id="times-from-locale" category="functional_correctness">
Displayed times are formatted with the shop's locale.
</rule>
{
"entries": [],
"errors": [
{ "name": "unreadable-structure", "file": ".lore/checkout.lore", "entry": null, "line": 6 },
{ "name": "unreadable-structure", "file": ".lore/display.lore", "entry": null, "line": 2 }
],
"warnings": []
}
A closing tag among the children that closes no child excludes the file:
Example 21 (parse)
<rule id="currency-from-settings" category="functional_correctness">
<when>
addedContains: ["'USD'"]
</when>
</when>
Display text never hard-codes a currency code.
</rule>
{
"entries": [],
"errors": [
{ "name": "unreadable-structure", "file": ".lore/checkout.lore", "entry": null, "line": 5 }
],
"warnings": []
}
A rule whose closing tag is missing takes in the next rule as prose. No
error is reported, because the second </rule> closes the first rule:
Example 22 (parse)
<rule id="price-from-quote" category="functional_correctness">
A displayed price must come from the quote that produced it.
<rule id="currency-from-settings" category="functional_correctness">
Display text never hard-codes a currency code.
</rule>
{
"entries": [
{
"kind": "rule", "id": "price-from-quote", "file": ".lore/checkout.lore",
"category": "functional_correctness", "severity": "advisory", "disabled": false,
"scopes": [{ "files": ["**"], "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.\n\n<rule id=\"currency-from-settings\" category=\"functional_correctness\">\nDisplay text never hard-codes a currency code.",
"src": null,
"sources": []
}
],
"errors": [],
"warnings": []
}
The entry's common indentation here is two spaces. The prose keeps the continuation line's extra indentation, the summary trims it, the line of four spaces becomes empty, and the trailing blank lines are dropped:
Example 23 (parse)
<rule id="quote-totals-match" category="functional_correctness">
The order page shows the total
from the quote that produced it.
A total rebuilt from line items drops quote-level discounts.
</rule>
{
"entries": [
{
"kind": "rule", "id": "quote-totals-match", "file": ".lore/checkout.lore",
"category": "functional_correctness", "severity": "advisory", "disabled": false,
"scopes": [{ "files": ["**"], "ignores": [] }],
"when": null, "checks": [], "meta": null,
"summary": "The order page shows the total from the quote that produced it.",
"prose": "The order page shows the total\n from the quote that produced it.\n\nA total rebuilt from line items drops quote-level discounts.",
"src": null,
"sources": []
}
],
"errors": [],
"warnings": []
}
A tilde fence protects a closing tag too. The ~~~ line inside does not
close the ~~~~ fence, since it is shorter:
Example 24 (parse)
<rule id="lore-samples-tilde-fenced" category="documentation">
A tilde fence works as well as a backtick fence.
~~~~
~~~
</rule>
~~~~
</rule>
{
"entries": [
{
"kind": "rule", "id": "lore-samples-tilde-fenced", "file": ".lore/docs.lore",
"category": "documentation", "severity": "advisory", "disabled": false,
"scopes": [{ "files": ["**"], "ignores": [] }],
"when": null, "checks": [], "meta": null,
"summary": "A tilde fence works as well as a backtick fence.",
"prose": "A tilde fence works as well as a backtick fence.\n\n~~~~\n~~~\n</rule>\n~~~~",
"src": null,
"sources": []
}
],
"errors": [],
"warnings": []
}
Indentation
Indentation inside an element carries no meaning, so an indented file and a flush-left file mean the same thing.
- An element's common indentation is the longest string of spaces and tabs that begins every non-blank line of its contents. Before interpreting an element's contents, a tool MUST remove the common indentation from every non-blank line and make every blank line empty.
- This applies to every element: file blocks, entries and children. A child's contents have the entry's common indentation removed first, then the child's own.
- Spaces and tabs both work, but MUST NOT be mixed: when an element's
contents have at least one non-blank line, every non-blank line begins
with a space or a tab, and the lines have no common indentation, the
element is
inconsistent-indentation. In a file block it is a file-level error; in an entry or one of its children, an entry-level error. - YAML does not allow tabs for nesting, so nested YAML uses spaces after the common indentation.
The same rule written flush-left, indented with spaces and indented with tabs gives the same model in all three files, apart from the id:
Example 25 (parse)
<scope>
files: ["apps/web/src/checkout/**"]
</scope>
<rule id="currency-flush" category="functional_correctness">
<when>
addedContains:
- "'USD'"
</when>
Display text never hard-codes a currency code.
It uses the shop's `currency` setting.
</rule>
<scope>
files: ["apps/web/src/checkout/**"]
</scope>
<rule id="currency-indented" category="functional_correctness">
<when>
addedContains:
- "'USD'"
</when>
Display text never hard-codes a currency code.
It uses the shop's `currency` setting.
</rule>
<scope>
files: ["apps/web/src/checkout/**"]
</scope>
<rule id="currency-tabs" category="functional_correctness">
<when>
addedContains:
- "'USD'"
</when>
Display text never hard-codes a currency code.
It uses the shop's `currency` setting.
</rule>
{
"entries": [
{
"kind": "rule", "id": "currency-flush", "file": ".lore/flush.lore",
"category": "functional_correctness", "severity": "advisory", "disabled": false,
"scopes": [{ "files": ["apps/web/src/checkout/**"], "ignores": [] }],
"when": { "addedContains": ["'USD'"] }, "checks": [], "meta": null,
"summary": "Display text never hard-codes a currency code.",
"prose": "Display text never hard-codes a currency code.\n\nIt uses the shop's `currency` setting.",
"src": null,
"sources": []
},
{
"kind": "rule", "id": "currency-indented", "file": ".lore/indented.lore",
"category": "functional_correctness", "severity": "advisory", "disabled": false,
"scopes": [{ "files": ["apps/web/src/checkout/**"], "ignores": [] }],
"when": { "addedContains": ["'USD'"] }, "checks": [], "meta": null,
"summary": "Display text never hard-codes a currency code.",
"prose": "Display text never hard-codes a currency code.\n\nIt uses the shop's `currency` setting.",
"src": null,
"sources": []
},
{
"kind": "rule", "id": "currency-tabs", "file": ".lore/tabs.lore",
"category": "functional_correctness", "severity": "advisory", "disabled": false,
"scopes": [{ "files": ["apps/web/src/checkout/**"], "ignores": [] }],
"when": { "addedContains": ["'USD'"] }, "checks": [], "meta": null,
"summary": "Display text never hard-codes a currency code.",
"prose": "Display text never hard-codes a currency code.\n\nIt uses the shop's `currency` setting.",
"src": null,
"sources": []
}
],
"errors": [],
"warnings": []
}
One line indented with a tab and another with spaces leave no common indentation. Only that rule is excluded:
Example 26 (parse)
<rule id="currency-from-settings" category="functional_correctness">
Display text never hard-codes a currency code.
It uses the shop's `currency` setting.
</rule>
<rule id="price-from-quote" category="functional_correctness">
A displayed price must come from the quote that produced it.
</rule>
{
"entries": [
{
"kind": "rule", "id": "price-from-quote", "file": ".lore/checkout.lore",
"category": "functional_correctness", "severity": "advisory", "disabled": false,
"scopes": [{ "files": ["**"], "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": []
}
],
"errors": [
{ "name": "inconsistent-indentation", "file": ".lore/checkout.lore", "entry": "currency-from-settings", "line": 1 }
],
"warnings": []
}
Structured blocks
<defaults>, <scope>, <when>, <meta> and <source> are structured
blocks, and so is a .loreconfig file. Their contents are YAML 1.2
read with the core schema: for a block in a Lore file, after
Indentation; for a .loreconfig, as written.
JSON is valid YAML 1.2, so a block MAY be written in JSON, and files MAY
mix the two. A tool reads a block as one YAML document, with these
rules:
- A block with no content other than blank lines and comments is an empty mapping.
- Anchors (
&name), aliases (*name) and directives (%YAML) areyaml-feature-not-allowed. So is every tag, custom or standard:!moneyand!!stralike. - Every mapping key MUST be a string, and every value MUST have a JSON
equivalent. A key that is not a string (such as
2026:, which the core schema reads as a number) isyaml-feature-not-allowed, and so are the values.inf,-.infand.nan. - A key that appears twice in one mapping is
duplicate-key. Keys are compared after quoting is resolved, sofilesand"files"are the same key. - Comments start with
#, as in YAML.//does not start a comment, so JSONC comments are not accepted: one is ordinary text, which usually makes the blockinvalid-yaml. A trailing comma in a flow sequence or flow mapping is allowed, as YAML 1.2 allows it. - Anything else that is not one well-formed YAML 1.2 document, such as a
bad escape, an alias to an anchor that is never defined, or a second
document, is
invalid-yaml. - Mappings and sequences, block or flow, MAY nest up to 100 deep,
counting the block's own value as depth 1, and a tool MUST read them.
A block that nests deeper is
invalid-yaml, at the line where the first mapping or sequence past the limit starts.
A tool checks a block in this order, and reports the first problem it
finds: inconsistent-indentation; then invalid-yaml; then
duplicate-key and yaml-feature-not-allowed, whichever starts first
in the block by character position (a repeated key at its second
occurrence, a feature at its first character); then the checks that the
block's own section defines. The line of a YAML problem is the line,
counted in the file, that holds:
- for
invalid-yaml, the first character at which the block stops being a well-formed document (the alias, for an undefined alias). When the block ends before the document is complete, as with an unclosed flow sequence or quoted string, the line is the block's closing tag line; - for
duplicate-key, the key's second occurrence; - for
yaml-feature-not-allowed, the first feature that is not allowed.
A problem in a file block is a file-level error. A problem in a child element is an entry-level error. In the document model, a block's value is the parsed YAML as JSON.
These YAML rules catch authors out, so each has an example below:
- An unquoted value that starts with a YAML indicator character, such
as
*,&,!,[or{, is not read as plain text:**/*.tsis an alias. Inside a flow sequence, an unquoted value also ends at,and cannot hold[,],{or}, so[src/*.{ts,tsx}]breaks. Quote globs. - In double quotes, a backslash starts an escape, and
"\d"is not a valid one. Write regular expressions in single quotes, where a backslash is an ordinary character. #starts a comment, even in the middle of an unquoted value.- Inside a flow sequence, an unquoted
[starts a nested sequence, so a regular expression with a character class needs quotes.
The same scope, written in JSON in one file and in YAML in another,
gives the same model. In the YAML block sequence, apps/web/**/*.tsx
needs no quotes, while **/*.test.tsx does, since it starts with *:
Example 27 (parse)
<scope>
{ "files": ["apps/web/**/*.tsx"], "ignores": ["**/*.test.tsx"] }
</scope>
<rule id="labels-from-messages" category="accessibility">
Visible labels come from the message catalog, never from string literals.
</rule>
<scope>
files:
- apps/web/**/*.tsx
ignores: ['**/*.test.tsx']
</scope>
<rule id="errors-from-messages" category="accessibility">
Error messages come from the message catalog, never from string literals.
</rule>
{
"entries": [
{
"kind": "rule", "id": "labels-from-messages", "file": ".lore/json.lore",
"category": "accessibility", "severity": "advisory", "disabled": false,
"scopes": [{ "files": ["apps/web/**/*.tsx"], "ignores": ["**/*.test.tsx"] }],
"when": null, "checks": [], "meta": null,
"summary": "Visible labels come from the message catalog, never from string literals.",
"prose": "Visible labels come from the message catalog, never from string literals.",
"src": null,
"sources": []
},
{
"kind": "rule", "id": "errors-from-messages", "file": ".lore/yaml.lore",
"category": "accessibility", "severity": "advisory", "disabled": false,
"scopes": [{ "files": ["apps/web/**/*.tsx"], "ignores": ["**/*.test.tsx"] }],
"when": null, "checks": [], "meta": null,
"summary": "Error messages come from the message catalog, never from string literals.",
"prose": "Error messages come from the message catalog, never from string literals.",
"src": null,
"sources": []
}
],
"errors": [],
"warnings": []
}
An anchor is not allowed, even one that no alias uses. The error is in a child, so only that rule is excluded:
Example 28 (parse)
<rule id="currency-from-settings" category="functional_correctness">
<when>
addedContains: &codes ["'USD'", "'EUR'"]
</when>
Display text never hard-codes a currency code.
</rule>
<rule id="price-from-quote" category="functional_correctness">
A displayed price must come from the quote that produced it.
</rule>
{
"entries": [
{
"kind": "rule", "id": "price-from-quote", "file": ".lore/checkout.lore",
"category": "functional_correctness", "severity": "advisory", "disabled": false,
"scopes": [{ "files": ["**"], "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": []
}
],
"errors": [
{ "name": "yaml-feature-not-allowed", "file": ".lore/checkout.lore", "entry": "currency-from-settings", "line": 3 }
],
"warnings": []
}
A duplicate key is an error in JSON as well as YAML. This one is in a file block, so the whole file is excluded:
Example 29 (parse)
<scope>
{ "files": ["**/*.tsx"], "files": ["**/*.ts"] }
</scope>
<rule id="price-from-quote" category="functional_correctness">
A displayed price must come from the quote that produced it.
</rule>
{
"entries": [],
"errors": [
{ "name": "duplicate-key", "file": ".lore/checkout.lore", "entry": null, "line": 2 }
],
"warnings": []
}
An unquoted glob that starts with * is an alias to an anchor that does
not exist, which is invalid YAML. The quoted glob in the second rule is
read as written:
Example 30 (parse)
<rule id="price-from-quote" category="functional_correctness">
<scope>
files: [**/*.tsx]
</scope>
A displayed price must come from the quote that produced it.
</rule>
<rule id="currency-from-settings" category="functional_correctness">
<scope>
files: ["**/*.tsx"]
</scope>
Display text never hard-codes a currency code.
</rule>
{
"entries": [
{
"kind": "rule", "id": "currency-from-settings", "file": ".lore/checkout.lore",
"category": "functional_correctness", "severity": "advisory", "disabled": false,
"scopes": [{ "files": ["**"], "ignores": [] }, { "files": ["**/*.tsx"], "ignores": [] }],
"when": null, "checks": [], "meta": null,
"summary": "Display text never hard-codes a currency code.",
"prose": "Display text never hard-codes a currency code.",
"src": null,
"sources": []
}
],
"errors": [
{ "name": "invalid-yaml", "file": ".lore/checkout.lore", "entry": "price-from-quote", "line": 3 }
],
"warnings": []
}
\d is not a valid escape in double quotes. In single quotes the
backslash is kept:
Example 31 (parse)
<rule id="price-literals-double" category="functional_correctness">
<when>
addedMatches: ["\d+\.\d{2}"]
</when>
A price is never written as a number literal in display code.
</rule>
<rule id="price-literals-single" category="functional_correctness">
<when>
addedMatches: ['\d+\.\d{2}']
</when>
A price is never written as a number literal in display code.
</rule>
{
"entries": [
{
"kind": "rule", "id": "price-literals-single", "file": ".lore/checkout.lore",
"category": "functional_correctness", "severity": "advisory", "disabled": false,
"scopes": [{ "files": ["**"], "ignores": [] }],
"when": { "addedMatches": ["\\d+\\.\\d{2}"] }, "checks": [], "meta": null,
"summary": "A price is never written as a number literal in display code.",
"prose": "A price is never written as a number literal in display code.",
"src": null,
"sources": []
}
],
"errors": [
{ "name": "invalid-yaml", "file": ".lore/checkout.lore", "entry": "price-literals-double", "line": 3 }
],
"warnings": []
}
A # after a space starts a comment, even inside an unquoted value.
owner loses the rest of its line and the condition looks for TODO
alone. A # with no space before it, as in source, is part of the
value:
Example 32 (parse)
<rule id="no-checkout-todos" category="code_style">
<meta>
owner: checkout #pricing team
source: docs/review.md#todos
</meta>
<when>
addedContains:
- TODO #checkout
</when>
New checkout code carries no `TODO #checkout` markers.
</rule>
{
"entries": [
{
"kind": "rule", "id": "no-checkout-todos", "file": ".lore/checkout.lore",
"category": "code_style", "severity": "advisory", "disabled": false,
"scopes": [{ "files": ["**"], "ignores": [] }],
"when": { "addedContains": ["TODO"] }, "checks": [],
"meta": { "owner": "checkout", "source": "docs/review.md#todos" },
"summary": "New checkout code carries no `TODO #checkout` markers.",
"prose": "New checkout code carries no `TODO #checkout` markers.",
"src": null,
"sources": []
}
],
"errors": [],
"warnings": []
}
Unquoted brackets inside a flow sequence start a nested sequence. In the
first rule, +_PRICE after the nested sequence is invalid YAML. In the
second, [$€£] parses as a list inside the list, and addedMatches
takes only strings (see Conditions), so the block fails
its schema. Quoted, both patterns are read as written:
Example 33 (parse)
<rule id="price-constants-unquoted" category="functional_correctness">
<when>
addedMatches: [[A-Z]+_PRICE]
</when>
Prices come from the quote, never from a module constant.
</rule>
<rule id="currency-symbols-unquoted" category="functional_correctness">
<when>
addedMatches: [[$€£]]
</when>
Display text never hard-codes a currency symbol.
</rule>
<rule id="price-sources-quoted" category="functional_correctness">
<when>
addedMatches: ['[A-Z]+_PRICE', '[$€£]']
</when>
Prices come from the quote, never from a module constant or a literal
with a currency symbol.
</rule>
{
"entries": [
{
"kind": "rule", "id": "price-sources-quoted", "file": ".lore/checkout.lore",
"category": "functional_correctness", "severity": "advisory", "disabled": false,
"scopes": [{ "files": ["**"], "ignores": [] }],
"when": { "addedMatches": ["[A-Z]+_PRICE", "[$€£]"] }, "checks": [], "meta": null,
"summary": "Prices come from the quote, never from a module constant or a literal with a currency symbol.",
"prose": "Prices come from the quote, never from a module constant or a literal\nwith a currency symbol.",
"src": null,
"sources": []
}
],
"errors": [
{ "name": "invalid-yaml", "file": ".lore/checkout.lore", "entry": "price-constants-unquoted", "line": 3 },
{ "name": "invalid-when", "file": ".lore/checkout.lore", "entry": "currency-symbols-unquoted", "line": 9 }
],
"warnings": []
}
A trailing comma is allowed, as in YAML 1.2. A // comment is not: here
it is read as text where the flow mapping expects , or }. A block that
ends before its document is complete is reported at its closing tag
line:
Example 34 (parse)
<scope>
{ "files": ["apps/web/**/*.tsx",] }
</scope>
<rule id="price-from-quote" category="functional_correctness">
A displayed price must come from the quote that produced it.
</rule>
<scope>
{
"files": ["apps/web/**/*.tsx"] // web only
}
</scope>
<rule id="currency-from-settings" category="functional_correctness">
Display text never hard-codes a currency code.
</rule>
<rule id="dates-from-locale" category="functional_correctness">
<scope>
files: ["**/*.tsx"
</scope>
Displayed dates are formatted with the shop's locale.
</rule>
{
"entries": [
{
"kind": "rule", "id": "price-from-quote", "file": ".lore/json.lore",
"category": "functional_correctness", "severity": "advisory", "disabled": false,
"scopes": [{ "files": ["apps/web/**/*.tsx"], "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": []
}
],
"errors": [
{ "name": "invalid-yaml", "file": ".lore/jsonc.lore", "entry": null, "line": 3 },
{ "name": "invalid-yaml", "file": ".lore/unclosed.lore", "entry": "dates-from-locale", "line": 4 }
],
"warnings": []
}
An empty block, or one holding only comments, is an empty mapping. The
empty <scope> leaves the defaults in place:
Example 35 (parse)
<scope>
</scope>
<rule id="price-from-quote" category="functional_correctness">
<meta>
# owner to be decided
</meta>
A displayed price must come from the quote that produced it.
</rule>
{
"entries": [
{
"kind": "rule", "id": "price-from-quote", "file": ".lore/checkout.lore",
"category": "functional_correctness", "severity": "advisory", "disabled": false,
"scopes": [{ "files": ["**"], "ignores": [] }],
"when": null, "checks": [], "meta": {},
"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": []
}
],
"errors": [],
"warnings": []
}
The core schema reads yes and off as strings, not booleans. A key
that is not a string is not allowed:
Example 36 (parse)
<rule id="price-from-quote" category="functional_correctness">
<meta>
reviewed: yes
legacy: off
enforced: true
owner: ~
since: 2026
</meta>
A displayed price must come from the quote that produced it.
</rule>
<rule id="currency-from-settings" category="functional_correctness">
<meta>
2026: reviewed
</meta>
Display text never hard-codes a currency code.
</rule>
{
"entries": [
{
"kind": "rule", "id": "price-from-quote", "file": ".lore/checkout.lore",
"category": "functional_correctness", "severity": "advisory", "disabled": false,
"scopes": [{ "files": ["**"], "ignores": [] }],
"when": null, "checks": [],
"meta": { "reviewed": "yes", "legacy": "off", "enforced": true, "owner": null, "since": 2026 },
"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": []
}
],
"errors": [
{ "name": "yaml-feature-not-allowed", "file": ".lore/checkout.lore", "entry": "currency-from-settings", "line": 14 }
],
"warnings": []
}
The mapping is depth 1 and each [ one more, so the first rule nests
100 deep and the second 101:
Example 37 (parse)
<rule id="team-tree-at-limit" category="documentation">
<meta>
teams: [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
</meta>
Metadata nested 100 deep is read.
</rule>
<rule id="team-tree-past-limit" category="documentation">
<meta>
teams: [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
</meta>
Metadata nested 101 deep is not.
</rule>
{
"entries": [
{
"kind": "rule", "id": "team-tree-at-limit", "file": ".lore/teams.lore",
"category": "documentation", "severity": "advisory", "disabled": false,
"scopes": [{ "files": ["**"], "ignores": [] }],
"when": null, "checks": [],
"meta": { "teams": [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]] },
"summary": "Metadata nested 100 deep is read.",
"prose": "Metadata nested 100 deep is read.",
"src": null,
"sources": []
}
],
"errors": [
{ "name": "invalid-yaml", "file": ".lore/teams.lore", "entry": "team-tree-past-limit", "line": 10 }
],
"warnings": []
}