> For AI agents: the complete documentation index is available at https://rslint.rs/llms.txt, the full documentation bundle is available at https://rslint.rs/llms-full.txt.

# max-lines

[Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0)
## Configuration


```ts title=rslint.config.ts
import { defineConfig, js } from '@rslint/core';

export default defineConfig([
  js.configs.recommended,
  {
    rules: {
      'max-lines': 'error',
    },
  },
]);
```

Enforce a maximum number of lines per file.

## Rule Details

Large files tend to do a lot of things and can make it hard to follow what's
going on. This rule caps the number of lines in a file.

With the `{ "max": 3 }` option:

```json
{ "max-lines": ["error", 3] }
```

Examples of **incorrect** code for this rule:

```javascript
let a,
    b,
    c,
    d;
```

Examples of **correct** code for this rule:

```javascript
let a,
    b,
    c;
```

## Options

This rule accepts a number (the maximum allowed) or an object with the
following properties:

- `max` (default `300`): the maximum number of lines allowed in a file.
- `skipBlankLines` (default `false`): ignore lines made up purely of
  whitespace.
- `skipComments` (default `false`): ignore lines containing just comments
  (a comment that shares a line with code does not exclude that line).

### `skipBlankLines`

```json
{ "max-lines": ["error", { "max": 2, "skipBlankLines": true }] }
```

Examples of **correct** code with the above configuration:

```javascript
var a = 1;


var b = 2;
```

### `skipComments`

```json
{ "max-lines": ["error", { "max": 2, "skipComments": true }] }
```

Examples of **correct** code with the above configuration:

```javascript
// a header comment
var a = 1;
var b = 2;
```

## Original Documentation

- [ESLint: max-lines](https://eslint.org/docs/latest/rules/max-lines)
- [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/max-lines.js)
