Skip to content
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

vue/no-setup-props-destructure should trigger when prop is passed to function #2092

Closed
henribru opened this issue Feb 27, 2023 · 1 comment · Fixed by #2244
Closed

vue/no-setup-props-destructure should trigger when prop is passed to function #2092

henribru opened this issue Feb 27, 2023 · 1 comment · Fixed by #2244

Comments

@henribru
Copy link

henribru commented Feb 27, 2023

What rule do you want to change?
vue/no-setup-props-destructure
Does this change cause the rule to produce more or fewer warnings?
More.
How will the change be implemented? (New option, new default behavior, etc.)?
Perhaps an option that defaults to false would be best for backwards compatibility, though arguably it's more correct for it to be the default behavior.
Please provide some example code that this change will affect:

<script setup>
const props = defineProps(["foo"]);

function foo(bar) {};

foo(props.foo);
</script>

What does the rule currently do for this code?
Nothing.
What will the rule do after it's changed?
Flag it as a loss of reactivity. It should be foo(toRef(props, "foo")) or foo(computed(() => props.foo)) instead.
Additional context

The rule already flags code like const foo = props.foo. Passing it to a function incurs the same loss of reactivity, so it seems consistent to flag that as well. Note also that vue/no-ref-object-destructure already flags something like foo(bar.value) and that seems like an analogous case.

@FloEdelmann FloEdelmann changed the title vue/no-setup-props-destructure should trigger when prop is passed to function vue/no-setup-props-destructure should trigger when prop is passed to function Feb 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants