-
-
Notifications
You must be signed in to change notification settings - Fork 679
False positive in vue/no-side-effects-in-computed-properties #420
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
Comments
Since we check all CallExpressions, I think the most simple and not too strict solution would be to just strip content of any call expression arguments in chain and perform regex check on the reduced code. |
Also triggers on copied arrays (ES6 spread operator):
|
It should not warn if I loop over an array like |
I am not sure if I should open an new issue, or maybe I don't understand how it should work, but I think there is another false positive for this rule. I want to emit a computed value containing an array of objects and each object will have a method on it, which yes, mutates the local state. But the method is not executed in the computed evaluation, it is just another property on the object.
|
Tell us about your environment
Node v9.3.0
eslint-plugin-vue v
Please show your full configuration:
What did you do? Please include the actual source code causing the issue.
What did you expect to happen?
This function takes an array of types, each of which has a category property, and returns an array of categories, each of which has an array of types within that category.
This function is appropriate as a computed function as it does not modify
this.types
.What actually happened? Please include the actual, raw output from ESLint.
The issue is with line 7 from the snippet:
categories[c.category].push(c)
. The regex forno-side-effects-in-computed-properties
catches ANY use ofpush
, even if it's on unrelated arrays. It even catchespush
calls within comments, for instance:I'm not certain what an appropriate fix is for this. Perhaps it should try to verify that the array being modified is not within the scope of the computed function?
The text was updated successfully, but these errors were encountered: