Skip to content

noExcessiveLinesPerFile

biome.json
{
"linter": {
"rules": {
"nursery": {
"noExcessiveLinesPerFile": "error"
}
}
}
}

Restrict the number of lines in a file.

Large files tend to do many things and can make it hard to follow what’s going on. This rule can help enforce a limit on the number of lines in a file.

The following example will show a diagnostic when maxLines is set to 2:

biome.json
{
"linter": {
"rules": {
"nursery": {
"noExcessiveLinesPerFile": {
"options": {
"maxLines": 2
}
}
}
}
}
}
.a { color: red; }
.b { color: blue; }
.c { color: green; }
code-block.css:1:1 lint/nursery/noExcessiveLinesPerFile ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

This file has too many lines (3). Maximum allowed is 2.

> 1 │ .a { color: red; }
^^^^^^^^^^^^^^^^^^
> 2 │ .b { color: blue; }
> 3 │ .c { color: green; }
^^^^^^^^^^^^^^^^^^^^
4 │

Consider splitting this file into smaller files.

This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

.a { color: red; }
.b { color: blue; }

This option sets the maximum number of lines allowed in a file. If the file exceeds this limit, a diagnostic will be reported.

Default: 300

When this option is set to true, blank lines are not counted towards the maximum line limit.

Default: false