Skip to content

Commit e04a1aa

Browse files
committed
Updates
1 parent 70951cf commit e04a1aa

32 files changed

Lines changed: 433 additions & 103 deletions

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ rules in templates can be disabled with eslint directives with mustache or html
422422
| :------------------------------------------------------------------------------------------------------------------------- | :-------------------------------------------------------- | :- | :- | :- |
423423
| [template-no-extra-mut-helper-argument](docs/rules/template-no-extra-mut-helper-argument.md) | disallow passing more than one argument to the mut helper | | | |
424424
| [template-no-jsx-attributes](docs/rules/template-no-jsx-attributes.md) | disallow JSX-style camelCase attributes | | 🔧 | |
425-
| [template-no-scope-outside-table-headings](docs/rules/template-no-scope-outside-table-headings.md) | disallow scope attribute outside th/td elements | | | |
425+
| [template-no-scope-outside-table-headings](docs/rules/template-no-scope-outside-table-headings.md) | disallow scope attribute outside th elements | | | |
426426
| [template-no-shadowed-elements](docs/rules/template-no-shadowed-elements.md) | disallow shadowing of built-in HTML elements | | | |
427427
| [template-no-unbalanced-curlies](docs/rules/template-no-unbalanced-curlies.md) | disallow unbalanced mustache curlies | | | |
428428
| [template-no-unknown-arguments-for-builtin-components](docs/rules/template-no-unknown-arguments-for-builtin-components.md) | disallow unknown arguments for built-in components | | | |

docs/rules/template-deprecated-inline-view-helper.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,26 @@ In Ember 1.12, support for invoking the inline View helper was deprecated.
88

99
## Rule Details
1010

11-
This rule flags `{{view}}` mustache or block statements that have hash pair arguments (e.g., `{{view 'foo' key=value}}`). Simple `{{view.property}}` path expressions or other usages without hash pairs are not flagged.
11+
This rule flags:
12+
13+
- `{{view}}` mustache or block statements that have params or hash pair arguments (e.g., `{{view 'foo'}}`, `{{view 'foo' key=value}}`).
14+
- `{{view.property}}` path expressions (e.g., `{{view.also-bad}}`).
15+
- Hash values referencing `view.*` paths (e.g., `please=view.stop`).
1216

1317
## Examples
1418

1519
This rule **forbids** the following:
1620

1721
```hbs
18-
{{view 'this-is-bad' tagName='span'}}
22+
{{view 'this-is-bad'}}
23+
24+
{{view.also-bad}}
25+
26+
{{qux-qaz please=view.stop}}
1927
20-
{{#view tagName='span'}}content{{/view}}
28+
{{#not-this please=view.stop}}{{/not-this}}
29+
30+
<div foo={{view.bar}}></div>
2131
```
2232

2333
This rule **allows** the following:
@@ -27,6 +37,8 @@ This rule **allows** the following:
2737
2838
{{qux-qaz this=good}}
2939
40+
{{#ok-this yay=nice}}{{/ok-this}}
41+
3042
<div foo={{bar}}></div>
3143
```
3244

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,23 @@ This rule disallows using `{{action}}` as an element modifier.
4242
<form {{on 'submit' this.handleSubmit}}>Submit</form>
4343
```
4444

45+
## Configuration
46+
47+
The following values are valid configuration:
48+
49+
- boolean -- `true` for enabled / `false` for disabled
50+
- array -- an allowlist of element tag names, which will accept action modifiers
51+
52+
For example, to allow action modifiers only on specific elements:
53+
54+
```js
55+
module.exports = {
56+
rules: {
57+
'ember/template-no-action-modifiers': ['error', { allowlist: ['form'] }],
58+
},
59+
};
60+
```
61+
4562
## Related Rules
4663

4764
- [template-no-action](./template-no-action.md)

docs/rules/template-no-action-on-submit-button.md

Lines changed: 28 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,56 +2,48 @@
22

33
<!-- end auto-generated rule header -->
44

5-
Disallow `action` attribute on submit buttons.
5+
Disallow click action on submit buttons within a form.
66

7-
Using the `action` attribute on submit buttons is a common mistake. Instead, you should use the `{{on}}` modifier to handle click events, or handle form submission at the form level.
7+
In a `<form>`, all `<button>` elements with a `type="submit"` attribute (or no `type`, since buttons default to `type="submit"`) should not have any click action. The action should be on the `<form>` element instead of directly on the button.
88

99
## Rule Details
1010

11-
This rule disallows using the `action` attribute on `<button>` elements (which default to type="submit") and `<input type="submit">` elements.
11+
This rule disallows:
1212

13-
## Examples
14-
15-
### Incorrect ❌
13+
- Using `{{action}}` or `{{on "click"}}` modifiers on submit buttons inside a `<form>`.
14+
- Using the HTML `action` attribute on submit buttons or `<input type="submit">` elements.
1615

17-
```gjs
18-
<template>
19-
<button action="save">Save</button>
20-
</template>
21-
```
16+
## Examples
2217

23-
```gjs
24-
<template>
25-
<button type="submit" action="submit">Submit</button>
26-
</template>
27-
```
18+
### Incorrect
2819

29-
```gjs
30-
<template>
31-
<input type="submit" action="go" />
32-
</template>
20+
```hbs
21+
<form>
22+
<button type='submit' {{on 'click' this.handleClick}} />
23+
<button type='submit' {{action 'handleClick'}} />
24+
<button {{on 'click' this.handleClick}} />
25+
<button {{action 'handleClick'}} />
26+
</form>
3327
```
3428

35-
### Correct
29+
### Correct
3630

37-
```gjs
38-
<template>
39-
<button {{on "click" this.handleClick}}>Save</button>
40-
</template>
31+
```hbs
32+
<form>
33+
<button type='button' {{on 'click' this.handleClick}} />
34+
<button type='button' {{action 'handleClick'}} />
35+
<button type='submit' />
36+
<button />
37+
</form>
4138
```
4239

43-
```gjs
44-
<template>
45-
<button type="button" action="doSomething">Click</button>
46-
</template>
47-
```
40+
Buttons outside a `<form>` are allowed to have click actions:
4841

49-
```gjs
50-
<template>
51-
<form {{on "submit" this.handleSubmit}}>
52-
<button type="submit">Submit</button>
53-
</form>
54-
</template>
42+
```hbs
43+
<button type='submit' {{on 'click' this.handleClick}} />
44+
<button type='submit' {{action 'handleClick'}} />
45+
<button {{on 'click' this.handleClick}} />
46+
<button {{action 'handleClick'}} />
5547
```
5648

5749
## Related Rules

docs/rules/template-no-arguments-for-html-elements.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,26 @@ This rule disallows using `@arguments` on HTML elements. Use regular attributes
5252
</template>
5353
```
5454

55+
Yielded components, named blocks, and path expressions are also allowed:
56+
57+
```hbs
58+
{{#let (component 'bar') as |foo|}}
59+
<foo @name='1' />
60+
{{/let}}
61+
```
62+
63+
```hbs
64+
<foo.some.name @name='1' />
65+
<@foo @name='2' />
66+
<@foo.bar @name='2' />
67+
```
68+
69+
```hbs
70+
<MyComponent>
71+
<:slot @name='Header'></:slot>
72+
</MyComponent>
73+
```
74+
5575
## Related Rules
5676

5777
- [template-no-block-params-for-html-elements](./template-no-block-params-for-html-elements.md)

docs/rules/template-no-aria-unsupported-elements.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,10 @@ Certain HTML elements do not support ARIA roles, states, and properties. This ru
1010

1111
This rule disallows ARIA attributes on elements that do not support them, including:
1212

13-
- `meta`
1413
- `html`
14+
- `meta`
1515
- `script`
1616
- `style`
17-
- `title`
18-
- `base`
19-
- `head`
20-
- `link`
2117

2218
## Examples
2319

docs/rules/template-no-array-prototype-extensions.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ This rule disallows using Ember Array prototype extensions in templates:
1212

1313
- `firstObject`
1414
- `lastObject`
15-
- `@each`
16-
- `[]`
1715

1816
## Examples
1917

@@ -31,12 +29,6 @@ This rule disallows using Ember Array prototype extensions in templates:
3129
</template>
3230
```
3331

34-
```gjs
35-
<template>
36-
{{this.data.@each}}
37-
</template>
38-
```
39-
4032
### Correct ✅
4133

4234
```gjs

docs/rules/template-no-capital-arguments.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,14 @@ Disallow capital letters in argument names. Use lowercase argument names (e.g.,
66

77
## Rule Details
88

9-
This rule enforces the convention that argument names should start with lowercase letters.
9+
This rule enforces the convention that argument names should start with lowercase letters. Anything that does not start with a lowercase letter (such as `@Foo`, `@0`, `@!` etc) is a reserved argument name. This is purely speculative and the goal is to carve out some space for future features. If we don't end up needing them, we can always relax the restrictions down the road.
10+
11+
Additionally, the following are reserved names and will also be flagged by this rule:
12+
13+
- `@arguments`
14+
- `@args`
15+
- `@block`
16+
- `@else`
1017

1118
## Examples
1219

@@ -24,6 +31,18 @@ Examples of **incorrect** code for this rule:
2431
</template>
2532
```
2633

34+
```gjs
35+
<template>
36+
<div>{{@arguments}}</div>
37+
</template>
38+
```
39+
40+
```gjs
41+
<template>
42+
<Foo @args={{true}} />
43+
</template>
44+
```
45+
2746
Examples of **correct** code for this rule:
2847

2948
```gjs
@@ -40,4 +59,5 @@ Examples of **correct** code for this rule:
4059

4160
## References
4261

62+
- [RFC #276 - Reserved Names](https://github.com/emberjs/rfcs/blob/68812bf2d439c6bb77ad491e0159b371b68c5c35/text/0276-named-args.md#reserved-names)
4363
- [Ember Style Guide](https://github.com/ember-cli/ember-styleguide)

docs/rules/template-no-duplicate-landmark-elements.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@ This rule ensures that when multiple landmark elements of the same type appear i
1212

1313
Landmark elements checked:
1414

15-
- `header`
16-
- `footer`
17-
- `main`
18-
- `nav`
19-
- `aside`
20-
- `section`
15+
- `header` (banner)
16+
- `footer` (contentinfo)
17+
- `main` (main)
18+
- `nav` (navigation)
19+
- `aside` (complementary)
20+
- `section` (region)
21+
- `form` (form, search)
2122

2223
## Examples
2324

docs/rules/template-no-inline-linkto.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ Disallows inline form of the LinkTo component.
88

99
The inline form of `<LinkTo>` (self-closing without content) should be avoided. Use the block form instead to provide link text.
1010

11+
This rule also disallows the curly `{{link-to}}` inline form (e.g., `{{link-to "text" "route"}}`). The block form `{{#link-to}}...{{/link-to}}` or `<LinkTo>` angle bracket syntax should be used instead.
12+
1113
## Examples
1214

1315
Examples of **incorrect** code for this rule:
@@ -24,6 +26,18 @@ Examples of **incorrect** code for this rule:
2426
</template>
2527
```
2628

29+
```gjs
30+
<template>
31+
{{link-to "Link text" "routeName"}}
32+
</template>
33+
```
34+
35+
```gjs
36+
<template>
37+
{{link-to "Link text" "routeName" prop1 prop2}}
38+
</template>
39+
```
40+
2741
Examples of **correct** code for this rule:
2842

2943
```gjs
@@ -40,6 +54,12 @@ Examples of **correct** code for this rule:
4054
</template>
4155
```
4256

57+
```gjs
58+
<template>
59+
{{#link-to "routeName" prop1 prop2}}Link text{{/link-to}}
60+
</template>
61+
```
62+
4363
## References
4464

4565
- [eslint-plugin-ember template-no-inline-link-to](https://github.com/ember-cli/eslint-plugin-ember/blob/master/docs/rules/template-no-inline-link-to.md)

0 commit comments

Comments
 (0)