Skip to content

Commit c178d29

Browse files
committed
Sync with ember-template-lint
1 parent 0577eb3 commit c178d29

1 file changed

Lines changed: 21 additions & 14 deletions

File tree

docs/rules/template-no-route-action.md

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
55
<!-- end auto-generated rule header -->
66

7-
Disallows the use of the `{{route-action}}` helper.
7+
This rule disallows the usage of `route-action`.
88

99
[ember-route-action-helper](https://github.com/DockYard/ember-route-action-helper) was a popular addon used to add actions to a route without creating a separate controller. Given the changes in Ember since ember-route-action-helper was a widely used pattern, controllers are now encouraged and we want to discourage the use of route-action.
1010

1111
Most route actions should either be sent to the controller first or encapsulated within a downstream component instead. We should never be escaping the DDAU hierarchy to lob actions up to the route.
1212

1313
## Examples
1414

15-
Examples of **incorrect** code for this rule:
15+
This rule **forbids** the following:
1616

1717
```hbs
1818
<CustomComponent @onUpdate={{route-action 'updateFoo'}} />
@@ -30,15 +30,19 @@ Examples of **incorrect** code for this rule:
3030
{{custom-component onUpdate=(route-action 'updateFoo' 'bar')}}
3131
```
3232

33-
```hbs
34-
{{route-action 'save'}}
35-
```
33+
With the given route:
3634

37-
```hbs
38-
<button {{on 'click' (route-action 'save')}}>Save</button>
35+
```js
36+
// app/routes/foo.js
37+
export default class extends Route {
38+
@action
39+
updateFoo(baz) {
40+
// ...
41+
}
42+
}
3943
```
4044

41-
Examples of **correct** code for this rule:
45+
This rule **allows** the following:
4246

4347
```hbs
4448
<CustomComponent @onUpdate={{this.updateFoo}} />
@@ -56,12 +60,16 @@ Examples of **correct** code for this rule:
5660
{{custom-component onUpdate=(fn this.updateFoo 'bar')}}
5761
```
5862

59-
```hbs
60-
<button {{on 'click' (fn this.save)}}>Save</button>
61-
```
63+
With the given controller:
6264

63-
```hbs
64-
<button {{on 'click' this.handleClick}}>Click</button>
65+
```js
66+
// app/controllers/foo.js
67+
export default class extends Controller {
68+
@action
69+
updateFoo(baz) {
70+
// ...
71+
}
72+
}
6573
```
6674

6775
## Migration
@@ -141,4 +149,3 @@ export default class extends Controller {
141149
- [ember-route-action-helper](https://github.com/DockYard/ember-route-action-helper)
142150
- [Ember guides/Controllers](https://guides.emberjs.com/release/routing/controllers/)
143151
- [Ember Best Practices: What are controllers good for?](https://dockyard.com/blog/2017/06/16/ember-best-practices-what-are-controllers-good-for)
144-
- [Ember.js Guides - Actions](https://guides.emberjs.com/release/components/component-state-and-actions/)

0 commit comments

Comments
 (0)