-
-
Notifications
You must be signed in to change notification settings - Fork 381
/
no-await-in-promise-methods.mjs
42 lines (39 loc) · 1.37 KB
/
no-await-in-promise-methods.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import {getTester} from './utils/test.mjs';
const {test} = getTester(import.meta);
test.snapshot({
valid: [
'Promise.all([promise1, promise2, promise3, promise4])',
'Promise.allSettled([promise1, promise2, promise3, promise4])',
'Promise.any([promise1, promise2, promise3, promise4])',
'Promise.race([promise1, promise2, promise3, promise4])',
'Promise.all(...[await promise])',
'Promise.all([await promise], extraArguments)',
'Promise.all()',
'Promise.all(notArrayExpression)',
'Promise.all([,])',
'Promise[all]([await promise])',
'Promise.all?.([await promise])',
'Promise?.all([await promise])',
'Promise.notListedMethod([await promise])',
'NotPromise.all([await promise])',
'Promise.all([(await promise, 0)])',
'new Promise.all([await promise])',
// We are not checking these cases
'globalThis.Promise.all([await promise])',
'Promise["all"]([await promise])',
],
invalid: [
'Promise.all([await promise])',
'Promise.allSettled([await promise])',
'Promise.any([await promise])',
'Promise.race([await promise])',
'Promise.all([, await promise])',
'Promise.all([await promise,])',
'Promise.all([await promise],)',
'Promise.all([await (0, promise)],)',
'Promise.all([await (( promise ))])',
'Promise.all([await await promise])',
'Promise.all([...foo, await promise1, await promise2])',
'Promise.all([await /* comment*/ promise])',
],
});