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

Fix: Don't report async/generator callbacks in array-callback-return #7172

Merged
merged 1 commit into from Sep 19, 2016

Conversation

not-an-aardvark
Copy link
Member

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

[ ] Documentation update
[x] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofixing to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:

Please check each item to ensure your pull request is ready:

  • I've read the pull request guide
  • I've included tests for my change
  • I've updated documentation for my change (if appropriate)

What changes did you make? (Give an overview)

See #7101 for context. This is one of the rule fixes that prevents incorrect behavior now that we can support async functions.

This fix updates array-callback-return to not report async callback functions, since async functions implicitly return a Promise value.

/* eslint array-callback-return: 2 */
foo.map(async function () {}) // should not return an error
foo.map(async () => {}) // should not return an error

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

Nothing in particular.

@mention-bot
Copy link

@not-an-aardvark, thanks for your PR! By analyzing the annotation information on this pull request, we identified @vitorbal, @mysticatea and @kaicataldo to be potential reviewers

@eslintbot
Copy link

LGTM

@mysticatea mysticatea added enhancement This change enhances an existing feature of ESLint rule Relates to ESLint's core rules evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels Sep 17, 2016
@mysticatea mysticatea self-assigned this Sep 17, 2016
@mysticatea mysticatea removed enhancement This change enhances an existing feature of ESLint evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion rule Relates to ESLint's core rules labels Sep 17, 2016
@mysticatea
Copy link
Member

mysticatea commented Sep 17, 2016

Thank you!

I was hovering between a bug and an enhancement.
But indeed, async functions and generators have implicit returned values. I think this is like a bug.

@not-an-aardvark in addition, could you add the check for generators as same?

@eslintbot
Copy link

LGTM

@not-an-aardvark not-an-aardvark changed the title Fix: Don't report async callback functions in array-callback-return Fix: Don't report async/generator callbacks in array-callback-return Sep 17, 2016
@not-an-aardvark
Copy link
Member Author

Added a check for generator functions.

@not-an-aardvark
Copy link
Member Author

I'm going to rebase all my PRs onto master so that the tests pass (sorry about the spammy "LGTM" messages).

@eslintbot
Copy link

LGTM

@mysticatea mysticatea removed their assignment Sep 17, 2016
@mysticatea mysticatea added bug ESLint is working incorrectly rule Relates to ESLint's core rules accepted There is consensus among the team that this change meets the criteria for inclusion labels Sep 17, 2016
Copy link
Member

@mysticatea mysticatea left a comment

Choose a reason for hiding this comment

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

LGTM, thank you!

Copy link
Member

@platinumazure platinumazure left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@nzakas nzakas merged commit f71937a into eslint:master Sep 19, 2016
@not-an-aardvark not-an-aardvark deleted the array-callback-return-async branch September 19, 2016 18:23
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 6, 2018
@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 Feb 6, 2018
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 bug ESLint is working incorrectly rule Relates to ESLint's core rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants