~james/core

core/web/scripts/staleAwait.ts -rw-r--r-- 541 bytes
452f17b7 — james chore(import): snapshot james.dad.town/core at f70c71c7696a 14 hours ago
                                                                                
1
2
3
4
5
6
7
8
9
// a settled promise runs {:then} in its own batch, which sees the old data and page while a navigation lands
const readsRouteState =
	"Identifier[name=/^(data|page)$/]:not(MemberExpression > Identifier.property, Property > Identifier.key)";

export const staleAwait = ["Pending", "Then", "Catch"].map((branch) => ({
	selector: `SvelteAwait${branch}Block:has(${readsRouteState})`,
	message:
		"{#await} branches can run before a navigation lands, seeing the old data and page. await in a <Pending> instead: {@const value = await ...}."
}));