Skip to content

Latest commit

 

History

History
73 lines (48 loc) · 1.19 KB

no-let.md

File metadata and controls

73 lines (48 loc) · 1.19 KB

Disallow mutable variables (no-let)

This rule should be combined with ESLint's built-in no-var rule to enforce that all variables are declared as const.

Rule Details

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()) {
}

Options

This rule accepts an options object of the following type:

{
  allowLocalMutation: boolean;
  ignorePattern?: string | Array<string>;
}

The default options:

{
  allowLocalMutation: false
}

allowLocalMutation

See the allowLocalMutation docs.

ignorePattern

Patterns will be matched against variable names. See the ignorePattern docs.