Enable the ESLint no-return-await call to avoid intermediate promise creation.

RESOLVED FIXED in Firefox 56

Status

()

Toolkit
General
RESOLVED FIXED
4 months ago
4 months ago

People

(Reporter: standard8, Assigned: standard8)

Tracking

Trunk
mozilla56
Points:
---

Firefox Tracking Flags

(firefox56 fixed)

Details

MozReview Requests

()

Submitter Diff Changes Open Issues Last Updated
Loading...
Error loading review requests:

Attachments

(1 attachment)

(Assignee)

Description

4 months ago
Using `return await` in async functions is unnecessary since the return value is automatically wrapped in Promise.resolve(), and worst case we'd effectively be wrapping the return with a second promise.

xref: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/async_function#Rewriting_a_promise_chain_with_an_async_function

We should therefore turn on the `no-return-await` rule for ESLint to avoid this happening and fix the existing instances.
Comment hidden (mozreview-request)

Comment 2

4 months ago
mozreview-review
Comment on attachment 8885471 [details]
Bug 1380009 - Enable the ESLint no-return-await call to avoid unnecessary intermediate promise creation.

https://reviewboard.mozilla.org/r/156324/#review161468

::: browser/components/preferences/in-content-new/applications.js:2090
(Diff revision 1)
>     *          an integer
>     * @returns the Desktop folder if aIndex == 0,
>     *          the Downloads folder if aIndex == 1,
>     *          the folder stored in browser.download.dir
>     */
> -  async _indexToFolder(aIndex) {
> +   _indexToFolder(aIndex) {

The indent seems incorrect here.
(Assignee)

Comment 3

4 months ago
(In reply to Florian Quèze [:florian] [:flo] from comment #2)
> The indent seems incorrect here.

Thanks for spotting that.
Comment hidden (mozreview-request)

Comment 5

4 months ago
mozreview-review
Comment on attachment 8885471 [details]
Bug 1380009 - Enable the ESLint no-return-await call to avoid unnecessary intermediate promise creation.

https://reviewboard.mozilla.org/r/156324/#review161646
Attachment #8885471 - Flags: review?(dtownsend) → review+

Comment 6

4 months ago
Pushed by mbanner@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/03be1f2d0e45
Enable the ESLint no-return-await call to avoid unnecessary intermediate promise creation. r=mossop

Comment 7

4 months ago
bugherder
https://hg.mozilla.org/mozilla-central/rev/03be1f2d0e45
Status: NEW → RESOLVED
Last Resolved: 4 months ago
status-firefox56: --- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla56

Comment 8

4 months ago
Commits pushed to master at https://github.com/mozilla/normandy

https://github.com/mozilla/normandy/commit/72241cc510724b4de0edf7ab1a9a2e37e82d2a55
Bug 1380009 - Enable eslint no-return-await.

https://github.com/mozilla/normandy/commit/82ed5c43b44bd995730a5aac1e9366c735940d34
Merge pull request #890 from mythmon/backport-lints

Bug 1380009 - Enable eslint no-return-await.
You need to log in before you can comment on or make changes to this bug.