noExcessiveClassesPerFile
Это содержимое пока не доступно на вашем языке.
Summary
Section titled “Summary”- Rule available since:
v2.3.12 - Diagnostic Category:
lint/nursery/noExcessiveClassesPerFile - This rule doesn’t have a fix.
- The default severity of this rule is information.
- Sources:
- Same as
max-classes-per-file
- Same as
How to configure
Section titled “How to configure”{ "linter": { "rules": { "nursery": { "noExcessiveClassesPerFile": "error" } } }}Description
Section titled “Description”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.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”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 {}Options
Section titled “Options”The following options are available:
maxClasses
Section titled “maxClasses”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
{ "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.
Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.