Skip to content

Commit

Permalink
no-unreadable-array-destructuring: Update tests (#947)
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker committed Dec 21, 2020
1 parent 2287075 commit 81b21a5
Show file tree
Hide file tree
Showing 3 changed files with 126 additions and 50 deletions.
66 changes: 16 additions & 50 deletions test/no-unreadable-array-destructuring.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
import {test} from './utils/test';

const errors = [
{
messageId: 'no-unreadable-array-destructuring'
}
];

test({
valid: [
'const [, foo] = parts;',
Expand All @@ -15,6 +9,8 @@ test({
'const [foo,] = parts;',
'const [foo,,] = parts;',
'const [foo,, bar,, baz] = parts;',
'[,foo] = bar;',
'({parts: [,foo]} = bar);',
'function foo([, bar]) {}',
'function foo([bar]) {}',
'function foo([bar,,baz]) {}',
Expand All @@ -26,51 +22,21 @@ test({
// This is stupid, but valid code
'const [,,] = parts;'
],
invalid: [
{
code: 'const [,, foo] = parts;',
errors
},
{
code: 'const [foo,,, bar] = parts;',
errors
},
{
code: 'const [foo,,,] = parts;',
errors
},
{
code: 'const [foo, bar,, baz ,,, qux] = parts;',
errors
},
{
code: 'function foo([,, bar]) {}',
errors
},
{
code: 'function foo([bar,,, baz]) {}',
errors
},
{
code: 'function foo([bar,,,]) {}',
errors
},
{
code: 'function foo([bar, baz,, qux ,,, quux]) {}',
errors
},
{
code: 'const [,,...rest] = parts;',
errors
},
// This is stupid, but valid code
{
code: 'const [,,,] = parts;',
errors
}
]
invalid: []
});

test.visualize([
'const [foo, bar,, baz ,,, qux] = parts;'
'const [,, foo] = parts;',
'const [foo,,, bar] = parts;',
'const [foo,,,] = parts;',
'const [foo, bar,, baz ,,, qux] = parts;',
'[,, foo] = bar;',
'({parts: [,, foo]} = bar);',
'function foo([,, bar]) {}',
'function foo([bar,,, baz]) {}',
'function foo([bar,,,]) {}',
'function foo([bar, baz,, qux ,,, quux]) {}',
'const [,,...rest] = parts;',
// This is stupid, but valid code
'const [,,,] = parts;'
]);
110 changes: 110 additions & 0 deletions test/snapshots/no-unreadable-array-destructuring.js.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,120 @@ Generated by [AVA](https://avajs.dev).

## no-unreadable-array-destructuring - #1

> Snapshot 1
`␊
Error 1/1:␊
> 1 | const [,, foo] = parts;␊
| ^^^^^^^^ Array destructuring may not contain consecutive ignored values.␊
`

## no-unreadable-array-destructuring - #2

> Snapshot 1
`␊
Error 1/1:␊
> 1 | const [foo,,, bar] = parts;␊
| ^^^^^^^^^^^^ Array destructuring may not contain consecutive ignored values.␊
`

## no-unreadable-array-destructuring - #3

> Snapshot 1
`␊
Error 1/1:␊
> 1 | const [foo,,,] = parts;␊
| ^^^^^^^^ Array destructuring may not contain consecutive ignored values.␊
`

## no-unreadable-array-destructuring - #4

> Snapshot 1
`␊
Error 1/1:␊
> 1 | const [foo, bar,, baz ,,, qux] = parts;␊
| ^^^^^^^^^^^^^^^^^^^^^^^^ Array destructuring may not contain consecutive ignored values.␊
`

## no-unreadable-array-destructuring - #5

> Snapshot 1
`␊
Error 1/1:␊
> 1 | [,, foo] = bar;␊
| ^^^^^^^^ Array destructuring may not contain consecutive ignored values.␊
`

## no-unreadable-array-destructuring - #6

> Snapshot 1
`␊
Error 1/1:␊
> 1 | ({parts: [,, foo]} = bar);␊
| ^^^^^^^^ Array destructuring may not contain consecutive ignored values.␊
`

## no-unreadable-array-destructuring - #7

> Snapshot 1
`␊
Error 1/1:␊
> 1 | function foo([,, bar]) {}␊
| ^^^^^^^^ Array destructuring may not contain consecutive ignored values.␊
`

## no-unreadable-array-destructuring - #8

> Snapshot 1
`␊
Error 1/1:␊
> 1 | function foo([bar,,, baz]) {}␊
| ^^^^^^^^^^^^ Array destructuring may not contain consecutive ignored values.␊
`

## no-unreadable-array-destructuring - #9

> Snapshot 1
`␊
Error 1/1:␊
> 1 | function foo([bar,,,]) {}␊
| ^^^^^^^^ Array destructuring may not contain consecutive ignored values.␊
`

## no-unreadable-array-destructuring - #10

> Snapshot 1
`␊
Error 1/1:␊
> 1 | function foo([bar, baz,, qux ,,, quux]) {}␊
| ^^^^^^^^^^^^^^^^^^^^^^^^^ Array destructuring may not contain consecutive ignored values.␊
`

## no-unreadable-array-destructuring - #11

> Snapshot 1
`␊
Error 1/1:␊
> 1 | const [,,...rest] = parts;␊
| ^^^^^^^^^^^ Array destructuring may not contain consecutive ignored values.␊
`

## no-unreadable-array-destructuring - #12

> Snapshot 1
`␊
Error 1/1:␊
> 1 | const [,,,] = parts;␊
| ^^^^^ Array destructuring may not contain consecutive ignored values.␊
`
Binary file modified test/snapshots/no-unreadable-array-destructuring.js.snap
Binary file not shown.

0 comments on commit 81b21a5

Please sign in to comment.