Skip to content
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

Rule against redundant closures #1169

Closed
not-my-profile opened this issue Jun 16, 2023 · 2 comments
Closed

Rule against redundant closures #1169

not-my-profile opened this issue Jun 16, 2023 · 2 comments

Comments

@not-my-profile
Copy link
Contributor

E.g. invalid:

xs.map(x => foo(x))

Valid:

xs.map(foo)
@magurotuna
Copy link
Member

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.

@not-my-profile
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants