Expected an assignment or function call and instead saw an expression
55 grid.removeAll(false);
56 section.items.forEach(({ id }) => {
57 const ref = refs.items.current[id]?.current;
58 ref && grid.makeWidget(ref);59 });
60 grid.batchUpdate(false);
61 return true;
Description
An unused expression that does not affect the state of the program indicates a logic error.
For example, if a programmer wants to increment the value of a variable a
by one, and intends to do so through this code:
let a = 0
a = a + 1
console.log(a) // output 1
But because of a typo, writes the following:
let a = 0
a + 1
console.log(a)
Here, the expression a + 1
does nothing meaningful in the program's runtime.
The expression is thus considered "unused" and should be removed.
Bad Practice
0
if(0) 0
{0}
f(0), {}
a, b()
c = a, b;
a() && function namedFunctionInExpressionContext () {f();}
(function anIncompleteIIFE () {});
injectGlobal`body{ color: red; }`
Recommended
{} // In this context, this is a block statement, not an object literal
{myLabel: someVar} // In this context, this is a block statement with a label and expression, not an object literal
function namedFunctionDeclaration () {}
(function aGenuineIIFE () {}());
f()
a = 0
new C
delete a.b
void a