-
-
Notifications
You must be signed in to change notification settings - Fork 693
Fix no-ref-as-operand and allow lint when ref as right operator #2273
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Thanks for this PR.
However, I think that this PR change has caused false positives in the following usages.
<script setup lang="ts"> import { ref, Ref } from 'vue' const refValue1: Ref<number> = ref(0) const maybeRefValue: Ref<number> | null = getMaybeRef() const refValue2 = maybeRefValue || refValue1 console.log(refValue2.value) </script>
I think we should keep track of how the result of the expression is used.
Also, I think the ternary operator could be improved if it would be possible to track the usage of the result of the expression.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
grindpride
commented
Sep 24, 2024
@ota-meshi @lakb248
Maybe put the logic for this rule in a separate no-ref-as-operand-strict
rule, or customize with a parameter (strictCheck
) of the current one?
In my code there are no cases of the following type
const refValue1: Ref<number> = ref(0) const maybeRefValue: Ref<number> | null = getMaybeRef() const refValue2 = maybeRefValue || refValue1
But errors with such case use are often encountered
const refValue1: Ref<number> = ref(0) if (refValue1) { //incorrect condition }
fix #2271