-
Notifications
You must be signed in to change notification settings - Fork 19
Description
Alternate title: Disallow function calls whose return values are discarded.
Based on this blog post, when you call a function and don’t use it’s return value, chances are high that it is being called for its side effect. e.g.
array.push(1)
alert('Hello world!')Thinking it further, I found this to be an expansion of no-unused-expressions rule, but with every ExpressionStatement disallowed, even if it only contains a CallExpression.
Disallowing SequenceExpression may also make sense because there’s no point in evaluating a, b in (a, b, c) except for the side-effects caused by evaluating a and b.
I think this can also potentially fix #2.
As a result, every expression that gets evaluated must either go into a constant or returned. If we also ensure that there are no-unused-vars, we can get a pure-functional-language-like semantic.