Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions crates/oxc_linter/src/rules/eslint/require_await.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ use crate::{AstNode, context::LintContext, rule::Rule};
pub struct RequireAwait;

fn require_await_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Async function has no 'await' expression.")
.with_help("Consider removing the 'async' keyword.")
OxcDiagnostic::warn("Async function has no `await` expression.")
.with_help("Consider removing the `async` keyword.")
.with_label(span)
}

Expand All @@ -27,6 +27,12 @@ declare_oxc_lint!(
///
/// Disallow async functions which have no `await` expression.
///
/// ::: warning NOTE
/// This rule is inferior to the accuracy of the type-aware
/// `typescript/require-await` rule. If using type-aware
/// rules, always prefer that rule over this one.
/// :::
///
/// ### Why is this bad?
///
/// Asynchronous functions in JavaScript behave differently than other
Expand All @@ -46,14 +52,15 @@ declare_oxc_lint!(
/// return data.map(processDataItem);
/// }
/// ```
/// Asynchronous functions that don’t use await might not need to be
///
/// Asynchronous functions that don’t use `await` might not need to be
/// asynchronous functions and could be the unintentional result of
/// refactoring.
///
/// Note: this rule ignores async generator functions. This is because
/// generators yield rather than return a value and async generators might
/// yield all the values of another async generator without ever actually
/// needing to use await.
/// needing to use `await`.
///
/// ### Examples
///
Expand Down
40 changes: 20 additions & 20 deletions crates/oxc_linter/src/snapshots/eslint_require_await.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,72 +2,72 @@
source: crates/oxc_linter/src/tester.rs
---

⚠ eslint(require-await): Async function has no 'await' expression.
⚠ eslint(require-await): Async function has no `await` expression.
╭─[require_await.mts:1:16]
1 │ async function foo() { doSomething() }
· ───
╰────
help: Consider removing the 'async' keyword.
help: Consider removing the `async` keyword.

⚠ eslint(require-await): Async function has no 'await' expression.
⚠ eslint(require-await): Async function has no `await` expression.
╭─[require_await.mts:1:2]
1 │ (async function() { doSomething() })
· ──────────────────────────────────
╰────
help: Consider removing the 'async' keyword.
help: Consider removing the `async` keyword.

⚠ eslint(require-await): Async function has no 'await' expression.
⚠ eslint(require-await): Async function has no `await` expression.
╭─[require_await.mts:1:1]
1 │ async () => { doSomething() }
· ─────────────────────────────
╰────
help: Consider removing the 'async' keyword.
help: Consider removing the `async` keyword.

⚠ eslint(require-await): Async function has no 'await' expression.
⚠ eslint(require-await): Async function has no `await` expression.
╭─[require_await.mts:1:1]
1 │ async () => doSomething()
· ─────────────────────────
╰────
help: Consider removing the 'async' keyword.
help: Consider removing the `async` keyword.

⚠ eslint(require-await): Async function has no 'await' expression.
⚠ eslint(require-await): Async function has no `await` expression.
╭─[require_await.mts:1:10]
1 │ ({ async foo() { doSomething() } })
· ───
╰────
help: Consider removing the 'async' keyword.
help: Consider removing the `async` keyword.

⚠ eslint(require-await): Async function has no 'await' expression.
⚠ eslint(require-await): Async function has no `await` expression.
╭─[require_await.mts:1:17]
1 │ class A { async foo() { doSomething() } }
· ───
╰────
help: Consider removing the 'async' keyword.
help: Consider removing the `async` keyword.

⚠ eslint(require-await): Async function has no 'await' expression.
⚠ eslint(require-await): Async function has no `await` expression.
╭─[require_await.mts:1:16]
1 │ (class { async foo() { doSomething() } })
· ───
╰────
help: Consider removing the 'async' keyword.
help: Consider removing the `async` keyword.

⚠ eslint(require-await): Async function has no 'await' expression.
⚠ eslint(require-await): Async function has no `await` expression.
╭─[require_await.mts:1:18]
1 │ (class { async ''() { doSomething() } })
· ────────────────────
╰────
help: Consider removing the 'async' keyword.
help: Consider removing the `async` keyword.

⚠ eslint(require-await): Async function has no 'await' expression.
⚠ eslint(require-await): Async function has no `await` expression.
╭─[require_await.mts:1:16]
1 │ async function foo() { async () => { await doSomething() } }
· ───
╰────
help: Consider removing the 'async' keyword.
help: Consider removing the `async` keyword.

⚠ eslint(require-await): Async function has no 'await' expression.
⚠ eslint(require-await): Async function has no `await` expression.
╭─[require_await.mts:1:31]
1 │ async function foo() { await (async () => { doSomething() }) }
· ─────────────────────────────
╰────
help: Consider removing the 'async' keyword.
help: Consider removing the `async` keyword.
Loading