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

Do not warn if .flat() has more than one parameter or if the one parameter is not 1 #317

Merged
merged 4 commits into from
Jun 10, 2019

Conversation

MrHen
Copy link
Contributor

@MrHen MrHen commented Jun 4, 2019

Fixes #315.

A follow up question is if we should warn / fix on .flat(1) which is default flattening behavior but I wanted to get the fix out quickly.

@sindresorhus
Copy link
Owner

Yes, we should report and fix .flat(1).

@fisker
Copy link
Collaborator

fisker commented Jun 4, 2019

and also undefined ? maybe also "1"?

according to , https://tc39.github.io/proposal-flatMap/#sec-Array.prototype.flat

Any value can ToInteger equals to 1, all the same

@sindresorhus
Copy link
Owner

@fisker Nah. No one would actually pass in that. Not worth caring about.

@fisker
Copy link
Collaborator

fisker commented Jun 4, 2019

make sense

@fisker
Copy link
Collaborator

fisker commented Jun 4, 2019

on second thought, most people also not pass 1, how about not check arguments at all, instead maybe make a new rule to check flat argument ?

@MrHen MrHen requested a review from sindresorhus June 4, 2019 23:08
@sindresorhus
Copy link
Owner

on second thought, most people also not pass 1, how about not check arguments at all, instead maybe make a new rule to check flat argument ?

A rule that checks arguments for built-ins in general sounds useful, but would be very fragile without type information. Better to just use TypeScript then.

@sindresorhus sindresorhus changed the title Do not warn if .flat() has a parameter Do not warn if .flat() has more than one parameter or if the one parameter is not 1 Jun 10, 2019
@sindresorhus sindresorhus merged commit 6f10722 into sindresorhus:master Jun 10, 2019
@MrHen MrHen deleted the bug/315-Flat-Parameters branch June 10, 2019 16:04
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

Successfully merging this pull request may close these issues.

prefer-flat-map fixer bug
3 participants