# Source: https://oxc.rs/docs/guide/usage/linter/rules/eslint/max-lines-per-function.md

---
url: /docs/guide/usage/linter/rules/eslint/max-lines-per-function.md
---

### What it does

Enforce a maximum number of lines of code in a function. This rule ensures
that functions do not exceed a specified line count, promoting smaller,
more focused functions that are easier to maintain and understand.

### Why is this bad?

Some people consider large functions a code smell. Large functions tend to
do a lot of things and can make it hard to follow what’s going on. Many coding
style guides dictate a limit to the number of lines that a function can
comprise of. This rule can help enforce that style.

### Examples

Examples of **incorrect** code for this rule with a particular max value:

```js
/* { "eslint/max-lines-per-function": ["error", 2] } */
function foo() {
  const x = 0;
}

/* { "eslint/max-lines-per-function": ["error", 4] } */
function foo() {
  // a comment followed by a blank line

  const x = 0;
}
```

Examples of **correct** code for this rule with a particular max value:

```js
/* { "eslint/max-lines-per-function": ["error", 3] } */
function foo() {
  const x = 0;
}

/* { "eslint/max-lines-per-function": ["error", 5] } */
function foo() {
  // a comment followed by a blank line

  const x = 0;
}
```

## Configuration

This rule accepts a configuration object with the following properties:

### IIFEs

type: `boolean`

default: `false`

The `IIFEs` option controls whether IIFEs are included in the line count.
By default, IIFEs are not considered, but when set to `true`, they will
be included in the line count for the function.

### max

type: `integer`

default: `50`

Maximum number of lines allowed in a function.

### skipBlankLines

type: `boolean`

default: `false`

Skip lines made up purely of whitespace.

### skipComments

type: `boolean`

default: `false`

Skip lines containing just comments.

## How to use

To **enable** this rule using the config file or in the CLI, you can use:

::: code-group

```json [Config (.oxlintrc.json)]
{
  "rules": {
    "max-lines-per-function": "error"
  }
}
```

```bash [CLI]
oxlint --deny max-lines-per-function
```

:::

## References

* Rule Source