functional/no-expression-statements
March 2, 2026 Β· View on GitHub
π Disallow expression statements.
πΌπ« This rule is enabled in the following configs:
noStatements, β
recommended, π strict. This rule is disabled in the βοΈ lite config.
π This rule requires type information.
This rule checks that the value of an expression is assigned to a variable and thus helps promote side-effect free (pure) functions.
Rule Details
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.
β Incorrect
/* eslint functional/no-expression-statements: "error" */
console.log("Hello world!");
/* eslint functional/no-expression-statements: "error" */
array.push(3);
/* eslint functional/no-expression-statements: "error" */
foo(bar);
β Correct
/* eslint functional/no-expression-statements: "error" */
const baz = foo(bar);
/* eslint functional/no-expression-statements: ["error", { "ignoreVoid": true }] */
console.log("hello world");
Options
This rule accepts an options object of the following type:
type Options = {
ignoreCodePattern?: string[] | string;
ignoreVoid?: boolean;
ignoreSelfReturning?: boolean;
};
Default Options
const defaults = {
ignoreVoid: false,
ignoreSelfReturning: false,
};
ignoreVoid
When enabled, expression of type void and Promise<void> are not flagged as violations.
This options requires TypeScript in order to work.
ignoreSelfReturning
Like ignoreVoid but instead does not flag function calls that always only return this.
Limitation: The function declaration must explicitly use return this; equivalents
(such as assign this to a variable first, that is then returned) won't be considered valid.
ignoreCodePattern
This option takes a RegExp string or an array of RegExp strings. It allows for the ability to ignore violations based on the code itself.