This repository has been archived by the owner on Nov 10, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 243
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: Add max-classes-per-file to main rules directory
This fixes a broken link in docs/rules index. Root cause is eslint/eslint-release#22
- Loading branch information
1 parent
cec908b
commit 81da35f
Showing
1 changed file
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
--- | ||
title: max-classes-per-file - Rules | ||
layout: doc | ||
edit_link: https://github.com/eslint/eslint/edit/master/docs/rules/max-classes-per-file.md | ||
--- | ||
<!-- Note: No pull requests accepted for this file. See README.md in the root directory for details. --> | ||
|
||
# enforce a maximum number of classes per file (max-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. | ||
|
||
## Rule Details | ||
|
||
This rule enforces that each file may contain only a particular number | ||
of classes and no more. | ||
|
||
Examples of **incorrect** code for this rule: | ||
|
||
```js | ||
/*eslint max-classes-per-file: "error"*/ | ||
|
||
class Foo {} | ||
class Bar {} | ||
``` | ||
|
||
Examples of **correct** code for this rule: | ||
|
||
```js | ||
/*eslint max-classes-per-file: "error"*/ | ||
|
||
class Foo {} | ||
``` | ||
|
||
## Options | ||
|
||
This rule has a numeric option (defaulted to 1) to specify the | ||
maximum number of classes. | ||
|
||
For example: | ||
|
||
```json | ||
{ | ||
"max-classes-per-file": ["error", 1] | ||
} | ||
``` | ||
|
||
Examples of **correct** code for this rule with the numeric option set to `2`: | ||
|
||
```js | ||
/* eslint max-classes-per-file: ["error", 2] */ | ||
|
||
class Foo {} | ||
class Bar {} | ||
``` | ||
|
||
## Version | ||
|
||
This rule was introduced in ESLint 5.0.0-alpha.3. | ||
|
||
## Resources | ||
|
||
* [Rule source](https://github.com/eslint/eslint/tree/master/lib/rules/max-classes-per-file.js) | ||
* [Documentation source](https://github.com/eslint/eslint/tree/master/docs/rules/max-classes-per-file.md) |