Disable JSHint warning: Expected an assignment or function call and instead saw an expression
74,025
Solution 1
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;
Solution 2
Include a /* jshint expr: true */
comment in your Javascript.
Reference: http://jshint.com/docs/options/#expr
Author by
Naor
My name is Naor and I live in the holy city Jerusalem of Israel. I am 31 years old, married to my lovely Ilana and we have a female cat named Mutzi. I am working as web developer and I create web apps in my free time.
Updated on April 22, 2020Comments
-
Naor about 4 years
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?