Pular para o conteúdo

noExcessiveClassesPerFile

Este conteúdo não está disponível em sua língua ainda.

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

Enforce a maximum number of classes per file.

Files containing multiple classes can often result in a less navigable and poorly structured codebase. Best practice is to keep each file limited to a single responsibility.

class Foo {}
class Bar {}
code-block.js:1:1 lint/nursery/noExcessiveClassesPerFile ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

File exceeds the maximum of 1 class, found 2 classes.

> 1 │ class Foo {}
^^^^^^^^^^^^
> 2 │ class Bar {}
^^^^^^^^^^^^
3 │

Files containing multiple classes can often result in a less navigable and poorly structured codebase. Extract the excessive classes into a separate file.

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.

class Foo {}

The following options are available:

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

Default: 1

biome.json
{
"linter": {
"rules": {
"nursery": {
"noExcessiveClassesPerFile": {
"options": {
"maxClasses": 2
}
}
}
}
}
}
class Foo {}
class Bar {}
class Baz {}
code-block.js:1:1 lint/nursery/noExcessiveClassesPerFile ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

File exceeds the maximum of 2 classes, found 3 classes.

> 1 │ class Foo {}
^^^^^^^^^^^^
> 2 │ class Bar {}
> 3 │ class Baz {}
^^^^^^^^^^^^
4 │

Files containing multiple classes can often result in a less navigable and poorly structured codebase. Extract the excessive classes into a separate file.

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.