Block using state
in event handlers when state
is set via binding on same element as event handler
#921
Labels
state
in event handlers when state
is set via binding on same element as event handler
#921
Motivation
In some cases, using
bind:value
orbind:checked
or similar bindings of state in Svelte 5.0 alongside event handlers that access the same state can result in unexpected behavior (e.g. seeing old values in the event handler and not the latest from the binding).This rule should help prevent code like this.
Description
The rule should detect any state that is bound to an element state, e.g.
bind:this
,bind:checked
,bind:value
, etc. and also accessed inside an event listeningonchange
,onkeyup
, etc. explaining that such a value may not be up to date.Examples
Additional comments
I am happy to consider implementing this rule myself.
The text was updated successfully, but these errors were encountered: