Skip to content

Commit bdf2694

Browse files
committed
Update README and add additional docs for rule
1 parent d18b904 commit bdf2694

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ Rules are grouped by category to help you understand their purpose. Each rule ha
138138
| :car: | [no-actions-hash](./docs/rules/no-actions-hash.md) | disallow the actions hash in components, controllers, and routes |
139139
| :car: | [no-classic-classes](./docs/rules/no-classic-classes.md) | disallow "classic" classes in favor of native JS classes |
140140
| :white_check_mark::wrench: | [no-ember-super-in-es-classes](./docs/rules/no-ember-super-in-es-classes.md) | disallow use of `this._super` in ES class methods |
141+
| :car: | [no-empty-glimmer-component-classes](./docs/rules/no-empty-glimmer-component-classes.md) | disallow empty backing classes for Glimmer components |
141142

142143
### jQuery
143144

docs/rules/no-empty-glimmer-component-classes.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ This rule will catch and prevent the use of empty backing classes for Glimmer co
44

55
## Rule Details
66

7-
This rule aims to disallow the use of empty backing classes for Glimmer components. Template-only Glimmer components where there is no backing class are much faster and lighter-weight than Glimmer components with backing classes, which are much lighter-weight than Ember components. Therefore, you should only have a backing class for a Glimmer component when absolutely necessary. Otherwise, remove the backing class entirely until it is actually needed.
7+
This rule aims to disallow the use of empty backing classes for Glimmer components when possible. Template-only Glimmer components where there is no backing class are much faster and lighter-weight than Glimmer components with backing classes, which are much lighter-weight than Ember components. Therefore, you should only have a backing class for a Glimmer component when absolutely necessary.
8+
9+
In addons, the empty class should be replaced with a `templateOnly` export. This is because addons can't assume `template-only-glimmer-components` is enabled. In apps, remove the backing class entirely until it is actually needed.
810

911
## Examples
1012

@@ -28,6 +30,12 @@ class MyComponent extends Component {
2830
}
2931
```
3032

33+
```js
34+
import templateOnly from '@ember/component/template-only';
35+
36+
export default templateOnly();
37+
```
38+
3139
## References
3240

3341
* [Glimmer Components - Octane Upgrade Guide](https://guides.emberjs.com/release/upgrading/current-edition/glimmer-components/)

0 commit comments

Comments
 (0)