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

enforce usage of 'const' or trigger error when reassigning reactive value #2419

Open
andredewaard opened this issue Mar 5, 2024 · 0 comments

Comments

@andredewaard
Copy link

Please describe what the rule should do:

Whenever someone wants to use reactive over ref for whatever reason it is really easy to lose reactivity on that object since you can just reassign the value. Enforcing the usage of 'const' or show a message that you can't do just, just like you get an warning when reassigning a ref value without .value.

What category should the rule belong to?

[X] Enforces code style (layout)
[ ] Warns about a potential error (problem)
[ ] Suggests an alternate way of doing something (suggestion)
[ ] Other (please specify:)

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

let data = reactive({}) // reactive assign only on const
data = {} // no error, but will lose reactivity. should throw error that this isn't possible.

// Example of enforcing this on .value which already works.
let test1 = ref({}) 
test1 = {} // Must use `.value` to read or write the value wrapped by 
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