Skip to content

Commit e5ff0d5

Browse files
Add 4 more template rules: no-element-event-actions, no-potential-path-strings, no-capital-arguments, no-unknown-arguments-for-builtin-components (55/127 total: 43%)
Co-authored-by: NullVoxPopuli <[email protected]>
1 parent b061def commit e5ff0d5

24 files changed

Lines changed: 804 additions & 82 deletions

README.md

Lines changed: 28 additions & 20 deletions
Large diffs are not rendered by default.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# ember/template-no-capital-arguments
2+
3+
<!-- end auto-generated rule header -->
4+
5+
Disallow capital letters in argument names. Use lowercase argument names (e.g., `@arg` instead of `@Arg`).
6+
7+
## Rule Details
8+
9+
This rule enforces the convention that argument names should start with lowercase letters.
10+
11+
## Examples
12+
13+
Examples of **incorrect** code for this rule:
14+
15+
```gjs
16+
<template>
17+
<div>{{@Arg}}</div>
18+
</template>
19+
```
20+
21+
```gjs
22+
<template>
23+
<div>{{@MyArgument}}</div>
24+
</template>
25+
```
26+
27+
Examples of **correct** code for this rule:
28+
29+
```gjs
30+
<template>
31+
<div>{{@arg}}</div>
32+
</template>
33+
```
34+
35+
```gjs
36+
<template>
37+
<div>{{@myArgument}}</div>
38+
</template>
39+
```
40+
41+
## References
42+
43+
- [Ember Style Guide](https://github.com/ember-cli/ember-styleguide)

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# template-no-curly-component-invocation
1+
# ember/template-no-curly-component-invocation
2+
3+
<!-- end auto-generated rule header -->
24

35
✅ The `extends: 'plugin:ember/strict-gjs'` and `extends: 'plugin:ember/strict-gts'` property in a configuration file enables this rule.
46

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# ember/template-no-element-event-actions
2+
3+
<!-- end auto-generated rule header -->
4+
5+
Disallow using element event actions (e.g., `onclick={{action}}`) in templates. Use the `{{on}}` modifier instead.
6+
7+
## Rule Details
8+
9+
This rule disallows the use of element event actions in templates.
10+
11+
## Examples
12+
13+
Examples of **incorrect** code for this rule:
14+
15+
```gjs
16+
<template>
17+
<button onclick={{this.handleClick}}>Click</button>
18+
</template>
19+
```
20+
21+
```gjs
22+
<template>
23+
<div onmouseenter={{this.handleHover}}>Hover</div>
24+
</template>
25+
```
26+
27+
Examples of **correct** code for this rule:
28+
29+
```gjs
30+
<template>
31+
<button {{on "click" this.handleClick}}>Click</button>
32+
</template>
33+
```
34+
35+
```gjs
36+
<template>
37+
<div {{on "mouseenter" this.handleHover}}>Hover</div>
38+
</template>
39+
```
40+
41+
## References
42+
43+
- [Ember Octane migration guide](https://guides.emberjs.com/release/upgrading/current-edition/action-on-and-fn/)

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# template-no-implicit-this
1+
# ember/template-no-implicit-this
2+
3+
<!-- end auto-generated rule header -->
24

35
✅ The `extends: 'plugin:ember/strict-gjs'` and `extends: 'plugin:ember/strict-gts'` property in a configuration file enables this rule.
46

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# ember/template-no-potential-path-strings
2+
3+
<!-- end auto-generated rule header -->
4+
5+
Disallow potential path strings that should be dynamic values in templates.
6+
7+
## Rule Details
8+
9+
This rule catches potential path strings in text nodes that should likely be dynamic values.
10+
11+
## Examples
12+
13+
Examples of **incorrect** code for this rule:
14+
15+
```gjs
16+
<template>
17+
<div>this.propertyName</div>
18+
</template>
19+
```
20+
21+
```gjs
22+
<template>
23+
<div>foo.bar</div>
24+
</template>
25+
```
26+
27+
Examples of **correct** code for this rule:
28+
29+
```gjs
30+
<template>
31+
<div>{{this.propertyName}}</div>
32+
</template>
33+
```
34+
35+
```gjs
36+
<template>
37+
<div>{{this.foo.bar}}</div>
38+
</template>
39+
```
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# ember/template-no-unknown-arguments-for-builtin-components
2+
3+
<!-- end auto-generated rule header -->
4+
5+
Disallow unknown arguments for built-in Ember components.
6+
7+
## Rule Details
8+
9+
This rule checks that only known arguments are used with built-in Ember components like `<Input>`, `<Textarea>`, and `<LinkTo>`.
10+
11+
## Examples
12+
13+
Examples of **incorrect** code for this rule:
14+
15+
```gjs
16+
<template>
17+
<Input @unknownArg="value" />
18+
</template>
19+
```
20+
21+
```gjs
22+
<template>
23+
<Textarea @invalidProp={{this.value}} />
24+
</template>
25+
```
26+
27+
Examples of **correct** code for this rule:
28+
29+
```gjs
30+
<template>
31+
<Input @type="text" @value={{this.value}} />
32+
</template>
33+
```
34+
35+
```gjs
36+
<template>
37+
<Textarea @value={{this.text}} @rows="10" />
38+
</template>
39+
```
40+
41+
## References
42+
43+
- [Ember Built-in Components](https://api.emberjs.com/ember/release/classes/Ember.Templates.components)

docs/rules/template-no-unnecessary-component-helper.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# template-no-unnecessary-component-helper
1+
# ember/template-no-unnecessary-component-helper
2+
3+
<!-- end auto-generated rule header -->
24

35
✅ The `extends: 'plugin:ember/strict-gjs'` and `extends: 'plugin:ember/strict-gts'` property in a configuration file enables this rule.
46

docs/rules/template-no-unused-block-params.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# template-no-unused-block-params
1+
# ember/template-no-unused-block-params
2+
3+
<!-- end auto-generated rule header -->
24

35
✅ The `extends: 'plugin:ember/strict-gjs'` and `extends: 'plugin:ember/strict-gts'` property in a configuration file enables this rule.
46

docs/rules/template-no-whitespace-within-word.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# template-no-whitespace-within-word
1+
# ember/template-no-whitespace-within-word
2+
3+
<!-- end auto-generated rule header -->
24

35
✅ The `extends: 'plugin:ember/strict-gjs'` and `extends: 'plugin:ember/strict-gts'` property in a configuration file enables this rule.
46

0 commit comments

Comments
 (0)