Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable JSHint warning: Expected an assignment or function call and instead saw an expression [duplicate]

I have the following line:

imageUrl && (data.imageUrl = imageUrl); 

For this line, JSHint complains:

 Expected an assignment or function call and instead saw an expression. 

I understand the warning, but I want to disable it. I can’t find the way how to do it. Any idea?

like image 737
Naor Avatar asked Dec 23 '14 16:12

Naor


2 Answers

If it really is just that one line

imageUrl && (data.imageUrl = imageUrl); // jshint ignore:line 

I am a fan of writing code so it doesn't produce warnings, though, even if this means taking special action to do so. So I'd prefer

if (imageUrl) data.imageUrl = imageUrl; 
like image 75
The Archetypal Paul Avatar answered Sep 28 '22 02:09

The Archetypal Paul


Include a /* jshint expr: true */ comment in your Javascript.

Reference: http://jshint.com/docs/options/#expr

like image 37
Paul Roub Avatar answered Sep 28 '22 00:09

Paul Roub