# max-statements

Rule `eslint/max-statements`. Enforce a maximum number of statements allowed in function blocks

- Source: eslint
- Technologies: JavaScript
- Kind: style
- Needs type information: no
- Autofix: no
- Reach: 0 weekly downloads of presets that enable it
- Trend: 0% last quarter
- Rank: #1649 by reach

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `max-statements` | no | no | package `eslint` | [docs](https://eslint.org/docs/latest/rules/max-statements) |
| Oxlint | `max-statements` | no | no | plugin `eslint`, category style | [docs](https://oxc.rs/docs/guide/usage/linter/rules/eslint/max-statements.html) |
| Biome | `nursery/noExcessiveStatementsPerFunction` | no | no | group nursery, since 2.6.0 | [docs](https://biomejs.dev/linter/rules/no-excessive-statements-per-function/) |

## Code examples

### Incorrect: the rule reports this

```js
function foo() {
  const foo1 = 1;
  const foo2 = 2;
  const foo3 = 3;
  const foo4 = 4;
  const foo5 = 5;
  const foo6 = 6;
  const foo7 = 7;
  const foo8 = 8;
  const foo9 = 9;
  const foo10 = 10;

  const foo11 = 11; // Too many.
}

const bar = () => {
  const foo1 = 1;
  const foo2 = 2;
  const foo3 = 3;
  const foo4 = 4;
  const foo5 = 5;
  const foo6 = 6;
  const foo7 = 7;
  const foo8 = 8;
  const foo9 = 9;
  const foo10 = 10;

  const foo11 = 11; // Too many.
};
```

### Correct: the rule accepts this

```js
function foo() {
    let one;
    let two = class {
        static {
            let three;
            let four;
            let five;
            if (six) {
                let seven;
                let eight;
                let nine;
            }
        }
    };
}
```

```js
function foo() {
  const foo1 = 1;
  const foo2 = 2;
  const foo3 = 3;
  const foo4 = 4;
  const foo5 = 5;
  const foo6 = 6;
  const foo7 = 7;
  const foo8 = 8;
  const foo9 = 9;
  const foo10 = 10;
  const foo11 = 11;
}
```

Examples from the ESLint documentation.

## Enable it

### ESLint: `eslint.config.js`

```js
export default [
  {
    rules: {
      "max-statements": "error",
    },
  },
];
```

### Oxlint: `.oxlintrc.json`

```json
{
  "rules": {
    "max-statements": "error"
  }
}
```

### Biome: `biome.json`

```json
{
  "linter": {
    "rules": {
      "nursery": {
        "noExcessiveStatementsPerFunction": "error"
      }
    }
  }
}
```

## Related rules

- [eslint/max-lines-per-function](https://lintradar.dev/rules/eslint/max-lines-per-function.md): Enforce a maximum number of lines of code in a function
- [eslint/no-magic-numbers](https://lintradar.dev/rules/eslint/no-magic-numbers.md): Disallow magic numbers
- [eslint/init-declarations](https://lintradar.dev/rules/eslint/init-declarations.md): Require or disallow initialization in variable declarations
- [eslint/no-ternary](https://lintradar.dev/rules/eslint/no-ternary.md): Disallow ternary operators
- [eslint/require-atomic-updates](https://lintradar.dev/rules/eslint/require-atomic-updates.md): Disallow assignments that can lead to race conditions due to usage of `await` or `yield`
- [eslint/capitalized-comments](https://lintradar.dev/rules/eslint/capitalized-comments.md): Enforce or disallow capitalization of the first letter of a comment

---

Web page: https://lintradar.dev/rules/eslint/max-statements. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
