From 0ec2bd75c972f81631dc5d201cf97126ea3c4095 Mon Sep 17 00:00:00 2001 From: fisker Cheung Date: Tue, 12 Oct 2021 11:39:18 +0800 Subject: [PATCH] `prefer-dom-node-text-content`: Test destructuring with default value (#1419) --- test/prefer-dom-node-text-content.mjs | 4 ++ .../prefer-dom-node-text-content.mjs.md | 62 +++++++++++++++++- .../prefer-dom-node-text-content.mjs.snap | Bin 630 -> 795 bytes 3 files changed, 63 insertions(+), 3 deletions(-) diff --git a/test/prefer-dom-node-text-content.mjs b/test/prefer-dom-node-text-content.mjs index 8ba2d7295b..88cc6c7131 100644 --- a/test/prefer-dom-node-text-content.mjs +++ b/test/prefer-dom-node-text-content.mjs @@ -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);', ], diff --git a/test/snapshots/prefer-dom-node-text-content.mjs.md b/test/snapshots/prefer-dom-node-text-content.mjs.md index 26fa8901e6..4d32684832 100644 --- a/test/snapshots/prefer-dom-node-text-content.mjs.md +++ b/test/snapshots/prefer-dom-node-text-content.mjs.md @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/test/snapshots/prefer-dom-node-text-content.mjs.snap b/test/snapshots/prefer-dom-node-text-content.mjs.snap index 103a926b5395bca4d17938c5d13179599ae284d5..f67e310388a69126d5c34065142c7f96450c942c 100644 GIT binary patch literal 795 zcmV+$1LXWcRzV`T_f4|M1^pO!Ps>H;= z;3PSj!y)5oc2a+FQ1{h_^^9OqO=bp$c#j8qf<~#U+>H0ESWxQI#|RcpWno~*v15oh zDdYXl`=RsAUq|`v7{Q{ktPBjLsi!72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