ESLint rule for Best practice: Moving signal reads to useTask$ or useComputed$ #342
DmitryEfimenko
started this conversation in
Proposals For Qwik
Replies: 1 comment
-
|
I think it's good point. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
What is it about?
Create Qwik ESLint rule to enforce best practices
What's the motivation for this proposal?
Problems you are trying to solve:
Goals you are trying to achieve:
Any other context or information you want to share:
Documentation best practices have the following section: Moving signal reads to useTask$ or useComputed$.
It would be good if there was a Qwik ESLint rule enforcing this best practice.
Proposed Solution / Feature
What do you propose?
Create a Qwik linting rule that highlights usages of derived state, which is defined at the component level rather than with the usage of useTask$ or useComputed$
Code examples
This should throw linting error/warning:
This should also throw linting error/warning:
Side note: in case of
useSignal, the type ofcountisSignal<number>. However, in case ofuseStore, the type ofstateis simply the state object shape - so:{ count: number; name: string }. This type does not indicate in any way that state is reactive. This certainly brings a bit of traction to the dev experience - it adds cognitive load to the dev having to remember this. It also might or might not play a part in the complexity of writing the ESLint rule - not sure about that one.Links / References
https://qwik.dev/docs/guides/best-practices/#moving-signal-reads-to-usetask-or-usecomputed
Beta Was this translation helpful? Give feedback.
All reactions