noExcessiveLinesPerFile (HTML)
Summary
Section titled “Summary”- Rule available since:
v2.5.0 - 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.
How to configure
Section titled “How to configure”{ "linter": { "rules": { "style": { "noExcessiveLinesPerFile": "error" } } }}Description
Section titled “Description”Restrict the number of lines in a file.
Large HTML and component files are harder to navigate and maintain. A line limit can encourage splitting unrelated markup into focused components or templates.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”This example reports a diagnostic when maxLines is 2:
{ "linter": { "rules": { "style": { "noExcessiveLinesPerFile": { "level": "on", "options": { "maxLines": 2 } } } } }}<div></div><span></span><p></p>code-block.html:1:1 lint/style/noExcessiveLinesPerFile ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ This file has too many lines (3). Maximum allowed is 2.
> 1 │ <div></div>
│ ^^^^^^^^^^^
> 2 │ <span></span>
> 3 │ <p></p>
│ ^^^^^^^
4 │
ℹ Consider splitting this file into smaller files.
<div></div><span></span>Options
Section titled “Options”maxLines
Section titled “maxLines”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:
{ "linter": { "rules": { "style": { "noExcessiveLinesPerFile": { "level": "on", "options": { "maxLines": 4 } } } } }}<div>Line 1</div><div>Line 2</div><div>Line 3</div><div>Line 4</div><div>Line 5</div>code-block.html:1:1 lint/style/noExcessiveLinesPerFile ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ This file has too many lines (5). Maximum allowed is 4.
> 1 │ <div>Line 1</div>
│ ^^^^^^^^^^^^^^^^^
> 2 │ <div>Line 2</div>
> 3 │ <div>Line 3</div>
> 4 │ <div>Line 4</div>
> 5 │ <div>Line 5</div>
│ ^^^^^^^^^^^^^^^^^
6 │
ℹ Consider splitting this file into smaller files.
skipBlankLines
Section titled “skipBlankLines”Excludes blank lines from the line count when set to true. Defaults to false.
Here, the blank lines do not count toward the limit:
{ "linter": { "rules": { "style": { "noExcessiveLinesPerFile": { "level": "on", "options": { "maxLines": 2, "skipBlankLines": true } } } } }}<div></div>
<span></span>Suppressions
Section titled “Suppressions”If you need to exceed the line limit in a specific file, you can suppress this rule at the top of the file:
{ "linter": { "rules": { "style": { "noExcessiveLinesPerFile": { "level": "on", "options": { "maxLines": 2 } } } } }}<!-- biome-ignore-all lint/style/noExcessiveLinesPerFile: generated file --><div></div><span></span><p></p>Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.