only flag unused array-destructs if it is the last variable

This commit is contained in:
Erik Krogh Kristensen
2020-09-02 11:19:50 +02:00
parent 29b3759655
commit a24db09418
3 changed files with 37 additions and 0 deletions

View File

@@ -1 +1,4 @@
| tst.js:4:7:4:11 | let x | For loop variable x is not used in the loop body. |
| tst.js:138:6:138:23 | const [key, value] | For loop variable value is not used in the loop body. |
| tst.js:151:6:151:35 | const [ ... value] | For loop variable value is not used in the loop body. |
| tst.js:152:6:152:10 | let i | For loop variable i is not used in the loop body. |

View File

@@ -133,3 +133,20 @@ function countOccurrencesDead(xs, p) {
a;
}
});
// NOT OK
for (const [key, value] of array) {}
// OK: for array-destructurings we only flag the last element
for (const [key, value] of array) {
console.log(value)
}
// OK: for array-destructurings we only flag the last element
for (const [key, key2, key3, value] of array) {
console.log(value)
}
// NOT OK
for (const [key, key2, key3, value] of array) {}
for (let i of [1, 2]) {}