# max-lines-per-function

Rule `eslint/max-lines-per-function`. Enforce a maximum number of lines of code in a function

- 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: #1648 by reach

## Linters

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

## Code examples

### Incorrect: the rule reports this

```js
function foo() {
    const x = 0;
}
```

```js
function foo() {
    // a comment
    const x = 0;
}
```

```js
function foo() {
    // a comment followed by a blank line

    const x = 0;
}
```

### Correct: the rule accepts this

```js
function foo() {
    const x = 0;
}
```

```js
function foo() {
    // a comment
    const x = 0;
}
```

```js
function foo() {
    // a comment followed by a blank line

    const x = 0;
}
```

Examples from the ESLint documentation.

## Enable it

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

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

### Oxlint: `.oxlintrc.json`

```json
{
  "rules": {
    "max-lines-per-function": "error"
  }
}
```

### Biome: `biome.json`

```json
{
  "linter": {
    "rules": {
      "complexity": {
        "noExcessiveLinesPerFunction": "error"
      }
    }
  }
}
```

## Related rules

- [sonarjs/max-lines-per-function](https://lintradar.dev/rules/sonarjs/max-lines-per-function.md): Functions should not have too many lines of code
- [eslint/init-declarations](https://lintradar.dev/rules/eslint/init-declarations.md): Require or disallow initialization in variable declarations
- [eslint/max-statements](https://lintradar.dev/rules/eslint/max-statements.md): Enforce a maximum number of statements allowed in function blocks
- [eslint/no-magic-numbers](https://lintradar.dev/rules/eslint/no-magic-numbers.md): Disallow magic numbers
- [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`

---

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