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

Update: Array.prototype.flatMap in array-callback-return (fixes #12235) #12267

Closed
wants to merge 1 commit into from

Conversation

mdjermanovic
Copy link
Member

What is the purpose of this pull request? (put an "X" next to item)

[X] Changes an existing rule #12235

This PR adds Array.prototype.flatMap to the list of targeted methods in array-callback-return, but only when ecmaVersion is set to 2019 or higher, in order to minimize potential breaking change impact.

This can produce more errors by default (for an ecmaVersion >= 2019 configuration only).

What changes did you make? (Give an overview)

Added flatMap to the pattern if ecmaVersion >= 10.

Also fixed two links in the documentation.

Is there anything you'd like reviewers to focus on?

Would be probably more correct to check enabled environments instead of the ecmaVersion, but that isn't possible at the moment as far as I know.

The diff looks big, most of it is just copy & paste to a different location.

@eslint-deprecated eslint-deprecated bot added the triage An ESLint team member will look at this issue soon label Sep 13, 2019
@@ -20,14 +20,17 @@ This rule finds callback functions of the following methods, then checks usage o
* [`Array.prototype.every`](https://www.ecma-international.org/ecma-262/6.0/#sec-array.prototype.every)
* [`Array.prototype.filter`](https://www.ecma-international.org/ecma-262/6.0/#sec-array.prototype.filter)
* [`Array.prototype.find`](https://www.ecma-international.org/ecma-262/6.0/#sec-array.prototype.find)
* [`Array.prototype.findIndex`](https://www.ecma-international.org/ecma-262/6.0/#sec-array.prototype.findIndex )
* [`Array.prototype.findIndex`](https://www.ecma-international.org/ecma-262/6.0/#sec-array.prototype.findindex )
Copy link
Sponsor Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as a side note, all of these links shouldn't be to the always-obsolete snapshots on ecma-international.org, but rather to the only correct version of the spec, https://tc39.es/ecma262/

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to fix the links in another PR, as two of them are partially broken (wrong #).

I understand that https://tc39.es/ecma262/ link represents the actual version much more than a draft, but it's officially still a draft? Also, it has the Draft word in the title, so I'm not sure is it OK to use this link, or just fix the links to ES2015. Or maybe change all links to ES2019.

Copy link
Sponsor Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It’s a living standard; whatever’s on github is always the latest version.

@mysticatea
Copy link
Member

Thank you for contribution. But I'd like to defer to merge as a breaking change until 7.0.0. Because [1, 2, 3].flatMap(() => {}) is not runtime errors and it can break user's builds.

@ljharb
Copy link
Sponsor Contributor

ljharb commented Sep 13, 2019

Can it be added behind an option now, and then turned on by default in v7?

@mysticatea mysticatea added this to Memorandum in v7.0.0 Sep 13, 2019
@mdjermanovic mdjermanovic added the breaking This change is backwards-incompatible label Sep 13, 2019
@mysticatea
Copy link
Member

I'm not a big fan of adding an option for only flagMap. This is similar to waiting for the rest change of #11803 until 7.0.0.

@platinumazure
Copy link
Member

As a side note, I would be interested in seeing if we could do a 7.0.0 release soon. It would be nice to get into the habit of doing smaller, more frequent major releases. But I know some users already struggle to do major version upgrades even if we do them infrequently...

@mdjermanovic
Copy link
Member Author

Just a thought, perhaps the rule could have an option - array of additional method names. That would avoid similar problems in the future.

Albeit, that could turn this rule into a generic configurable "callback-return" rule, so I'm not sure if this is a good idea.

@ljharb
Copy link
Sponsor Contributor

ljharb commented Sep 13, 2019

More frequent majors is a heavy burden on shared configs and plugins.

@mysticatea mysticatea moved this from Memorandum to Needs discussion in v7.0.0 Nov 7, 2019
@mysticatea mysticatea moved this from Needs discussion to Implemented, pending review in v7.0.0 Nov 7, 2019
@mdjermanovic
Copy link
Member Author

For v7.0.0, is there a need to check ecmaVersion >= 10? This was intended to decrease the breaking impact in a semver-minor version, but adds some complexity to the code.

As a similar thing, there is no ecmaVersion >= 6 check for find and findIndex

@platinumazure
Copy link
Member

I agree there is probably no need to check ecmaVersion if we just label this as breaking and add it in 7.0.0.

@kaicataldo kaicataldo added accepted There is consensus among the team that this change meets the criteria for inclusion bug ESLint is working incorrectly rule Relates to ESLint's core rules and removed triage An ESLint team member will look at this issue soon bug ESLint is working incorrectly labels Dec 20, 2019
@mdjermanovic mdjermanovic added the do not merge This pull request should not be merged yet label Dec 21, 2019
@kaicataldo kaicataldo removed the do not merge This pull request should not be merged yet label Dec 23, 2019
@mdjermanovic
Copy link
Member Author

@kaicataldo I added 'do not merge' because this needs to be changed if there is no need to check ecmaVersion. Sorry, I should have left a note.

@kaicataldo
Copy link
Member

Ah, sorry! I should have asked. I was removing "do not merge" labels from "breaking" changes because we're now able to merge semver-major PRs in preparing for our first v7 alpha release.

@mdjermanovic mdjermanovic added the do not merge This pull request should not be merged yet label Dec 23, 2019
@mdjermanovic
Copy link
Member Author

mdjermanovic commented Jan 9, 2020

Closing this in favor of #12765.

It seemed much easier to just make a new PR in this case.

@mysticatea mysticatea removed this from Implemented, pending review in v7.0.0 Jan 14, 2020
@mdjermanovic mdjermanovic deleted the issue12235 branch January 18, 2020 04:46
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Jul 9, 2020
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Jul 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion breaking This change is backwards-incompatible do not merge This pull request should not be merged yet rule Relates to ESLint's core rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants