From e684e6ce23126aeb40086903b137309281033bb3 Mon Sep 17 00:00:00 2001 From: fisker Cheung Date: Wed, 14 Jul 2021 11:04:44 +0800 Subject: [PATCH] `prefer-dom-node-text-content`: Test destructuring with default value --- test/prefer-dom-node-text-content.mjs | 4 ++ .../prefer-dom-node-text-content.mjs.md | 36 ++++++++++++++++-- .../prefer-dom-node-text-content.mjs.snap | Bin 670 -> 750 bytes 3 files changed, 36 insertions(+), 4 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 573cebec5a..f8d9491b50 100644 --- a/test/snapshots/prefer-dom-node-text-content.mjs.md +++ b/test/snapshots/prefer-dom-node-text-content.mjs.md @@ -110,7 +110,21 @@ Generated by [AVA](https://avajs.dev). 1 | const {textContent: text} = node;␊ ` -## Invalid #7 +## 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/2 @@ -135,7 +149,7 @@ Generated by [AVA](https://avajs.dev). 1 | ({textContent: innerText} = node);␊ ` -## Invalid #8 +## Invalid #10 1 | ({innerText: text} = node); > Error 1/1 @@ -149,7 +163,21 @@ Generated by [AVA](https://avajs.dev). 1 | ({textContent: text} = node);␊ ` -## Invalid #9 +## 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/2 @@ -174,7 +202,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/2 diff --git a/test/snapshots/prefer-dom-node-text-content.mjs.snap b/test/snapshots/prefer-dom-node-text-content.mjs.snap index f1ec41d641264844cca641fe807e05e1c9fb6d57..a7c879175c24e9b5c4343957551245a99ce29086 100644 GIT binary patch literal 750 zcmV`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!72ed*%*+i&vjj-kCX6Iis24TAgG85r7gg(cXk zc|})lo!we>?dWMHu;^6|2$tqzV3=rJx!pVa<{CTyuc2iwoO_wTq9NQ6+{?qjFtc<| z>tD5(T#jpFN|$VY3N!;Gx`G#i5A!iFY)DjFA1^f_%A;xa#)qQIOBlhTpZFOV4z8)) zW%}Y<^nKMyZJ{S_7;>egHeKv1Iq25~T;5Kxqw zmRh8cpjQG^>ztoglA2eNppah%7K0m-pvT3fOJ%?nT$-MqT3nKupQm7`Z)l|uT%K8y zoS{&XkLDUZpv&R@LXtrE3?&@68KL2joS#=*qEHR@gp~qFb1hIC$Rw2T7@{Ep^&yfJ zx*t(O<_9c=zT4V!hcyUBLy_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