Open
Description
Motivation
If you use the .update(...)
method on a writable store and don't explicitly return a value the store will be set to undefined
. That might be on purpose, but I'm willing to bet that more often than not it's accidental.
Description
The rule should look for .update()
calls that match the signature of writable.update()
and ensure that all code paths return some value. Doesn't have to the be the original value or anything specific, I just think being able to require the usage of return <thing>;
to make it really explicit that a value is being set would be useful and prevent errors.
Examples
<script>
const store = writable(false);
// ✓ GOOD
store.update(($store) => true);
store.update(($store) => {
return true;
});
store.update(($store) => {
if(foo) {
// ...
return bar;
}
return true;
});
// ✗ BAD
store.update(($store) => {
// ...
});
store.update(($store) => {
if(foo) {
// ...
return bar;
}
});
</script>
Additional comments
No response