list-invariant
A list marked /** @sorted */ whose elements are out of order, or a list marked /** @unique */ that names an element twice; and either tag where the checker can't verify it.
Why: a list that must stay sorted (a merge order, a hash input, a list searched by bisection) or free of repeats usually says so only in a comment. Adding at the end is what an agent does, and what a merge does when two branches each add one. An adopter's list of encoding features had to stay sorted, said so in a comment, and still got marchTogether after pub. The tag states the rule where the checker verifies it, on every run. Guide: Enums.
✕ Rejectedlist-invariant
ts
/**
* Encoding features: each one adds a field to a snapshot, in this order.
* @sorted @unique
*/
export const FEATURES = Object.freeze(["library", "pub", "marchTogether", "scoutResume"]);text
"marchTogether" is out of order in `FEATURES`, which is `@sorted`: it comes after "pub"
help: Move it to its sorted place: between "library" and "pub". ...✓ Accepted0 diagnostics
ts
/**
* Encoding features: each one adds a field to a snapshot, in this order.
* @sorted @unique
*/
export const FEATURES = Object.freeze(["library", "marchTogether", "pub", "scoutResume"]);What counts
- Where: the tag goes in the comment right before a module-level
const(exported or not). The comment may hold other text and other tags. The value is an array literal that nothing can change afterwards:[...] as constorObject.freeze([...]), also with a type annotation (const X: readonly string[] = Object.freeze([...])). A plain[...]is reported, since code could sort or push to it after the check. - What: string literals or number literals, not both. Comments between the elements are fine.
@sortedis ascending: numbers by value, strings assort()orders them, by UTF-16 code units ("Zed"before"alpha"). Equal neighbours are fine; add@uniqueto forbid them. The first element out of order is reported, with the place it belongs.@uniquereports the second of two equal elements. On a code table (anas constor frozen object),@uniquemeans its values are all different, andduplicate-code-valuereports two that aren't.
What the rule can't see
A list built at run time (names.toSorted(), a spread of another list) has no literal elements to check, so the tag is reported there. Sort it once where it is declared, or check it in a test.