Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs (max-elements-per-file): add docs #109

Merged
merged 1 commit into from
Aug 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions docs/rules/max-elements-per-file.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Enforces a maximum number of elements per file (max-elements-per-file)

This rule disallows creating multiple `HTMLElement` classes in a single file.

## Rule Details

👎 Examples of **incorrect** code for this rule:

```js
// elements.ts
class FirstElement extends HTMLElement {}
class SecondElement extends HTMLElement {}
```

👍 Examples of **correct** code for this rule:

```js
// first-element.ts
class FirstElement extends HTMLElement {}
```

```js
// second-element.ts
class SecondElement extends HTMLElement {}
```

Declaring multiple Custom Elements per file can:

- Result in large files which are difficult to navigate.
- Make a project difficult to navigate, as Custom Elements do not have a 1-1
mapping with files.
- Make it more difficult for bundle optimizations such as "Tree Shaking",
"Bundle Splitting" or "Dead Code Elimination"

Having one element per file eliminates these problems.

## When Not To Use It

If you intentionally want multiple elements in a single file then you can
disable this rule.
Loading