Skip to content

Commit 45d5dea

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 fix Update documentation links from ember-template-lint to eslint-plugin-ember - Changed references in various rule documentation files to point to the new eslint-plugin-ember URLs instead of ember-template-lint. - Updated tests to reflect the change in rule naming conventions. Add scope checking to template-no-arguments-for-html-elements Fix oof Cleanup Enhance linting rules: refine messages and add checks for `this.attrs`, `this.this`, and yield scenarios Refactor rule and tests for template-no-attrs-in-components: specify `this.attrs` usage and update examples lint:fix Fix AI garbage ope ope In progress copying more tests over Refactor lint rules and update test cases for improved clarity and functionality Fixes Docs updates Fix ope ope ope Test fixes Fix cleanup
1 parent 484c3c6 commit 45d5dea

389 files changed

Lines changed: 30917 additions & 1116 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.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,6 @@ arr.uniq();
139139

140140
## Related Rules
141141

142-
- [no-array-prototype-extensions](https://github.com/ember-template-lint/ember-template-lint/blob/master/docs/rule/no-array-prototype-extensions.md) from ember-template-lint
142+
- [template-no-array-prototype-extensions](https://github.com/ember-cli/eslint-plugin-ember/blob/master/docs/rules/template-no-array-prototype-extensions.md) from eslint-plugin-ember
143143
- [no-function-prototype-extensions](no-function-prototype-extensions.md)
144144
- [no-string-prototype-extensions](no-string-prototype-extensions.md)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ import didUpdate from '@ember/render-modifiers/modifiers/did-update';
4545
import willDestroy from '@ember/render-modifiers/modifiers/will-destroy';
4646
```
4747

48-
For more examples, see [the docs on ember-template-lint](https://github.com/ember-template-lint/ember-template-lint/blob/master/docs/rule/no-at-ember-render-modifiers.md).
48+
For more examples, see [the docs on eslint-plugin-ember](https://github.com/ember-cli/eslint-plugin-ember/blob/master/docs/rules/template-no-at-ember-render-modifiers.md).
4949

5050
## References
5151

5252
- [Editions](https://emberjs.com/editions/)
5353
- [Octane Upgrade Guide](https://guides.emberjs.com/release/upgrading/current-edition/)
5454
- [Component Documentation](https://guides.emberjs.com/release/components/)
5555
- [Avoiding Lifecycle in Component](https://nullvoxpopuli.com/avoiding-lifecycle)
56-
- [The `ember-template-lint` version of this rule](https://github.com/ember-template-lint/ember-template-lint/blob/master/docs/rule/no-at-ember-render-modifiers.md)
56+
- [The `eslint-plugin-ember` version of this rule](https://github.com/ember-cli/eslint-plugin-ember/blob/master/docs/rules/template-no-at-ember-render-modifiers.md)
5757
- [`ember-modifier`](https://github.com/ember-modifier/ember-modifier)
5858
- [`@ember/render-modifiers`](https://github.com/emberjs/ember-render-modifiers) (deprecated)

docs/rules/no-html-safe.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export default helper(substring);
109109

110110
## Related Rules
111111

112-
- ember-template-lint has a [no-triple-curlies](https://github.com/ember-template-lint/ember-template-lint/blob/master/docs/rule/no-triple-curlies.md) rule for the template equivalent of this rule.
112+
- eslint-plugin-ember has a [template-no-triple-curlies](https://github.com/ember-cli/eslint-plugin-ember/blob/master/docs/rules/template-no-triple-curlies.md) rule for the template equivalent of this rule.
113113

114114
## References
115115

docs/rules/no-restricted-service-injections.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,4 @@ Accepts an array of the objects with the following options:
6060
## Related Rules
6161

6262
- The [no-restricted-imports](https://eslint.org/docs/rules/no-restricted-imports) or [import/no-restricted-paths](https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-restricted-paths.md) rules are the JavaScript import statement equivalent of this rule.
63-
- ember-template-lint has a [no-restricted-invocations](https://github.com/ember-template-lint/ember-template-lint/blob/master/docs/rule/no-restricted-invocations.md) rule for disallowing component usages.
63+
- eslint-plugin-ember has a [template-no-restricted-invocations](https://github.com/ember-cli/eslint-plugin-ember/blob/master/docs/rules/template-no-restricted-invocations.md) rule for disallowing component usages.

docs/rules/template-attribute-order.md

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,60 +6,67 @@ Enforces a consistent ordering of attributes in template elements. This helps im
66

77
## Rule Details
88

9-
This rule enforces a consistent order for attributes on template elements. By default, it follows this order:
10-
11-
1. `class`
12-
2. `id`
13-
3. `role`
14-
4. `aria-*` attributes
15-
5. `data-test-*` attributes
16-
6. `type`
17-
7. `name`
18-
8. `value`
19-
9. `placeholder`
20-
10. `disabled`
9+
This rule enforces a consistent order for attributes on template elements. By default, attributes are ordered by type group:
10+
11+
1. **Arguments**`@argName` (Glimmer component arguments)
12+
2. **Attributes** — standard HTML attributes like `class`, `id`, `role`
13+
3. **Modifiers**`{{on "click" ...}}`, `{{did-insert ...}}`, etc.
14+
15+
Within each group, attributes are sorted alphabetically by default.
16+
17+
Additional groups (`splattributes` and `comments`) can be added to the ordering if needed.
18+
19+
Hash pairs in curly invocations (mustache/block statements) are also alphabetized when `alphabetize` is enabled.
2120

2221
## Examples
2322

2423
Examples of **incorrect** code for this rule:
2524

2625
```gjs
2726
<template>
28-
<div id="main" class="container"></div>
27+
<MyComponent class="btn" @onClick={{this.go}} @label="hi" />
2928
</template>
3029
```
3130

31+
In this example, `class` (an attribute) appears before `@onClick` and `@label` (arguments). Arguments should come first.
32+
3233
```gjs
3334
<template>
34-
<button aria-label="Submit" role="button">Send</button>
35+
<MyComponent @label="hi" @action={{this.go}} />
3536
</template>
3637
```
3738

39+
Here, `@label` and `@action` are out of alphabetical order within the arguments group.
40+
3841
Examples of **correct** code for this rule:
3942

4043
```gjs
4144
<template>
42-
<div class="container" id="main"></div>
45+
<MyComponent @action={{this.go}} @label="hi" class="btn" />
4346
</template>
4447
```
4548

4649
```gjs
4750
<template>
48-
<button class="btn" role="button" aria-label="Submit">Send</button>
51+
<div class="container" id="main" {{on "click" this.handleClick}}></div>
4952
</template>
5053
```
5154

52-
## Configuration
55+
## Options
5356

54-
You can customize the order by providing an `order` array:
57+
| Name | Type | Default | Description |
58+
| ------------- | ---------- | ------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------- |
59+
| `order` | `string[]` | `["arguments", "attributes", "modifiers"]` | The order of token type groups. Valid values: `"arguments"`, `"attributes"`, `"modifiers"`, `"splattributes"`, `"comments"`. |
60+
| `alphabetize` | `boolean` | `true` | Whether to alphabetize attributes within each group. |
5561

5662
```js
5763
module.exports = {
5864
rules: {
5965
'ember/template-attribute-order': [
6066
'error',
6167
{
62-
order: ['class', 'id', 'role', 'aria-', 'type'],
68+
order: ['arguments', 'attributes', 'modifiers'],
69+
alphabetize: true,
6370
},
6471
],
6572
},
@@ -68,4 +75,4 @@ module.exports = {
6875

6976
## References
7077

71-
- [ember-template-lint attribute-order](https://github.com/ember-template-lint/ember-template-lint/blob/master/docs/rule/attribute-order.md)
78+
- [eslint-plugin-ember template-attribute-order](https://github.com/ember-cli/eslint-plugin-ember/blob/master/docs/rules/template-attribute-order.md)

docs/rules/template-builtin-component-arguments.md

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

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

5-
✅ The `extends: 'recommended'` property in a configuration file enables this rule.
6-
75
The builtin `Input` component has several arguments that match attributes
86
of the lower-case `input` HTML element. These arguments should be set via e.g.
97
`@type`, instead of `type`, but it is easy to forget and can cause subtle
@@ -32,34 +30,34 @@ other attributes or builtin components.
3230

3331
This rule **forbids** the following:
3432

35-
```hbs
36-
<Input type='text' size='10' />
33+
```gjs
34+
<template><Input type='text' size='10' /></template>
3735
```
3836

39-
```hbs
40-
<Input @type='checkbox' checked />
37+
```gjs
38+
<template><Input @type='checkbox' checked /></template>
4139
```
4240

43-
```hbs
44-
<Textarea value="Hello, Tom!" /></Textarea>
41+
```gjs
42+
<template><Textarea value="Hello, Tom!" /></Textarea></template>
4543
```
4644

4745
This rule **allows** the following:
4846

49-
```hbs
50-
<input type='text' size='10' />
47+
```gjs
48+
<template><input type='text' size='10' /></template>
5149
```
5250

53-
```hbs
54-
<Input @type='text' size='10' />
51+
```gjs
52+
<template><Input @type='text' size='10' /></template>
5553
```
5654

57-
```hbs
58-
<Input @type='checkbox' @checked={{true}} />
55+
```gjs
56+
<template><Input @type='checkbox' @checked={{true}} /></template>
5957
```
6058

61-
```hbs
62-
<Textarea @value="Hello, Tom!" /></Textarea>
59+
```gjs
60+
<template><Textarea @value="Hello, Tom!" /></Textarea></template>
6361
```
6462

6563
## Migration
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# ember/template-deprecated-inline-view-helper
2+
3+
<!-- end auto-generated rule header -->
4+
5+
In Ember 1.12, support for invoking the inline View helper was deprecated.
6+
7+
## Rule Details
8+
9+
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.
10+
11+
## Examples
12+
13+
This rule **forbids** the following:
14+
15+
```gjs
16+
<template>
17+
{{view 'this-is-bad' tagName="span"}}
18+
19+
{{#view tagName="span"}}content{{/view}}
20+
</template>
21+
```
22+
23+
This rule **allows** the following:
24+
25+
```gjs
26+
<template>
27+
{{this-is-better}}
28+
29+
{{qux-qaz this=good}}
30+
31+
<div foo={{bar}}></div>
32+
</template>
33+
```
34+
35+
## References
36+
37+
- 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+
- [eslint-plugin-ember template-deprecated-render-helper](https://github.com/ember-cli/eslint-plugin-ember/blob/master/docs/rules/template-deprecated-render-helper.md)

0 commit comments

Comments
 (0)