Disallow Unused Expressions (no-unused-expressions)

Unused expressions are those expressions that evaluate to a value but are never used. For example:

"Hello world";

This string is a valid JavaScript expression, but isn’t actually used. Even though it’s not a syntax error it is clearly a logic error and it has no effect on the code being executed.

Rule Details

This rule aims to eliminate unused expressions. The value of an expression should always be used, except in the case of expressions that side effect: function calls, assignments, and the new operator.

The following patterns are considered warnings:

if(0) 0
f(0), {}
a && b()

The following patterns are not considered warnings:

a = 0
new C
delete a.b
void a


This rule was introduced in ESLint 0.1.0.