Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
191
rated 0 times [  196] [ 5]  / answers: 1 / hits: 61192  / 12 Years ago, fri, march 2, 2012, 12:00:00

I'm totally cool with this JSLint error. How can I tolerate it? Is there a flag or checkbox for it?



You get it when you do stuff like:



v && arr.push(v);


as opposed to:



if (v) {
arr.push(v);
}


Both do the same exact thing. If you put:



window.test = function(v) {
'use strict';
var arr = [];
if (v) {
arr.push(v);
}
return arr;
};


into the minifier it minifies down to this anyway:



window.test=function(a){var b=[];a&&b.push(a);return b};

More From » jslint

 Answers
9

I don't think JSLint has an option to turn that off.



JSHint (a fork with more options) has an option for it, though: The expr option, documented as if ExpressionStatement should be allowed as Programs.


[#87083] Thursday, March 1, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
malkajillc

Total Points: 652
Total Questions: 107
Total Answers: 98

Location: Finland
Member since Sat, Nov 6, 2021
3 Years ago
;