Closed
Bug 1380009
Opened 8 years ago
Closed 8 years ago
Enable the ESLint no-return-await call to avoid intermediate promise creation.
Categories
(Toolkit :: General, enhancement)
Toolkit
General
Tracking
()
RESOLVED
FIXED
mozilla56
| Tracking | Status | |
|---|---|---|
| firefox56 | --- | fixed |
People
(Reporter: standard8, Assigned: standard8)
Details
Attachments
(1 file)
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•8 years 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•8 years 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•8 years 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+
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•8 years ago
|
||
| bugherder | ||
Status: NEW → RESOLVED
Closed: 8 years ago
status-firefox56:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla56
Comment 8•8 years 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.
Description
•