Expected an assignment or function call and instead saw an expression

断了今生、忘了曾经 提交于 2019-11-29 23:42:44

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".

You can add the following line to ignore that warning:

/*jshint -W030 */

You can read more about it here.

There's no option for this in JSLint. You can circumvent it using:

var dummy = v && arr.push(v);

NB: dummy evaluates to true after that.

Another workaround could be:

function expression(statement) { 
 'use strict';
 return statement; 
}
expression(v && arr.push);

People who are looking how to suppress it when using ESLint. You can ingnore it by writing the following comment just above the line.

// eslint-disable-next-line no-unused-expressions

You can also suppress the warning for the entire file by placing the following comment at the very top of the file

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