Skip to content

eslint/max-classes-per-file Pedantic

What it does

Enforce a maximum number of classes per file

Why is this bad?

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.

Example

javascript
class Foo {}
class Bar {}

How to use

To enable this rule in the CLI or using the config file, you can use:

bash
oxlint --deny max-classes-per-file
json
{
  "rules": {
    "max-classes-per-file": "error"
  }
}

References

Released under the MIT License.