Closed not-my-profile closed 1 year ago
This seems more difficult for me than it seems to be, because for example the following two examples behave differently:
['10', '10', '10'].map(parseInt);
// [ 10, NaN, 2 ]
['10', '10', '10'].map((x) => parseInt(x));
// [ 10, 10, 10 ]
I'd say 99.9% of the cases what people want to do is the second one, not first one. Also the linter should not suggest the change that affects the code behavior in runtime. So the linter would need to be smart enough to consider the second example to be not redundant - this sounds really hard.
Ah, very good call! (explanation for others wondering what's happening).
You're right, doing this reliably would require type awareness, which is currently blocked as explained in #1138 ... so I'm closing this for now.
E.g. invalid:
Valid: