Skip to content

Commit 81b21a5

Browse files
authored
no-unreadable-array-destructuring: Update tests (#947)
1 parent 2287075 commit 81b21a5

File tree

3 files changed

+126
-50
lines changed

3 files changed

+126
-50
lines changed
Lines changed: 16 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
import {test} from './utils/test';
22

3-
const errors = [
4-
{
5-
messageId: 'no-unreadable-array-destructuring'
6-
}
7-
];
8-
93
test({
104
valid: [
115
'const [, foo] = parts;',
@@ -15,6 +9,8 @@ test({
159
'const [foo,] = parts;',
1610
'const [foo,,] = parts;',
1711
'const [foo,, bar,, baz] = parts;',
12+
'[,foo] = bar;',
13+
'({parts: [,foo]} = bar);',
1814
'function foo([, bar]) {}',
1915
'function foo([bar]) {}',
2016
'function foo([bar,,baz]) {}',
@@ -26,51 +22,21 @@ test({
2622
// This is stupid, but valid code
2723
'const [,,] = parts;'
2824
],
29-
invalid: [
30-
{
31-
code: 'const [,, foo] = parts;',
32-
errors
33-
},
34-
{
35-
code: 'const [foo,,, bar] = parts;',
36-
errors
37-
},
38-
{
39-
code: 'const [foo,,,] = parts;',
40-
errors
41-
},
42-
{
43-
code: 'const [foo, bar,, baz ,,, qux] = parts;',
44-
errors
45-
},
46-
{
47-
code: 'function foo([,, bar]) {}',
48-
errors
49-
},
50-
{
51-
code: 'function foo([bar,,, baz]) {}',
52-
errors
53-
},
54-
{
55-
code: 'function foo([bar,,,]) {}',
56-
errors
57-
},
58-
{
59-
code: 'function foo([bar, baz,, qux ,,, quux]) {}',
60-
errors
61-
},
62-
{
63-
code: 'const [,,...rest] = parts;',
64-
errors
65-
},
66-
// This is stupid, but valid code
67-
{
68-
code: 'const [,,,] = parts;',
69-
errors
70-
}
71-
]
25+
invalid: []
7226
});
7327

7428
test.visualize([
75-
'const [foo, bar,, baz ,,, qux] = parts;'
29+
'const [,, foo] = parts;',
30+
'const [foo,,, bar] = parts;',
31+
'const [foo,,,] = parts;',
32+
'const [foo, bar,, baz ,,, qux] = parts;',
33+
'[,, foo] = bar;',
34+
'({parts: [,, foo]} = bar);',
35+
'function foo([,, bar]) {}',
36+
'function foo([bar,,, baz]) {}',
37+
'function foo([bar,,,]) {}',
38+
'function foo([bar, baz,, qux ,,, quux]) {}',
39+
'const [,,...rest] = parts;',
40+
// This is stupid, but valid code
41+
'const [,,,] = parts;'
7642
]);

test/snapshots/no-unreadable-array-destructuring.js.md

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,120 @@ Generated by [AVA](https://avajs.dev).
66

77
## no-unreadable-array-destructuring - #1
88

9+
> Snapshot 1
10+
11+
`␊
12+
Error 1/1:␊
13+
> 1 | const [,, foo] = parts;␊
14+
| ^^^^^^^^ Array destructuring may not contain consecutive ignored values.␊
15+
`
16+
17+
## no-unreadable-array-destructuring - #2
18+
19+
> Snapshot 1
20+
21+
`␊
22+
Error 1/1:␊
23+
> 1 | const [foo,,, bar] = parts;␊
24+
| ^^^^^^^^^^^^ Array destructuring may not contain consecutive ignored values.␊
25+
`
26+
27+
## no-unreadable-array-destructuring - #3
28+
29+
> Snapshot 1
30+
31+
`␊
32+
Error 1/1:␊
33+
> 1 | const [foo,,,] = parts;␊
34+
| ^^^^^^^^ Array destructuring may not contain consecutive ignored values.␊
35+
`
36+
37+
## no-unreadable-array-destructuring - #4
38+
939
> Snapshot 1
1040
1141
`␊
1242
Error 1/1:␊
1343
> 1 | const [foo, bar,, baz ,,, qux] = parts;␊
1444
| ^^^^^^^^^^^^^^^^^^^^^^^^ Array destructuring may not contain consecutive ignored values.␊
1545
`
46+
47+
## no-unreadable-array-destructuring - #5
48+
49+
> Snapshot 1
50+
51+
`␊
52+
Error 1/1:␊
53+
> 1 | [,, foo] = bar;␊
54+
| ^^^^^^^^ Array destructuring may not contain consecutive ignored values.␊
55+
`
56+
57+
## no-unreadable-array-destructuring - #6
58+
59+
> Snapshot 1
60+
61+
`␊
62+
Error 1/1:␊
63+
> 1 | ({parts: [,, foo]} = bar);␊
64+
| ^^^^^^^^ Array destructuring may not contain consecutive ignored values.␊
65+
`
66+
67+
## no-unreadable-array-destructuring - #7
68+
69+
> Snapshot 1
70+
71+
`␊
72+
Error 1/1:␊
73+
> 1 | function foo([,, bar]) {}␊
74+
| ^^^^^^^^ Array destructuring may not contain consecutive ignored values.␊
75+
`
76+
77+
## no-unreadable-array-destructuring - #8
78+
79+
> Snapshot 1
80+
81+
`␊
82+
Error 1/1:␊
83+
> 1 | function foo([bar,,, baz]) {}␊
84+
| ^^^^^^^^^^^^ Array destructuring may not contain consecutive ignored values.␊
85+
`
86+
87+
## no-unreadable-array-destructuring - #9
88+
89+
> Snapshot 1
90+
91+
`␊
92+
Error 1/1:␊
93+
> 1 | function foo([bar,,,]) {}␊
94+
| ^^^^^^^^ Array destructuring may not contain consecutive ignored values.␊
95+
`
96+
97+
## no-unreadable-array-destructuring - #10
98+
99+
> Snapshot 1
100+
101+
`␊
102+
Error 1/1:␊
103+
> 1 | function foo([bar, baz,, qux ,,, quux]) {}␊
104+
| ^^^^^^^^^^^^^^^^^^^^^^^^^ Array destructuring may not contain consecutive ignored values.␊
105+
`
106+
107+
## no-unreadable-array-destructuring - #11
108+
109+
> Snapshot 1
110+
111+
`␊
112+
Error 1/1:␊
113+
> 1 | const [,,...rest] = parts;␊
114+
| ^^^^^^^^^^^ Array destructuring may not contain consecutive ignored values.␊
115+
`
116+
117+
## no-unreadable-array-destructuring - #12
118+
119+
> Snapshot 1
120+
121+
`␊
122+
Error 1/1:␊
123+
> 1 | const [,,,] = parts;␊
124+
| ^^^^^ Array destructuring may not contain consecutive ignored values.␊
125+
`
426 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)