Skip to content

noExcessiveLinesPerFile (CSS)

  • Rule available since: v2.3.12
  • Diagnostic Category: lint/style/noExcessiveLinesPerFile
  • This rule isn’t recommended, so you need to enable it.
  • This rule doesn’t have a fix.
  • The default severity of this rule is information.
biome.json
{
"linter": {
"rules": {
"style": {
"noExcessiveLinesPerFile": "error"
}
}
}
}

Restrict the number of lines in a file.

Large stylesheets are harder to navigate and maintain. A line limit can encourage splitting unrelated styles into focused files.

This example reports a diagnostic when maxLines is 2:

biome.json
{
"linter": {
"rules": {
"style": {
"noExcessiveLinesPerFile": {
"level": "on",
"options": {
"maxLines": 2
}
}
}
}
}
}
.a { color: red; }
.b { color: blue; }
.c { color: green; }
code-block.css:1:1 lint/style/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.

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

Sets the maximum number of lines allowed in a file. Defaults to 300.

This example lowers the limit to 4 and reports a five-line file:

biome.json
{
"linter": {
"rules": {
"style": {
"noExcessiveLinesPerFile": {
"level": "on",
"options": {
"maxLines": 4
}
}
}
}
}
}
.a { color: red; }
.b { color: blue; }
.c { color: green; }
.d { color: yellow; }
.e { color: purple; }
code-block.css:1:1 lint/style/noExcessiveLinesPerFile ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

ℹ This file has too many lines (5). Maximum allowed is 4.

> 1 │ .a { color: red; }
│ ^^^^^^^^^^^^^^^^^^
> 2 │ .b { color: blue; }
> 3 │ .c { color: green; }
> 4 │ .d { color: yellow; }
> 5 │ .e { color: purple; }
│ ^^^^^^^^^^^^^^^^^^^^^
6 │

ℹ Consider splitting this file into smaller files.

Excludes blank lines from the line count when set to true. Defaults to false.

Here, the blank lines do not count toward the limit:

biome.json
{
"linter": {
"rules": {
"style": {
"noExcessiveLinesPerFile": {
"level": "on",
"options": {
"maxLines": 2,
"skipBlankLines": true
}
}
}
}
}
}
.a { color: red; }
.b { color: blue; }

If you need to exceed the line limit in a specific file, you can suppress this rule at the top of the file:

biome.json
{
"linter": {
"rules": {
"style": {
"noExcessiveLinesPerFile": {
"level": "on",
"options": {
"maxLines": 2
}
}
}
}
}
}
/* biome-ignore-all lint/style/noExcessiveLinesPerFile: generated file */
.a { color: red; }
.b { color: blue; }
.c { color: green; }