Files and folders
A Lore file is a file whose name ends in .lore and that sits inside
a Lore folder, directly or in a subfolder. A Lore folder MAY sit in any
directory of a repository.
- The base of a Lore file is the directory that contains the first Lore folder on its path, counted from the repository root. Subfolders inside a Lore folder group files and change nothing, including the base.
- A file whose name ends in
.lorebut that is not inside a Lore folder is not a Lore file, and a tool MUST NOT collect it. Files in a Lore folder whose names do not end in.loreare not Lore files either, and a tool MUST ignore them. - A set of entries MAY be one file or many. A tool MUST NOT give the split any meaning, except that a file block applies only to the file it is in.
- Which Lore files a tool collects is defined in Collecting files.
A Lore file is UTF-8 text. A tool MUST ignore a byte order mark at the
start of a file, and MUST treat a carriage return directly before a line
feed as part of the line break. A file that is not valid UTF-8 is
unreadable-structure, a file-level error at the line of the first
invalid byte.
The smallest useful Lore file holds one rule. Its prose's first paragraph is its summary, with the paragraph's lines joined by spaces:
Example 1 (parse)
<rule id="price-from-quote" category="functional_correctness" severity="blocking">
A displayed price must come from the quote
that produced it.
Recomputing a price from its inputs drops quote-level discounts, so the
customer sees one total and is charged another.
</rule>
{
"entries": [
{
"kind": "rule", "id": "price-from-quote", "file": ".lore/checkout.lore",
"category": "functional_correctness", "severity": "blocking", "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\nthat produced it.\n\nRecomputing a price from its inputs drops quote-level discounts, so the\ncustomer sees one total and is charged another.",
"src": null,
"sources": []
}
],
"errors": [],
"warnings": []
}
A subfolder inside a Lore folder does not move the base. These globs
resolve from apps/web/src/checkout/, the directory that contains the
Lore folder, not from the pricing/ subfolder:
Example 2 (parse)
<scope>
files: ["**/*.tsx"]
ignores: ["**/*.test.tsx"]
</scope>
<rule id="quote-expiry-shown" category="functional_correctness">
A checkout page that shows a quoted price also shows when the quote
expires.
</rule>
{
"entries": [
{
"kind": "rule", "id": "quote-expiry-shown", "file": "apps/web/src/checkout/.lore/pricing/quotes.lore",
"category": "functional_correctness", "severity": "advisory", "disabled": false,
"scopes": [{ "files": ["apps/web/src/checkout/**/*.tsx"], "ignores": ["apps/web/src/checkout/**/*.test.tsx"] }],
"when": null, "checks": [], "meta": null,
"summary": "A checkout page that shows a quoted price also shows when the quote expires.",
"prose": "A checkout page that shows a quoted price also shows when the quote\nexpires.",
"src": null,
"sources": []
}
],
"errors": [],
"warnings": []
}
A .lore file outside any Lore folder is not collected, and neither is a
file in a Lore folder without the .lore extension. Only the rule in
.lore/checkout.lore is eligible:
Example 3 (eligibility)
<rule id="price-from-quote" category="functional_correctness">
A displayed price must come from the quote that produced it.
</rule>
<rule id="readme-rule" category="documentation">
This file is not a Lore file.
</rule>
<rule id="totals-from-quote" category="functional_correctness">
Cart totals come from the quote, never from summing line items.
</rule>
M apps/web/src/checkout/CartTotal.tsx
+42 const total = items.reduce((sum, item) => sum + item.price, 0)
{ "eligible": ["price-from-quote"], "hits": [], "excluded": [], "warnings": [] }
This file starts with a byte order mark (U+FEFF). A tool ignores it, so the opening tag after it is still at column 0:
Example 4 (parse)
<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": [],
"warnings": []
}