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

feat: deprecate no-return-await #17417

Merged
merged 4 commits into from Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/src/_data/further_reading_links.json
Expand Up @@ -719,5 +719,12 @@
"logo": "https://tc39.es/ecma262/img/favicon.ico",
"title": "ECMAScript® 2023 Language Specification",
"description": null
},
"https://v8.dev/blog/fast-async": {
"domain": "v8.dev",
"url": "https://v8.dev/blog/fast-async",
"logo": "https://v8.dev/favicon.ico",
"title": "Faster async functions and promises · V8",
"description": "Faster and easier-to-debug async functions and promises are coming to V8 v7.2 / Chrome 72."
}
}
11 changes: 4 additions & 7 deletions docs/src/_data/rules.json
Expand Up @@ -1062,13 +1062,6 @@
"fixable": false,
"hasSuggestions": false
},
{
"name": "no-return-await",
"description": "Disallow unnecessary `return await`",
"recommended": false,
"fixable": false,
"hasSuggestions": true
},
{
"name": "no-script-url",
"description": "Disallow `javascript:` urls",
Expand Down Expand Up @@ -1983,6 +1976,10 @@
"name": "no-restricted-modules",
"replacedBy": []
},
{
"name": "no-return-await",
"replacedBy": []
},
{
"name": "no-spaced-func",
"replacedBy": [
Expand Down
2 changes: 2 additions & 0 deletions docs/src/_data/rules_meta.json
Expand Up @@ -1578,6 +1578,8 @@
"recommended": false,
"url": "https://eslint.org/docs/latest/rules/no-return-await"
},
"deprecated": true,
"replacedBy": [],
"fixable": null
},
"no-script-url": {
Expand Down
2 changes: 2 additions & 0 deletions docs/src/rules/no-return-await.md
Expand Up @@ -2,10 +2,12 @@
title: no-return-await
rule_type: suggestion
further_reading:
- https://v8.dev/blog/fast-async
- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function
- https://jakearchibald.com/2017/await-vs-return-vs-return-await/
---

This rule was **deprecated** in Eslint v8.49.0 with no replacement. The original intent of this rule no longer applies due to the fact Javascript now handles native `Promises` differently. It can now be slower to remove `await` rather than keeping it. More technical information can be found in [this](https://v8.dev/blog/fast-async) V8 blog entry.
clshortfuse marked this conversation as resolved.
Show resolved Hide resolved

Using `return await` inside an `async function` keeps the current function in the call stack until the Promise that is being awaited has resolved, at the cost of an extra microtask before resolving the outer Promise. `return await` can also be used in a try/catch statement to catch errors from another function that returns a Promise.

Expand Down
5 changes: 5 additions & 0 deletions lib/rules/no-return-await.js
@@ -1,6 +1,7 @@
/**
* @fileoverview Disallows unnecessary `return await`
* @author Jordan Harband
* @deprecated
clshortfuse marked this conversation as resolved.
Show resolved Hide resolved
*/
"use strict";

Expand All @@ -26,6 +27,10 @@ module.exports = {

fixable: null,

deprecated: true,

replacedBy: [],

schema: [
],

Expand Down
1 change: 0 additions & 1 deletion packages/js/src/configs/eslint-all.js
Expand Up @@ -172,7 +172,6 @@ module.exports = Object.freeze({
"no-restricted-properties": "error",
"no-restricted-syntax": "error",
"no-return-assign": "error",
"no-return-await": "error",
"no-script-url": "error",
"no-self-assign": "error",
"no-self-compare": "error",
Expand Down