add query for detecting ignored calls to Array.prototype.concat

This commit is contained in:
Erik Krogh Kristensen
2019-10-10 16:20:27 +02:00
parent 4b27b2ac05
commit 5489a80372
8 changed files with 113 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
| tst.js:3:1:3:19 | arr.concat([1,2,3]) | Return value from call to concat ignored. |
| tst.js:5:1:5:15 | arr.concat(arr) | Return value from call to concat ignored. |

View File

@@ -0,0 +1 @@
Statements/IgnoreConcatReturn.ql

View File

@@ -0,0 +1,13 @@
var arr = [1,2,3];
arr.concat([1,2,3]); // NOT OK!
arr.concat(arr); // NOT OK!
console.log(arr.concat([1,2,3]));
arr.concat(null);
arr.concat();
arr.concat([]);
({concat: Array.prototype.concat}.concat(arr));