This rule checks that the value of an expression is assigned to a variable and thus helps promote side-effect free (pure) functions.
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.
Examples of incorrect code for this rule:
/* eslint functional/no-expression-statement: "error" */
console.log("Hello world!");
/* eslint functional/no-expression-statement: "error" */
array.push(3);
/* eslint functional/no-expression-statement: "error" */
foo(bar);
Examples of correct code for this rule:
/* eslint functional/no-expression-statement: "error" */
const baz = foo(bar);
/* eslint functional/no-expression-statement: ["error", { "ignoreVoid": true }] */
console.log("hello world");
This rule accepts an options object of the following type:
{
ignorePattern?: string | Array<string>;
ignoreVoid?: boolean
}
The default options:
{
ignoreVoid: false
}
When enabled, expression of type void are not flagged as violations. This options requires TypeScript in order to work.
Patterns will be matched against the line(s) of code. See the ignorePattern docs for more information.