palantir / tslint-react

:orange_book: Lint rules related to React & JSX for TSLint.
Apache License 2.0
749 stars 76 forks source link

Improve "jsx-no-lambda" rule detection #29

Closed no23reason closed 7 years ago

no23reason commented 8 years ago

This rule is reporting false positives in situations where the lambda is used as a parameter to a function returning some value. For example:

interface Item { value: number; }

<Currency amount={ _.sumBy(items, (item: Item) => item.value) } />

This usage does not have any negative implications with regards to the shallowCompare render optimisation as the lambda is never actually compared.

I am aware that simple workaround would often be to compute the value into a variable and then use it like this:

interface Item { value: number; }

const total = _.sumBy(items, (item: Item) => item.value);
<Currency amount={ total } />

However, that seems tedious and unnecessary.

jkillian commented 8 years ago

👍 Seems like a reasonable enhancement @no23reason