mirror of
https://github.com/Unleash/unleash.git
synced 2026-09-09 21:55:55 +00:00
5ff54da9a5
`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.
10 lines
608 B
Plaintext
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")
|
|
}
|