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

Rule proposal: vue/no-direct-ref-in-watch #2657

Open
Revadike opened this issue Dec 21, 2024 · 0 comments
Open

Rule proposal: vue/no-direct-ref-in-watch #2657

Revadike opened this issue Dec 21, 2024 · 0 comments

Comments

@Revadike
Copy link

Please describe what the rule should do:
This rule should enforce the use of arrow functions for dependencies in the watch function in Vue 3. Instead of directly passing a ref or variable, the rule should ensure that developers use a function returning the reactive value. This will help avoid potential issues with reactive tracking and align with best practices.

What category should the rule belong to?
[ ] Enforces code style (layout)
[ ] Warns about a potential error (problem)
[X] Suggests an alternate way of doing something (suggestion)
[ ] Other (please specify:)

Provide 2-3 code examples that this rule should warn about:

// Incorrect usage (should warn)
watch(myVar, handler)

// Correct usage
watch(() => myVar.value, handler)

Additional context
This rule would provide clear guidance for writing more consistent and reliable watch expressions in Vue 3.

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

No branches or pull requests

1 participant