Files
unleash/tracking-shape.grit
Gergo Kekesi 5ff54da9a5 refactor(tracking): useTracking returns one callable per journey
`useTracking` now returns a callable tracker, so a call site holds one
named function per journey: `trackX(action)`, `trackX.mutation(fn)`,
`trackX.validationFailed()`. Every call site is converted; the old
object return let callers choose between destructuring, holding, and
renaming, which produced four shapes in a single PR when I was working
with Claude. This rule will now be enforced and will be easy to follow.

A Biome GritQL rule (`oss/tracking-shape.grit`) rejects destructuring
the return value, so the shape is enforced by lint rather than review.
2026-09-09 10:20:56 +01:00

10 lines
608 B
Plaintext

language js
// useTracking returns one callable tracker per journey. Destructuring it reintroduces
// bare `track`/`trackMutation` bindings and the four call-site shapes the callable removed.
// The binding is matched by text: a plain name is fine, anything else is a pattern.
`const $binding = useTracking($args)` as $match where {
not $binding <: r"^[\w$]+$",
register_diagnostic(span=$match, message="useTracking returns one callable per journey. Hold it as `const trackX = useTracking(xTracking)`; call `trackX(action)`, `trackX.mutation(fn)`, `trackX.validationFailed()`.", severity="error")
}