chore(linter): add error message to unicorn/no-single-promise-in-promise-methods

This commit is contained in:
Boshen 2024-04-19 15:52:41 +08:00
parent 2bac1d5384
commit fd670d542a
No known key found for this signature in database
GPG key ID: 9C7A8C8AB22BEBD1
2 changed files with 52 additions and 52 deletions

View file

@ -12,7 +12,7 @@ use oxc_span::Span;
use crate::{ast_util::is_method_call, context::LintContext, rule::Rule, AstNode};
#[derive(Debug, Error, Diagnostic)]
#[error("Wrapping single-element array with `Promise.{1}()` is unnecessary.")]
#[error("eslint-plugin-unicorn(no-single-promise-in-promise-methods): Wrapping single-element array with `Promise.{1}()` is unnecessary.")]
#[diagnostic(
severity(warning),
help("Either use the value directly, or switch to `Promise.resolve(…)`.")

View file

@ -2,224 +2,224 @@
source: crates/oxc_linter/src/tester.rs
expression: no_single_promise_in_promise_methods
---
⚠ Wrapping single-element array with `Promise.all()` is unnecessary.
eslint-plugin-unicorn(no-single-promise-in-promise-methods): Wrapping single-element array with `Promise.all()` is unnecessary.
╭─[no_single_promise_in_promise_methods.tsx:1:15]
1 │ await Promise.all([(0, promise)])
· ───
╰────
help: Either use the value directly, or switch to `Promise.resolve(…)`.
⚠ Wrapping single-element array with `Promise.all()` is unnecessary.
eslint-plugin-unicorn(no-single-promise-in-promise-methods): Wrapping single-element array with `Promise.all()` is unnecessary.
╭─[no_single_promise_in_promise_methods.tsx:1:39]
1 │ async function * foo() {await Promise.all([yield promise])}
· ───
╰────
help: Either use the value directly, or switch to `Promise.resolve(…)`.
⚠ Wrapping single-element array with `Promise.all()` is unnecessary.
eslint-plugin-unicorn(no-single-promise-in-promise-methods): Wrapping single-element array with `Promise.all()` is unnecessary.
╭─[no_single_promise_in_promise_methods.tsx:1:39]
1 │ async function * foo() {await Promise.all([yield* promise])}
· ───
╰────
help: Either use the value directly, or switch to `Promise.resolve(…)`.
⚠ Wrapping single-element array with `Promise.all()` is unnecessary.
eslint-plugin-unicorn(no-single-promise-in-promise-methods): Wrapping single-element array with `Promise.all()` is unnecessary.
╭─[no_single_promise_in_promise_methods.tsx:1:15]
1 │ await Promise.all([() => promise,],)
· ───
╰────
help: Either use the value directly, or switch to `Promise.resolve(…)`.
⚠ Wrapping single-element array with `Promise.all()` is unnecessary.
eslint-plugin-unicorn(no-single-promise-in-promise-methods): Wrapping single-element array with `Promise.all()` is unnecessary.
╭─[no_single_promise_in_promise_methods.tsx:1:15]
1 │ await Promise.all([a ? b : c,],)
· ───
╰────
help: Either use the value directly, or switch to `Promise.resolve(…)`.
⚠ Wrapping single-element array with `Promise.all()` is unnecessary.
eslint-plugin-unicorn(no-single-promise-in-promise-methods): Wrapping single-element array with `Promise.all()` is unnecessary.
╭─[no_single_promise_in_promise_methods.tsx:1:15]
1 │ await Promise.all([x ??= y,],)
· ───
╰────
help: Either use the value directly, or switch to `Promise.resolve(…)`.
⚠ Wrapping single-element array with `Promise.all()` is unnecessary.
eslint-plugin-unicorn(no-single-promise-in-promise-methods): Wrapping single-element array with `Promise.all()` is unnecessary.
╭─[no_single_promise_in_promise_methods.tsx:1:15]
1 │ await Promise.all([x ||= y,],)
· ───
╰────
help: Either use the value directly, or switch to `Promise.resolve(…)`.
⚠ Wrapping single-element array with `Promise.all()` is unnecessary.
eslint-plugin-unicorn(no-single-promise-in-promise-methods): Wrapping single-element array with `Promise.all()` is unnecessary.
╭─[no_single_promise_in_promise_methods.tsx:1:15]
1 │ await Promise.all([x &&= y,],)
· ───
╰────
help: Either use the value directly, or switch to `Promise.resolve(…)`.
⚠ Wrapping single-element array with `Promise.all()` is unnecessary.
eslint-plugin-unicorn(no-single-promise-in-promise-methods): Wrapping single-element array with `Promise.all()` is unnecessary.
╭─[no_single_promise_in_promise_methods.tsx:1:15]
1 │ await Promise.all([x |= y,],)
· ───
╰────
help: Either use the value directly, or switch to `Promise.resolve(…)`.
⚠ Wrapping single-element array with `Promise.all()` is unnecessary.
eslint-plugin-unicorn(no-single-promise-in-promise-methods): Wrapping single-element array with `Promise.all()` is unnecessary.
╭─[no_single_promise_in_promise_methods.tsx:1:15]
1 │ await Promise.all([x ^= y,],)
· ───
╰────
help: Either use the value directly, or switch to `Promise.resolve(…)`.
⚠ Wrapping single-element array with `Promise.all()` is unnecessary.
eslint-plugin-unicorn(no-single-promise-in-promise-methods): Wrapping single-element array with `Promise.all()` is unnecessary.
╭─[no_single_promise_in_promise_methods.tsx:1:15]
1 │ await Promise.all([x ??= y,],)
· ───
╰────
help: Either use the value directly, or switch to `Promise.resolve(…)`.
⚠ Wrapping single-element array with `Promise.all()` is unnecessary.
eslint-plugin-unicorn(no-single-promise-in-promise-methods): Wrapping single-element array with `Promise.all()` is unnecessary.
╭─[no_single_promise_in_promise_methods.tsx:1:15]
1 │ await Promise.all([x ||= y,],)
· ───
╰────
help: Either use the value directly, or switch to `Promise.resolve(…)`.
⚠ Wrapping single-element array with `Promise.all()` is unnecessary.
eslint-plugin-unicorn(no-single-promise-in-promise-methods): Wrapping single-element array with `Promise.all()` is unnecessary.
╭─[no_single_promise_in_promise_methods.tsx:1:15]
1 │ await Promise.all([x &&= y,],)
· ───
╰────
help: Either use the value directly, or switch to `Promise.resolve(…)`.
⚠ Wrapping single-element array with `Promise.all()` is unnecessary.
eslint-plugin-unicorn(no-single-promise-in-promise-methods): Wrapping single-element array with `Promise.all()` is unnecessary.
╭─[no_single_promise_in_promise_methods.tsx:1:15]
1 │ await Promise.all([x | y,],)
· ───
╰────
help: Either use the value directly, or switch to `Promise.resolve(…)`.
⚠ Wrapping single-element array with `Promise.all()` is unnecessary.
eslint-plugin-unicorn(no-single-promise-in-promise-methods): Wrapping single-element array with `Promise.all()` is unnecessary.
╭─[no_single_promise_in_promise_methods.tsx:1:15]
1 │ await Promise.all([x ^ y,],)
· ───
╰────
help: Either use the value directly, or switch to `Promise.resolve(…)`.
⚠ Wrapping single-element array with `Promise.all()` is unnecessary.
eslint-plugin-unicorn(no-single-promise-in-promise-methods): Wrapping single-element array with `Promise.all()` is unnecessary.
╭─[no_single_promise_in_promise_methods.tsx:1:15]
1 │ await Promise.all([x & y,],)
· ───
╰────
help: Either use the value directly, or switch to `Promise.resolve(…)`.
⚠ Wrapping single-element array with `Promise.all()` is unnecessary.
eslint-plugin-unicorn(no-single-promise-in-promise-methods): Wrapping single-element array with `Promise.all()` is unnecessary.
╭─[no_single_promise_in_promise_methods.tsx:1:15]
1 │ await Promise.all([x !== y,],)
· ───
╰────
help: Either use the value directly, or switch to `Promise.resolve(…)`.
⚠ Wrapping single-element array with `Promise.all()` is unnecessary.
eslint-plugin-unicorn(no-single-promise-in-promise-methods): Wrapping single-element array with `Promise.all()` is unnecessary.
╭─[no_single_promise_in_promise_methods.tsx:1:15]
1 │ await Promise.all([x == y,],)
· ───
╰────
help: Either use the value directly, or switch to `Promise.resolve(…)`.
⚠ Wrapping single-element array with `Promise.all()` is unnecessary.
eslint-plugin-unicorn(no-single-promise-in-promise-methods): Wrapping single-element array with `Promise.all()` is unnecessary.
╭─[no_single_promise_in_promise_methods.tsx:1:15]
1 │ await Promise.all([x in y,],)
· ───
╰────
help: Either use the value directly, or switch to `Promise.resolve(…)`.
⚠ Wrapping single-element array with `Promise.all()` is unnecessary.
eslint-plugin-unicorn(no-single-promise-in-promise-methods): Wrapping single-element array with `Promise.all()` is unnecessary.
╭─[no_single_promise_in_promise_methods.tsx:1:15]
1 │ await Promise.all([x >>> y,],)
· ───
╰────
help: Either use the value directly, or switch to `Promise.resolve(…)`.
⚠ Wrapping single-element array with `Promise.all()` is unnecessary.
eslint-plugin-unicorn(no-single-promise-in-promise-methods): Wrapping single-element array with `Promise.all()` is unnecessary.
╭─[no_single_promise_in_promise_methods.tsx:1:15]
1 │ await Promise.all([x + y,],)
· ───
╰────
help: Either use the value directly, or switch to `Promise.resolve(…)`.
⚠ Wrapping single-element array with `Promise.all()` is unnecessary.
eslint-plugin-unicorn(no-single-promise-in-promise-methods): Wrapping single-element array with `Promise.all()` is unnecessary.
╭─[no_single_promise_in_promise_methods.tsx:1:15]
1 │ await Promise.all([x / y,],)
· ───
╰────
help: Either use the value directly, or switch to `Promise.resolve(…)`.
⚠ Wrapping single-element array with `Promise.all()` is unnecessary.
eslint-plugin-unicorn(no-single-promise-in-promise-methods): Wrapping single-element array with `Promise.all()` is unnecessary.
╭─[no_single_promise_in_promise_methods.tsx:1:15]
1 │ await Promise.all([x ** y,],)
· ───
╰────
help: Either use the value directly, or switch to `Promise.resolve(…)`.
⚠ Wrapping single-element array with `Promise.all()` is unnecessary.
eslint-plugin-unicorn(no-single-promise-in-promise-methods): Wrapping single-element array with `Promise.all()` is unnecessary.
╭─[no_single_promise_in_promise_methods.tsx:1:15]
1 │ await Promise.all([promise,],)
· ───
╰────
help: Either use the value directly, or switch to `Promise.resolve(…)`.
⚠ Wrapping single-element array with `Promise.all()` is unnecessary.
eslint-plugin-unicorn(no-single-promise-in-promise-methods): Wrapping single-element array with `Promise.all()` is unnecessary.
╭─[no_single_promise_in_promise_methods.tsx:1:15]
1 │ await Promise.all([getPromise(),],)
· ───
╰────
help: Either use the value directly, or switch to `Promise.resolve(…)`.
⚠ Wrapping single-element array with `Promise.all()` is unnecessary.
eslint-plugin-unicorn(no-single-promise-in-promise-methods): Wrapping single-element array with `Promise.all()` is unnecessary.
╭─[no_single_promise_in_promise_methods.tsx:1:15]
1 │ await Promise.all([promises[0],],)
· ───
╰────
help: Either use the value directly, or switch to `Promise.resolve(…)`.
⚠ Wrapping single-element array with `Promise.all()` is unnecessary.
eslint-plugin-unicorn(no-single-promise-in-promise-methods): Wrapping single-element array with `Promise.all()` is unnecessary.
╭─[no_single_promise_in_promise_methods.tsx:1:15]
1 │ await Promise.all([await promise])
· ───
╰────
help: Either use the value directly, or switch to `Promise.resolve(…)`.
⚠ Wrapping single-element array with `Promise.any()` is unnecessary.
eslint-plugin-unicorn(no-single-promise-in-promise-methods): Wrapping single-element array with `Promise.any()` is unnecessary.
╭─[no_single_promise_in_promise_methods.tsx:1:15]
1 │ await Promise.any([promise])
· ───
╰────
help: Either use the value directly, or switch to `Promise.resolve(…)`.
⚠ Wrapping single-element array with `Promise.race()` is unnecessary.
eslint-plugin-unicorn(no-single-promise-in-promise-methods): Wrapping single-element array with `Promise.race()` is unnecessary.
╭─[no_single_promise_in_promise_methods.tsx:1:15]
1 │ await Promise.race([promise])
· ────
╰────
help: Either use the value directly, or switch to `Promise.resolve(…)`.
⚠ Wrapping single-element array with `Promise.all()` is unnecessary.
eslint-plugin-unicorn(no-single-promise-in-promise-methods): Wrapping single-element array with `Promise.all()` is unnecessary.
╭─[no_single_promise_in_promise_methods.tsx:1:15]
1 │ await Promise.all([new Promise(() => {})])
· ───
╰────
help: Either use the value directly, or switch to `Promise.resolve(…)`.
⚠ Wrapping single-element array with `Promise.all()` is unnecessary.
eslint-plugin-unicorn(no-single-promise-in-promise-methods): Wrapping single-element array with `Promise.all()` is unnecessary.
╭─[no_single_promise_in_promise_methods.tsx:1:16]
1 │ +await Promise.all([+1])
· ───
╰────
help: Either use the value directly, or switch to `Promise.resolve(…)`.
⚠ Wrapping single-element array with `Promise.all()` is unnecessary.
eslint-plugin-unicorn(no-single-promise-in-promise-methods): Wrapping single-element array with `Promise.all()` is unnecessary.
╭─[no_single_promise_in_promise_methods.tsx:2:23]
1 │
2 │ await Promise.all([(x,y)])
@ -228,14 +228,14 @@ expression: no_single_promise_in_promise_methods
╰────
help: Either use the value directly, or switch to `Promise.resolve(…)`.
⚠ Wrapping single-element array with `Promise.all()` is unnecessary.
eslint-plugin-unicorn(no-single-promise-in-promise-methods): Wrapping single-element array with `Promise.all()` is unnecessary.
╭─[no_single_promise_in_promise_methods.tsx:1:9]
1 │ Promise.all([promise,],)
· ───
╰────
help: Either use the value directly, or switch to `Promise.resolve(…)`.
⚠ Wrapping single-element array with `Promise.all()` is unnecessary.
eslint-plugin-unicorn(no-single-promise-in-promise-methods): Wrapping single-element array with `Promise.all()` is unnecessary.
╭─[no_single_promise_in_promise_methods.tsx:3:11]
2 │ foo
3 │ Promise.all([(0, promise),],)
@ -244,7 +244,7 @@ expression: no_single_promise_in_promise_methods
╰────
help: Either use the value directly, or switch to `Promise.resolve(…)`.
⚠ Wrapping single-element array with `Promise.all()` is unnecessary.
eslint-plugin-unicorn(no-single-promise-in-promise-methods): Wrapping single-element array with `Promise.all()` is unnecessary.
╭─[no_single_promise_in_promise_methods.tsx:3:17]
2 │ foo
3 │ Promise.all([[array][0],],)
@ -253,112 +253,112 @@ expression: no_single_promise_in_promise_methods
╰────
help: Either use the value directly, or switch to `Promise.resolve(…)`.
⚠ Wrapping single-element array with `Promise.all()` is unnecessary.
eslint-plugin-unicorn(no-single-promise-in-promise-methods): Wrapping single-element array with `Promise.all()` is unnecessary.
╭─[no_single_promise_in_promise_methods.tsx:1:9]
1 │ Promise.all([promise]).then()
· ───
╰────
help: Either use the value directly, or switch to `Promise.resolve(…)`.
⚠ Wrapping single-element array with `Promise.all()` is unnecessary.
eslint-plugin-unicorn(no-single-promise-in-promise-methods): Wrapping single-element array with `Promise.all()` is unnecessary.
╭─[no_single_promise_in_promise_methods.tsx:1:9]
1 │ Promise.all([1]).then()
· ───
╰────
help: Either use the value directly, or switch to `Promise.resolve(…)`.
⚠ Wrapping single-element array with `Promise.all()` is unnecessary.
eslint-plugin-unicorn(no-single-promise-in-promise-methods): Wrapping single-element array with `Promise.all()` is unnecessary.
╭─[no_single_promise_in_promise_methods.tsx:1:9]
1 │ Promise.all([1.]).then()
· ───
╰────
help: Either use the value directly, or switch to `Promise.resolve(…)`.
⚠ Wrapping single-element array with `Promise.all()` is unnecessary.
eslint-plugin-unicorn(no-single-promise-in-promise-methods): Wrapping single-element array with `Promise.all()` is unnecessary.
╭─[no_single_promise_in_promise_methods.tsx:1:9]
1 │ Promise.all([.1]).then()
· ───
╰────
help: Either use the value directly, or switch to `Promise.resolve(…)`.
⚠ Wrapping single-element array with `Promise.all()` is unnecessary.
eslint-plugin-unicorn(no-single-promise-in-promise-methods): Wrapping single-element array with `Promise.all()` is unnecessary.
╭─[no_single_promise_in_promise_methods.tsx:1:9]
1 │ Promise.all([(0, promise)]).then()
· ───
╰────
help: Either use the value directly, or switch to `Promise.resolve(…)`.
⚠ Wrapping single-element array with `Promise.all()` is unnecessary.
eslint-plugin-unicorn(no-single-promise-in-promise-methods): Wrapping single-element array with `Promise.all()` is unnecessary.
╭─[no_single_promise_in_promise_methods.tsx:1:25]
1 │ const _ = () => Promise.all([ a ?? b ,],)
· ───
╰────
help: Either use the value directly, or switch to `Promise.resolve(…)`.
⚠ Wrapping single-element array with `Promise.all()` is unnecessary.
eslint-plugin-unicorn(no-single-promise-in-promise-methods): Wrapping single-element array with `Promise.all()` is unnecessary.
╭─[no_single_promise_in_promise_methods.tsx:1:9]
1 │ Promise.all([ {a} = 1 ,],)
· ───
╰────
help: Either use the value directly, or switch to `Promise.resolve(…)`.
⚠ Wrapping single-element array with `Promise.all()` is unnecessary.
eslint-plugin-unicorn(no-single-promise-in-promise-methods): Wrapping single-element array with `Promise.all()` is unnecessary.
╭─[no_single_promise_in_promise_methods.tsx:1:9]
1 │ Promise.all([ function () {} ,],)
· ───
╰────
help: Either use the value directly, or switch to `Promise.resolve(…)`.
⚠ Wrapping single-element array with `Promise.all()` is unnecessary.
eslint-plugin-unicorn(no-single-promise-in-promise-methods): Wrapping single-element array with `Promise.all()` is unnecessary.
╭─[no_single_promise_in_promise_methods.tsx:1:9]
1 │ Promise.all([ class {} ,],)
· ───
╰────
help: Either use the value directly, or switch to `Promise.resolve(…)`.
⚠ Wrapping single-element array with `Promise.all()` is unnecessary.
eslint-plugin-unicorn(no-single-promise-in-promise-methods): Wrapping single-element array with `Promise.all()` is unnecessary.
╭─[no_single_promise_in_promise_methods.tsx:1:9]
1 │ Promise.all([ new Foo ,],).then()
· ───
╰────
help: Either use the value directly, or switch to `Promise.resolve(…)`.
⚠ Wrapping single-element array with `Promise.all()` is unnecessary.
eslint-plugin-unicorn(no-single-promise-in-promise-methods): Wrapping single-element array with `Promise.all()` is unnecessary.
╭─[no_single_promise_in_promise_methods.tsx:1:9]
1 │ Promise.all([ new Foo ,],).toString
· ───
╰────
help: Either use the value directly, or switch to `Promise.resolve(…)`.
⚠ Wrapping single-element array with `Promise.all()` is unnecessary.
eslint-plugin-unicorn(no-single-promise-in-promise-methods): Wrapping single-element array with `Promise.all()` is unnecessary.
╭─[no_single_promise_in_promise_methods.tsx:1:13]
1 │ foo(Promise.all([promise]))
· ───
╰────
help: Either use the value directly, or switch to `Promise.resolve(…)`.
⚠ Wrapping single-element array with `Promise.all()` is unnecessary.
eslint-plugin-unicorn(no-single-promise-in-promise-methods): Wrapping single-element array with `Promise.all()` is unnecessary.
╭─[no_single_promise_in_promise_methods.tsx:1:9]
1 │ Promise.all([promise]).foo = 1
· ───
╰────
help: Either use the value directly, or switch to `Promise.resolve(…)`.
⚠ Wrapping single-element array with `Promise.all()` is unnecessary.
eslint-plugin-unicorn(no-single-promise-in-promise-methods): Wrapping single-element array with `Promise.all()` is unnecessary.
╭─[no_single_promise_in_promise_methods.tsx:1:9]
1 │ Promise.all([promise])[0] ||= 1
· ───
╰────
help: Either use the value directly, or switch to `Promise.resolve(…)`.
⚠ Wrapping single-element array with `Promise.all()` is unnecessary.
eslint-plugin-unicorn(no-single-promise-in-promise-methods): Wrapping single-element array with `Promise.all()` is unnecessary.
╭─[no_single_promise_in_promise_methods.tsx:1:9]
1 │ Promise.all([undefined]).then()
· ───
╰────
help: Either use the value directly, or switch to `Promise.resolve(…)`.
⚠ Wrapping single-element array with `Promise.all()` is unnecessary.
eslint-plugin-unicorn(no-single-promise-in-promise-methods): Wrapping single-element array with `Promise.all()` is unnecessary.
╭─[no_single_promise_in_promise_methods.tsx:1:9]
1 │ Promise.all([null]).then()
· ───