Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prefer-dom-node-text-content: Test destructuring with default value #1419

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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.