noExcessiveLinesPerFile
Este conteúdo não está disponível em sua língua ainda.
Summary
Section titled “Summary”- Diagnostic Category:
lint/nursery/noExcessiveLinesPerFile - This rule doesn’t have a fix.
- The default severity of this rule is information.
- Sources:
- Inspired from
max-lines
- Inspired from
How to configure
Section titled “How to configure”{ "linter": { "rules": { "nursery": { "noExcessiveLinesPerFile": "error" } } }}Description
Section titled “Description”Restrict the number of lines in a file.
This rule checks the number of lines in a file and reports a diagnostic if it exceeds a specified limit. Some people consider large files a code smell. Large files tend to do many things and can make it hard to follow what’s going on. Many coding style guides dictate a limit of the number of lines that a file can comprise of. This rule can help enforce that style.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”The following example will show a diagnostic when maxLines is set to 2:
{ "linter": { "rules": { "nursery": { "noExcessiveLinesPerFile": { "options": { "maxLines": 2 } } } } }}const a = 1;const b = 2;const c = 3;code-block.js:1:1 lint/nursery/noExcessiveLinesPerFile ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ This file has too many lines (3). Maximum allowed is 2.
> 1 │ const a = 1;
│ ^^^^^^^^^^^^
> 2 │ const b = 2;
> 3 │ const c = 3;
│ ^^^^^^^^^^^^
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.
const a = 1;const b = 2;Options
Section titled “Options”The following options are available:
maxLines
Section titled “maxLines”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 maxLines: 2, the following file will be considered invalid:
{ "linter": { "rules": { "nursery": { "noExcessiveLinesPerFile": { "options": { "maxLines": 2 } } } } }}const a = 1;const b = 2;const c = 3;code-block.js:1:1 lint/nursery/noExcessiveLinesPerFile ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ This file has too many lines (3). Maximum allowed is 2.
> 1 │ const a = 1;
│ ^^^^^^^^^^^^
> 2 │ const b = 2;
> 3 │ const c = 3;
│ ^^^^^^^^^^^^
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.
skipBlankLines
Section titled “skipBlankLines”When this option is set to true, blank lines are not counted towards the maximum line limit.
This means that only lines with actual code or comments will be counted.
Default: false
When maxLines: 3 and skipBlankLines: true, the following file will be considered valid
even though it has 5 total lines, because only 3 lines contain code:
{ "linter": { "rules": { "nursery": { "noExcessiveLinesPerFile": { "options": { "maxLines": 3, "skipBlankLines": true } } } } }}const a = 1;
const b = 2;
const c = 3;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": { "nursery": { "noExcessiveLinesPerFile": { "options": { "maxLines": 2 } } } } }}// biome-ignore lint/nursery/noExcessiveLinesPerFile: generated fileconst a = 1;const b = 2;const c = 3;Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.