U04
Warning
Declared and never read
U04 — A store member nothing reads
A store's state, derived value or action that nothing reads, inside the store or as Store.member.
What the compiler said
warning[U04]: `Cart.coupon` is declared but never read --> src/App.wf:3:5 | 3 | state coupon = "" | ^^^^^ = help: Nothing reads the state, inside the store or as `Cart.coupon`; remove it, or name it `_coupon` to keep it = docs: https://webfluent.monzeromer.dev/errors/U04
Your editor offers this fix: Remove Cart.coupon. wf fix --code U04 applies it to every place it fits.
The fix
Broken
store Cart {
state items: [String] = []
state coupon = ""
}
page P(path: "/", title: "T", description: "D") {
use Cart
Heading("{Cart.items.length}").h1
}
Fixed
store Cart {
state items: [String] = []
}
page P(path: "/", title: "T", description: "D") {
use Cart
Heading("{Cart.items.length}").h1
}
Remove the member, or name it with a leading _.
Each example is a whole program: it is all of src/App.wf in a project with no other .wf file (trying an example).
lints may lower it:
"lints": { "U04": "off" }
// wf-allow(U04)