Standard: Arrow function should not return assignment

Created on 21 Jun 2016  路  3Comments  路  Source: standard/standard

Hello!

Just switched to standard with our team. Loving the simplicity!
I do have one question.

Can you somehow hide the Arrow function should not return assignment error?
I feel like it should not be an error.

I love the simplicity of
tags.map(tag => tag.name = text.text)

Cheers

Most helpful comment

I think it's very good, since it can be used to avoid confusion when you missed one of the =, e.g.

tags.filter(tag => tag.name = text.text)

All 3 comments

I think it's very good, since it can be used to avoid confusion when you missed one of the =, e.g.

tags.filter(tag => tag.name = text.text)

And I believe you can just signal that you really meant an assignment by wrapping in parenthesis:

tags.filter(tag => (tag.name = text.text))

As pointed out by @dougwilson, this error is easily averted in a quite aesthetically pleasing way, especially given the safety net it provides as pointed out by @LinusU.

Closing, but don't let that end the conversation if you feel otherwise :+1:

Was this page helpful?
0 / 5 - 0 ratings