JS: add test for js/trivial-conditional

This commit is contained in:
Esben Sparre Andreasen
2019-02-07 09:04:07 +01:00
parent f956e570cb
commit 55fd948c24
2 changed files with 29 additions and 0 deletions

View File

@@ -33,3 +33,5 @@
| UselessConditionalGood.js:69:12:69:13 | xy | This use of variable 'xy' always evaluates to false. |
| UselessConditionalGood.js:85:12:85:13 | xy | This use of variable 'xy' always evaluates to false. |
| UselessConditionalGood.js:97:12:97:13 | xy | This use of variable 'xy' always evaluates to false. |
| UselessConditionalGood.js:114:8:114:8 | p | This use of variable 'p' always evaluates to false. |
| UselessConditionalGood.js:122:8:122:8 | p | This use of variable 'p' always evaluates to false. |

View File

@@ -99,3 +99,30 @@ function getLastLine(input) {
f10(undefined, undefined);
})();
(function(){
function g(p) {
return function() {
if (p) { // OK, whitelisted
g(p);
}
};
}
function f(p = false) {
return function() {
if (p) { // OK, whitelisted
f(p);
}
};
}
function h(p = false) {
(function() {
if (p) { // OK, whitelisted
}
});
}
h();
});