This rule should be combined with ESLint's built-in no-var
rule to enforce that all variables are declared as const
.
In functional programming variables should not be mutable; use const
instead.
Examples of incorrect code for this rule:
/* eslint functional/no-let: "error" */
let x = 5;
/* eslint functional/no-let: "error" */
for (let i = 0; i < array.length; i++) {
}
Examples of correct code for this rule:
/* eslint functional/no-let: "error" */
const x = 5;
/* eslint functional/no-let: "error" */
for (const element of array) {
}
/* eslint functional/no-let: "error" */
for (const [index, element] of array.entries()) {
}
This rule accepts an options object of the following type:
{
allowLocalMutation: boolean;
ignorePattern?: string | Array<string>;
}
The default options:
{
allowLocalMutation: false
}
See the allowLocalMutation docs.
Patterns will be matched against variable names. See the ignorePattern docs.