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

可紊 提交于 2019-12-02 20:14:24

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;

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

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!