Skip to content

Commit 6a1f6be

Browse files
committed
More docs
1 parent 0e15c92 commit 6a1f6be

49 files changed

Lines changed: 626 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/rules/template-no-action.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ Examples of **correct** code for this rule:
4747
- Replace `(action "methodName")` with method references or `(fn this.methodName)`
4848
- Replace `<button onclick={{action ...}}>` with `<button {{on "click" ...}}>`
4949

50+
## Related Rules
51+
52+
* [no-action-modifiers](template-no-action-modifiers.md)
53+
* [no-element-event-actions](template-no-element-event-actions.md)
54+
* [no-mut-helper](template-no-mut-helper.md)
55+
5056
## References
5157

5258
- [eslint-plugin-ember template-no-action](https://github.com/ember-cli/eslint-plugin-ember/blob/master/docs/rules/template-no-action.md)

docs/rules/template-no-at-ember-render-modifiers.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,31 @@ Examples of **correct** code for this rule:
3838
</template>
3939
```
4040

41+
## Migration
42+
43+
The migration path typically depends on what the render-modifier was used for, but if you need a custom modifier, the [`ember-modifier` README](https://github.com/ember-modifier/ember-modifier) covers everything you need to know for making custom modifiers.
44+
45+
For example, if render modifiers were used for setup/teardown, the migration to `ember-modifier` could be the following:
46+
47+
```js
48+
import Component from '@glimmer/component';
49+
import { modifier } from 'ember-modifier';
50+
51+
export default class MyComponent extends Component {
52+
myModifier = modifier((element) => {
53+
let handleEvent = () => {};
54+
55+
element.addEventListener('eventName', handleEvent);
56+
57+
return () => element.removeEventListener('eventName', handelEvent);
58+
});
59+
}
60+
```
61+
62+
```hbs
63+
<div {{this.myModifier}}>
64+
```
65+
4166
## References
4267

4368
- [eslint-plugin-ember template-no-at-ember-render-modifiers](https://github.com/ember-cli/eslint-plugin-ember/blob/master/docs/rules/template-no-at-ember-render-modifiers.md)

docs/rules/template-no-block-params-for-html-elements.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ This rule disallows using block params on HTML elements. Use components if you n
6262
</template>
6363
```
6464

65+
## Migration
66+
67+
- Remove the unused block parameters or fix the tag name to refer to a component
68+
6569
## Related Rules
6670

6771
- [template-no-arguments-for-html-elements](./template-no-arguments-for-html-elements.md)

docs/rules/template-no-builtin-form-components.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,67 @@ This rule **allows** the following:
2626
<template><textarea {{on "input" this.handleInput}}>{{this.body}}</textarea></template>
2727
```
2828

29+
## Migration
30+
31+
Many forms may be simplified by switching to a light one-way data approach.
32+
33+
For example – vanilla JavaScript has everything we need to handle form data, de-sync it from our source data and collect all user input in a single object.
34+
35+
```js
36+
import Component from '@glimmer/component';
37+
import { tracked } from '@glimmer/tracking';
38+
import { action } from '@ember/object';
39+
40+
export default class MyComponent extends Component {
41+
@tracked userInput = {};
42+
43+
@action
44+
handleInput(event) {
45+
const formData = new FormData(event.currentTarget);
46+
this.userInput = Object.fromEntries(formData.entries());
47+
}
48+
}
49+
```
50+
51+
```hbs
52+
<form {{on "input" this.handleInput}}>
53+
<label> Name
54+
<input name="name">
55+
</label>
56+
</form>
57+
```
58+
59+
Another option would is to "control" the field's value by replacing the built-in form component with a native HTML element and binding an event listener to handle user input.
60+
61+
In the following example the initial value of a field is controlled by a local tracked property, which is updated by an event listener.
62+
63+
```js
64+
import Component from '@glimmer/component';
65+
import { tracked } from '@glimmer/tracking';
66+
import { action } from '@ember/object';
67+
68+
export default class MyComponent extends Component {
69+
@tracked name;
70+
71+
@action
72+
updateName(event) {
73+
this.name = event.target.value;
74+
}
75+
}
76+
```
77+
78+
```hbs
79+
<input
80+
type="text"
81+
value={{this.name}}
82+
{{on "input" this.updateName}}
83+
/>
84+
```
85+
86+
## Related Rules
87+
88+
* [no-mut-helper](template-no-mut-helper.md)
89+
2990
## References
3091

3192
- [Ember Built-in Components](https://guides.emberjs.com/release/components/built-in-components/)

docs/rules/template-no-chained-this.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@ Using `this.this.*` in templates is almost always a typo or copy/paste mistake.
1212

1313
This rule disallows `this.this.*` patterns in templates (e.g., `{{this.this.foo}}` or `<this.this.Bar />`).
1414

15+
## Motivation
16+
17+
Templates are meant to clearly reference local properties, arguments (`@arg`), or component state via `this`. When you see `this.this.foo`, it's either:
18+
19+
- A typo (e.g., copy/paste or incorrect refactor)
20+
- A misunderstanding of Glimmer component boundaries
21+
- A misuse of dynamic component invocation (e.g., `<this.this.foo />`)
22+
23+
These patterns often go unnoticed but produce confusing or broken runtime behavior.
24+
1525
## Examples
1626

1727
### Incorrect ❌

docs/rules/template-no-class-bindings.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ This rule **allows** the following:
3030
<template><SomeThing /></template>
3131
```
3232

33+
## Migration
34+
35+
- find in templates and remove `classBinding` and/or `classNameBindings`.
36+
3337
## References
3438

3539
- [ember-template-lint no-class-bindings](https://github.com/ember-template-lint/ember-template-lint/blob/master/docs/rule/no-class-bindings.md)

docs/rules/template-no-curly-component-invocation.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ This rule **allows** the following:
4646
<template><Nested::Component /></template>
4747
```
4848

49+
## Migration
50+
51+
- use <https://github.com/ember-codemods/ember-angle-brackets-codemod>
52+
4953
## Configuration
5054

5155
This rule accepts an options object with the following properties:

docs/rules/template-no-element-event-actions.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ Examples of **correct** code for this rule:
4444
| --------------------- | --------- | ------- | ----------------------------------------------------------------------------------------------------------------- |
4545
| `requireActionHelper` | `boolean` | `false` | When `true`, only flags events using `{{action ...}}`; when `false`, flags any dynamic value on event attributes. |
4646

47+
## Related Rules
48+
49+
* [no-action](template-no-action.md)
50+
* [no-action-modifiers](template-no-action-modifiers.md)
51+
4752
## References
4853

4954
- [Ember Octane migration guide](https://guides.emberjs.com/release/upgrading/current-edition/action-on-and-fn/)

docs/rules/template-no-html-comments.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,8 @@ Examples of **correct** code for this rule:
3434
<div>Content</div>
3535
</template>
3636
```
37+
38+
## References
39+
40+
* [Ember guides/template features](https://guides.emberjs.com/release/components/#toc_supported-features)
41+
* [Handlebars docs/comments](https://handlebarsjs.com/guide/#template-comments)

docs/rules/template-no-implicit-this.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,17 @@ Require explicit `this` for property access in templates to avoid ambiguity.
88

99
This rule requires explicitly using `this.` prefix for component properties and `@` prefix for named arguments in templates, avoiding ambiguous property references.
1010

11+
## Motivation
12+
13+
Currently, the way to access properties on a components class is `{{greeting}}`
14+
from a template. This works because the component class is one of the objects
15+
we resolve against during the evaluation of the expression.
16+
17+
The first problem with this approach is that the `{{greeting}}` syntax is
18+
ambiguous, as it could be referring to a local variable (block param), a helper
19+
with no arguments, a closed over component, or a property on the component
20+
class.
21+
1122
## Examples
1223

1324
Examples of **incorrect** code for this rule:
@@ -42,6 +53,12 @@ Examples of **correct** code for this rule:
4253
</template>
4354
```
4455

56+
## Migration
57+
58+
* use [ember-no-implicit-this-codemod](https://github.com/ember-codemods/ember-no-implicit-this-codemod)
59+
* [upgrade to Glimmer components](https://guides.emberjs.com/release/upgrading/current-edition/glimmer-components/), which don't allow ambiguous access
60+
* classic components have [auto-reflection](https://github.com/emberjs/rfcs/blob/master/text/0276-named-args.md#motivation), and can use `this.myArgName` or `this.args.myArgNme` or `@myArgName` interchangeably
61+
4562
## References
4663

4764
- [Ember Octane Guide - Templates](https://guides.emberjs.com/release/components/component-state-and-actions/)

0 commit comments

Comments
 (0)