Skip to content

Commit

Permalink
prefer-dom-node-text-content: Test destructuring with default value (
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker committed Oct 12, 2021
1 parent 4435a10 commit 0ec2bd7
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 3 deletions.
4 changes: 4 additions & 0 deletions test/prefer-dom-node-text-content.mjs
Expand Up @@ -24,8 +24,12 @@ test.snapshot({
'const {innerText} = node;',
'const {innerText,} = node;',
'const {innerText: text} = node;',
'const {innerText = "default text"} = node;',
'const {innerText: text = "default text"} = node;',
'({innerText} = node);',
'({innerText: text} = node);',
'({innerText = "default text"} = node);',
'({innerText: text = "default text"} = node);',
'function foo({innerText}) {return innerText}',
'for (const [{innerText}] of elements);',
],
Expand Down
62 changes: 59 additions & 3 deletions test/snapshots/prefer-dom-node-text-content.mjs.md
Expand Up @@ -89,6 +89,34 @@ Generated by [AVA](https://avajs.dev).
`

## Invalid #7
1 | const {innerText = "default text"} = node;

> Error 1/1
`␊
> 1 | const {innerText = "default text"} = node;␊
| ^^^^^^^^^ Prefer \`.textContent\` over \`.innerText\`.␊
--------------------------------------------------------------------------------␊
Suggestion 1/1: Switch to \`.textContent\`.␊
1 | const {textContent: innerText = "default text"} = node;␊
`

## Invalid #8
1 | const {innerText: text = "default text"} = node;

> Error 1/1
`␊
> 1 | const {innerText: text = "default text"} = node;␊
| ^^^^^^^^^ Prefer \`.textContent\` over \`.innerText\`.␊
--------------------------------------------------------------------------------␊
Suggestion 1/1: Switch to \`.textContent\`.␊
1 | const {textContent: text = "default text"} = node;␊
`

## Invalid #9
1 | ({innerText} = node);

> Error 1/1
Expand All @@ -102,7 +130,7 @@ Generated by [AVA](https://avajs.dev).
1 | ({textContent: innerText} = node);␊
`

## Invalid #8
## Invalid #10
1 | ({innerText: text} = node);

> Error 1/1
Expand All @@ -116,7 +144,35 @@ Generated by [AVA](https://avajs.dev).
1 | ({textContent: text} = node);␊
`

## Invalid #9
## Invalid #11
1 | ({innerText = "default text"} = node);

> Error 1/1
`␊
> 1 | ({innerText = "default text"} = node);␊
| ^^^^^^^^^ Prefer \`.textContent\` over \`.innerText\`.␊
--------------------------------------------------------------------------------␊
Suggestion 1/1: Switch to \`.textContent\`.␊
1 | ({textContent: innerText = "default text"} = node);␊
`

## Invalid #12
1 | ({innerText: text = "default text"} = node);

> Error 1/1
`␊
> 1 | ({innerText: text = "default text"} = node);␊
| ^^^^^^^^^ Prefer \`.textContent\` over \`.innerText\`.␊
--------------------------------------------------------------------------------␊
Suggestion 1/1: Switch to \`.textContent\`.␊
1 | ({textContent: text = "default text"} = node);␊
`

## Invalid #13
1 | function foo({innerText}) {return innerText}

> Error 1/1
Expand All @@ -130,7 +186,7 @@ Generated by [AVA](https://avajs.dev).
1 | function foo({textContent: innerText}) {return innerText}␊
`

## Invalid #10
## Invalid #14
1 | for (const [{innerText}] of elements);

> Error 1/1
Expand Down
Binary file modified test/snapshots/prefer-dom-node-text-content.mjs.snap
Binary file not shown.

0 comments on commit 0ec2bd7

Please sign in to comment.