Find useless ternary operator

JavaScript pattern

If $condition ? $answer:$answer then this expression returns $answer. This is probably a human error.


Apply with the Grit CLI
grit apply useless_ternary_operator

<></>React.Fragment

BEFORE
data === "value" ? `/r/${data.id}` : `/r/${data.id}`


data === "value" ? `/r/${data.id}` : `/r/${data.name}`
AFTER
data === "value" ? `/r/${data.id}` : `/r/${data.id}` //useless-ternary operator both result are sanme


data === "value" ? `/r/${data.id}` : `/r/${data.name}`