Skip to content

Commit e1eec94

Browse files
CopilotNullVoxPopuli
authored andcommitted
Port over ember-template-lint rule for gjs/gts
Revert .github changes Remove attribute indentation rule. We have prettier for formatting concerns Port over gjs/gts relevant ember-template-lint cleanup Add documentation and test files for removed ember rules feat(rules): add template-require-valid-form-groups and template-template-length rules - Introduced `template-require-valid-form-groups` rule to enforce proper grouping of form controls using `<fieldset>`/`<legend>` or WAI-ARIA roles. - Added `template-template-length` rule to enforce size constraints on templates, allowing configuration for minimum and maximum line lengths. - Updated documentation for existing rules to include configuration details. - Added tests for both new rules to ensure correct functionality and error reporting. Cleanup Fix
1 parent a86e4b3 commit e1eec94

394 files changed

Lines changed: 23004 additions & 947 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.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ npm-debug.log
1414

1515
# eslint-remote-tester
1616
eslint-remote-tester-results
17+
package-lock.json

CHANGELOG.md

Lines changed: 1385 additions & 929 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 155 additions & 17 deletions
Large diffs are not rendered by default.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# ember/template-deprecated-inline-view-helper
2+
3+
<!-- end auto-generated rule header -->
4+
5+
✅ The `extends: 'recommended'` property in a configuration file enables this rule.
6+
7+
In Ember 1.12, support for invoking the inline View helper was deprecated.
8+
9+
## Examples
10+
11+
This rule **forbids** the following:
12+
13+
```hbs
14+
{{view 'this-is-bad'}}
15+
16+
{{view.also-bad}}
17+
18+
{{qux-qaz please=view.stop}}
19+
20+
{{#not-this please=view.stop}}{{/not-this}}
21+
22+
<div foo={{view.bar}}></div>
23+
```
24+
25+
This rule **allows** the following:
26+
27+
```hbs
28+
{{this-is-better}}
29+
30+
{{qux-qaz this=good}}
31+
32+
{{#ok-this yay=nice}}{{/ok-this}}
33+
34+
<div foo={{bar}}></div>
35+
```
36+
37+
## References
38+
39+
- More information is available at the [Deprecation Guide](http://emberjs.com/deprecations/v1.x/#toc_ember-view).
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# ember/template-deprecated-render-helper
2+
3+
<!-- end auto-generated rule header -->
4+
5+
Disallows the {{render}} helper which is deprecated.
6+
7+
## Examples
8+
9+
Incorrect:
10+
11+
```gjs
12+
<template>{{render "user"}}</template>
13+
```
14+
15+
Correct:
16+
17+
```gjs
18+
<template><User /></template>
19+
```
20+
21+
## References
22+
23+
- [ember-template-lint deprecated-render-helper](https://github.com/ember-template-lint/ember-template-lint/blob/master/docs/rule/deprecated-render-helper.md)
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# ember/template-modifier-name-case
2+
3+
🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
4+
5+
<!-- end auto-generated rule header -->
6+
7+
Requires dasherized names for modifiers.
8+
9+
Modifiers should use dasherized names when being invoked, not camelCase. This is a stylistic rule that will prevent you from using camelCase modifiers, requiring you to use dasherized modifier names instead.
10+
11+
## Examples
12+
13+
This rule **forbids** the following:
14+
15+
```hbs
16+
<div {{didInsert}}></div>
17+
```
18+
19+
```hbs
20+
<div {{onFocus}}></div>
21+
```
22+
23+
```hbs
24+
<div {{modifier 'didInsert'}}></div>
25+
```
26+
27+
This rule **allows** the following:
28+
29+
```hbs
30+
<div {{did-insert}}></div>
31+
```
32+
33+
```hbs
34+
<div {{on-focus}}></div>
35+
```
36+
37+
```hbs
38+
<div {{modifier 'did-insert'}}></div>
39+
```
40+
41+
## See Also
42+
43+
- [named-functions-in-promises](named-functions-in-promises.md)
44+
45+
## References
46+
47+
- [Template syntax guide - Modifiers](https://guides.emberjs.com/release/components/template-syntax/#toc_modifiers)
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# ember/template-no-action-modifiers
2+
3+
<!-- end auto-generated rule header -->
4+
5+
💼 This rule is enabled in the following [configs](https://github.com/ember-cli/eslint-plugin-ember#-configurations): `strict-gjs`, `strict-gts`.
6+
7+
Disallow usage of `{{action}}` modifiers in templates.
8+
9+
The `{{action}}` modifier has been deprecated in favor of the `{{on}}` modifier. The `{{on}}` modifier provides a more explicit and flexible way to handle events.
10+
11+
## Rule Details
12+
13+
This rule disallows using `{{action}}` as an element modifier.
14+
15+
## Examples
16+
17+
### Incorrect ❌
18+
19+
```gjs
20+
<template>
21+
<button {{action "save"}}>Save</button>
22+
</template>
23+
```
24+
25+
```gjs
26+
<template>
27+
<div {{action "onClick"}}>Click me</div>
28+
</template>
29+
```
30+
31+
```gjs
32+
<template>
33+
<form {{action "submit" on="submit"}}>Submit</form>
34+
</template>
35+
```
36+
37+
### Correct ✅
38+
39+
```gjs
40+
<template>
41+
<button {{on "click" this.handleClick}}>Save</button>
42+
</template>
43+
```
44+
45+
```gjs
46+
<template>
47+
<div {{on "click" this.onClick}}>Click me</div>
48+
</template>
49+
```
50+
51+
```gjs
52+
<template>
53+
<form {{on "submit" this.handleSubmit}}>Submit</form>
54+
</template>
55+
```
56+
57+
## Related Rules
58+
59+
- [template-no-action](./template-no-action.md)
60+
61+
## References
62+
63+
- [Ember Octane Guide - Element Modifiers](https://guides.emberjs.com/release/components/template-lifecycle-dom-and-modifiers/)
64+
- [ember-template-lint: no-action](https://github.com/ember-template-lint/ember-template-lint/blob/master/docs/rule/no-action.md)
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# ember/template-no-action-on-submit-button
2+
3+
<!-- end auto-generated rule header -->
4+
5+
💼 This rule is enabled in the following [configs](https://github.com/ember-cli/eslint-plugin-ember#-configurations): `strict-gjs`, `strict-gts`.
6+
7+
Disallow `action` attribute on submit buttons.
8+
9+
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.
10+
11+
## Rule Details
12+
13+
This rule disallows using the `action` attribute on `<button>` elements (which default to type="submit") and `<input type="submit">` elements.
14+
15+
## Examples
16+
17+
### Incorrect ❌
18+
19+
```gjs
20+
<template>
21+
<button action="save">Save</button>
22+
</template>
23+
```
24+
25+
```gjs
26+
<template>
27+
<button type="submit" action="submit">Submit</button>
28+
</template>
29+
```
30+
31+
```gjs
32+
<template>
33+
<input type="submit" action="go" />
34+
</template>
35+
```
36+
37+
### Correct ✅
38+
39+
```gjs
40+
<template>
41+
<button {{on "click" this.handleClick}}>Save</button>
42+
</template>
43+
```
44+
45+
```gjs
46+
<template>
47+
<button type="button" action="doSomething">Click</button>
48+
</template>
49+
```
50+
51+
```gjs
52+
<template>
53+
<form {{on "submit" this.handleSubmit}}>
54+
<button type="submit">Submit</button>
55+
</form>
56+
</template>
57+
```
58+
59+
## Related Rules
60+
61+
- [template-no-action-modifiers](./template-no-action-modifiers.md)
62+
63+
## References
64+
65+
- [ember-template-lint: no-invalid-interactive](https://github.com/ember-template-lint/ember-template-lint/blob/master/docs/rule/no-invalid-interactive.md)

docs/rules/template-no-action.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# ember/template-no-action
2+
3+
<!-- end auto-generated rule header -->
4+
5+
Disallows the use of `{{action}}` helper.
6+
7+
The `{{action}}` helper is deprecated in favor of the `{{on}}` modifier and `{{fn}}` helper, which provide better performance and clearer intent.
8+
9+
## Examples
10+
11+
Examples of **incorrect** code for this rule:
12+
13+
```gjs
14+
<template>
15+
<button {{on "click" (action "save")}}>Save</button>
16+
</template>
17+
```
18+
19+
```gjs
20+
<template>
21+
{{action "doSomething"}}
22+
</template>
23+
```
24+
25+
Examples of **correct** code for this rule:
26+
27+
```gjs
28+
<template>
29+
<button {{on "click" this.save}}>Save</button>
30+
</template>
31+
```
32+
33+
```gjs
34+
<template>
35+
<button {{on "click" (fn this.save "arg")}}>Save with arg</button>
36+
</template>
37+
```
38+
39+
```gjs
40+
<template>
41+
{{this.action}}
42+
</template>
43+
```
44+
45+
## Migration
46+
47+
- Replace `(action "methodName")` with method references or `(fn this.methodName)`
48+
- Replace `<button onclick={{action ...}}>` with `<button {{on "click" ...}}>`
49+
50+
## References
51+
52+
- [ember-template-lint no-action](https://github.com/ember-template-lint/ember-template-lint/blob/master/docs/rule/no-action.md)
53+
- [Ember.js Deprecations - action helper](https://deprecations.emberjs.com/v3.x/#toc_action-helper)
54+
- [Ember Modifier Documentation](https://guides.emberjs.com/release/components/template-lifecycle-dom-and-modifiers/)
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# ember/template-no-ambiguous-glimmer-paths
2+
3+
<!-- end auto-generated rule header -->
4+
5+
> Disallow ambiguous path in templates
6+
7+
## Rule Details
8+
9+
This rule requires explicit `this.` or `@` prefix for property access to avoid ambiguity.
10+
11+
## Examples
12+
13+
Examples of **incorrect** code for this rule:
14+
15+
```gjs
16+
<template>
17+
{{user.name}}
18+
</template>
19+
```
20+
21+
```gjs
22+
<template>
23+
{{model.title}}
24+
</template>
25+
```
26+
27+
Examples of **correct** code for this rule:
28+
29+
```gjs
30+
<template>
31+
{{this.user.name}}
32+
</template>
33+
```
34+
35+
```gjs
36+
<template>
37+
{{@model.title}}
38+
</template>
39+
```
40+
41+
```gjs
42+
<template>
43+
{{MyComponent}}
44+
</template>
45+
```
46+
47+
## References
48+
49+
- [ember-template-lint no-implicit-this](https://github.com/ember-template-lint/ember-template-lint/blob/master/docs/rule/no-implicit-this.md)

0 commit comments

Comments
 (0)