Skip to content

Commit

Permalink
More
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker authored and Clement398 committed Feb 23, 2024
1 parent eed65b6 commit c97843e
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 12 deletions.
2 changes: 2 additions & 0 deletions test/no-single-promise-in-promise-methods.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ test.snapshot({
`,
'Promise.all([promise]).then()',
'Promise.all([1]).then()',
'Promise.all([1.]).then()',
'Promise.all([.1]).then()',
'Promise.all([(0, promise)]).then()',
'const _ = () => Promise.all([ a ?? b ,],)',
'Promise.all([ {a} = 1 ,],)',
Expand Down
70 changes: 58 additions & 12 deletions test/snapshots/no-single-promise-in-promise-methods.mjs.md
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,53 @@ Generated by [AVA](https://avajs.dev).
1 | Promise.resolve(1).then()␊
`

## invalid(6): Promise.all([(0, promise)]).then()
## invalid(6): Promise.all([1.]).then()

> Input
`␊
1 | Promise.all([1.]).then()␊
`

> Error 1/1
`␊
> 1 | Promise.all([1.]).then()␊
| ^^^^ Wrapping single-element array with \`Promise.all()\` is unnecessary.␊
--------------------------------------------------------------------------------␊
Suggestion 1/2: Use the value directly.␊
1 | (1.).then()␊
--------------------------------------------------------------------------------␊
Suggestion 2/2: Switch to \`Promise.resolve(…)\`.␊
1 | Promise.resolve(1.).then()␊
`

## invalid(7): Promise.all([.1]).then()

> Input
`␊
1 | Promise.all([.1]).then()␊
`

> Error 1/1
`␊
> 1 | Promise.all([.1]).then()␊
| ^^^^ Wrapping single-element array with \`Promise.all()\` is unnecessary.␊
--------------------------------------------------------------------------------␊
Suggestion 1/2: Use the value directly.␊
1 | (.1).then()␊
--------------------------------------------------------------------------------␊
Suggestion 2/2: Switch to \`Promise.resolve(…)\`.␊
1 | Promise.resolve(.1).then()␊
`

## invalid(8): Promise.all([(0, promise)]).then()

> Input
Expand All @@ -828,7 +874,7 @@ Generated by [AVA](https://avajs.dev).
1 | Promise.resolve((0, promise)).then()␊
`

## invalid(7): const _ = () => Promise.all([ a ?? b ,],)
## invalid(9): const _ = () => Promise.all([ a ?? b ,],)

> Input
Expand All @@ -851,7 +897,7 @@ Generated by [AVA](https://avajs.dev).
1 | const _ = () => Promise.resolve( a ?? b ,)␊
`

## invalid(8): Promise.all([ {a} = 1 ,],)
## invalid(10): Promise.all([ {a} = 1 ,],)

> Input
Expand All @@ -874,7 +920,7 @@ Generated by [AVA](https://avajs.dev).
1 | Promise.resolve( {a} = 1 ,)␊
`

## invalid(9): Promise.all([ function () {} ,],)
## invalid(11): Promise.all([ function () {} ,],)

> Input
Expand All @@ -897,7 +943,7 @@ Generated by [AVA](https://avajs.dev).
1 | Promise.resolve( function () {} ,)␊
`

## invalid(10): Promise.all([ class {} ,],)
## invalid(12): Promise.all([ class {} ,],)

> Input
Expand All @@ -920,7 +966,7 @@ Generated by [AVA](https://avajs.dev).
1 | Promise.resolve( class {} ,)␊
`

## invalid(11): Promise.all([ new Foo ,],).then()
## invalid(13): Promise.all([ new Foo ,],).then()

> Input
Expand All @@ -943,7 +989,7 @@ Generated by [AVA](https://avajs.dev).
1 | Promise.resolve( new Foo ,).then()␊
`

## invalid(12): Promise.all([ new Foo ,],).toString
## invalid(14): Promise.all([ new Foo ,],).toString

> Input
Expand All @@ -966,7 +1012,7 @@ Generated by [AVA](https://avajs.dev).
1 | Promise.resolve( new Foo ,).toString␊
`

## invalid(13): foo(Promise.all([promise]))
## invalid(15): foo(Promise.all([promise]))

> Input
Expand All @@ -989,7 +1035,7 @@ Generated by [AVA](https://avajs.dev).
1 | foo(Promise.resolve(promise))␊
`

## invalid(14): Promise.all([promise]).foo = 1
## invalid(16): Promise.all([promise]).foo = 1

> Input
Expand All @@ -1012,7 +1058,7 @@ Generated by [AVA](https://avajs.dev).
1 | Promise.resolve(promise).foo = 1␊
`

## invalid(15): Promise.all([promise])[0] ||= 1
## invalid(17): Promise.all([promise])[0] ||= 1

> Input
Expand All @@ -1035,7 +1081,7 @@ Generated by [AVA](https://avajs.dev).
1 | Promise.resolve(promise)[0] ||= 1␊
`

## invalid(16): Promise.all([undefined]).then()
## invalid(18): Promise.all([undefined]).then()

> Input
Expand All @@ -1058,7 +1104,7 @@ Generated by [AVA](https://avajs.dev).
1 | Promise.resolve(undefined).then()␊
`

## invalid(17): Promise.all([null]).then()
## invalid(19): Promise.all([null]).then()

> Input
Expand Down
Binary file modified test/snapshots/no-single-promise-in-promise-methods.mjs.snap
Binary file not shown.

0 comments on commit c97843e

Please sign in to comment.