-
Notifications
You must be signed in to change notification settings - Fork 65
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
prefer-map incorrectly states that _.map could be used instead of _.forEach #92
Comments
The better question is if there's a better data structure that doesn't require iteration and mutation. |
Well, it's a different question, I don't know if it's 'better'. I agree that it's not particularly nice code, but this still looks like a bug to me. Is the rule really looking at that line and determining that perhaps a refactor of the data structures is in order? I would guess not, I would guess it's doing some relatively basic static analysis and concluding that this can be easily swapped to _.map, which is incorrect. |
I agree that this looks like a bug. |
@facboy yeah, apologies. I agree it's a bug. |
Yes, the |
It does appear to be the case. xs = _.map(xs, (x, i) => _.assign({}, x, {data: x.data.concat([other[i]])})) But that's not particularly nicer. Would you suggest we refine the rule? Do you think it's necessary for it to make sure the |
I think the only additional limitation we would need to add, would be to ensure that push is not being called on the first ( |
For the following
I get this output:
I'm pretty certain this is incorrect.
The text was updated successfully, but these errors were encountered: