Replies: 2 comments 2 replies
-
It could also be an ESLint rule that checks that a composable is destructured. The real source of the problem is calling the composable directly in an expression |
Beta Was this translation helpful? Give feedback.
1 reply
-
these lint rules could help catch related issues:
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
I recently came across some Problems in a larger Code Base, that went unnoticed for quite some time.
Vue3 supports unpacking computed properties in some contexts within its templates, but there are plenty of places where you need to unpack the value. I do unterstand the technical need for that and do not object to that.
My concern is about the errors that come frome that, and how easy it currently is to miss them.
Especially when comparing/checking computed values, missing the value unpacking happens easily.
Example:
Here, the comparison looks good on first glance, but you have to know that useExample returns a computed prop to see it's actually wrong.
My proposition would be, to add a compiler option, that throws warnings on comparisons of computed properties, when they are not unpacked, if they are not explicitly annotated with a comment, something like "compare-computed-container"
At least for me, 99.99% of times I compare a Computed, I want the comparison done to the underlying value.
This compiler option would help spot those mistakes, while making the code more explicit in the rare cases, where you actually do want to compare the computed itself.
Beta Was this translation helpful? Give feedback.
All reactions