Skip to content

Commit c0e3d77

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
1 parent 21d7e49 commit c0e3d77

428 files changed

Lines changed: 23884 additions & 1053 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: 220 additions & 37 deletions
Large diffs are not rendered by default.
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# ember/template-attribute-order
2+
3+
💼 This rule is enabled in the following [configs](https://github.com/ember-cli/eslint-plugin-ember#-configurations): `strict-gjs`, `strict-gts`.
4+
5+
<!-- end auto-generated rule header -->
6+
7+
Enforces a consistent ordering of attributes in template elements. This helps improve readability and maintainability of templates.
8+
9+
## Rule Details
10+
11+
This rule enforces a consistent order for attributes on template elements. By default, it follows this order:
12+
13+
1. `class`
14+
2. `id`
15+
3. `role`
16+
4. `aria-*` attributes
17+
5. `data-test-*` attributes
18+
6. `type`
19+
7. `name`
20+
8. `value`
21+
9. `placeholder`
22+
10. `disabled`
23+
24+
## Examples
25+
26+
Examples of **incorrect** code for this rule:
27+
28+
```gjs
29+
<template>
30+
<div id="main" class="container"></div>
31+
</template>
32+
```
33+
34+
```gjs
35+
<template>
36+
<button aria-label="Submit" role="button">Send</button>
37+
</template>
38+
```
39+
40+
Examples of **correct** code for this rule:
41+
42+
```gjs
43+
<template>
44+
<div class="container" id="main"></div>
45+
</template>
46+
```
47+
48+
```gjs
49+
<template>
50+
<button class="btn" role="button" aria-label="Submit">Send</button>
51+
</template>
52+
```
53+
54+
## Configuration
55+
56+
You can customize the order by providing an `order` array:
57+
58+
```js
59+
module.exports = {
60+
rules: {
61+
'ember/template-attribute-order': [
62+
'error',
63+
{
64+
order: ['class', 'id', 'role', 'aria-', 'type'],
65+
},
66+
],
67+
},
68+
};
69+
```
70+
71+
## References
72+
73+
- [ember-template-lint attribute-order](https://github.com/ember-template-lint/ember-template-lint/blob/master/docs/rule/attribute-order.md)
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# ember/template-builtin-component-arguments
2+
3+
💼 This rule is enabled in the following [configs](https://github.com/ember-cli/eslint-plugin-ember#-configurations): `strict-gjs`, `strict-gts`.
4+
5+
<!-- end auto-generated rule header -->
6+
7+
✅ The `extends: 'recommended'` property in a configuration file enables this rule.
8+
9+
The builtin `Input` component has several arguments that match attributes
10+
of the lower-case `input` HTML element. These arguments should be set via e.g.
11+
`@type`, instead of `type`, but it is easy to forget and can cause subtle
12+
issues.
13+
14+
This rule warns about `Input` component invocations that use the following attributes instead of arguments:
15+
16+
- `checked`
17+
- `type`
18+
- `value`
19+
20+
The builtin `Textarea` component has several arguments that match properties
21+
of the lower-case `textarea` HTML element. These arguments should be set via e.g.
22+
`@value`, instead of `value`, but it is easy to forget and can cause subtle
23+
issues.
24+
25+
This rule warns about `Textarea` component invocations that use the following attributes instead of arguments:
26+
27+
- `value`
28+
29+
Please note that this rule currently only warns about these three attributes on
30+
the `Input`, and one property on the `Textarea` components, but might be extended in the future to also warn about
31+
other attributes or builtin components.
32+
33+
## Examples
34+
35+
This rule **forbids** the following:
36+
37+
```hbs
38+
<Input type='text' size='10' />
39+
```
40+
41+
```hbs
42+
<Input @type='checkbox' checked />
43+
```
44+
45+
```hbs
46+
<Textarea value="Hello, Tom!" /></Textarea>
47+
```
48+
49+
This rule **allows** the following:
50+
51+
```hbs
52+
<input type='text' size='10' />
53+
```
54+
55+
```hbs
56+
<Input @type='text' size='10' />
57+
```
58+
59+
```hbs
60+
<Input @type='checkbox' @checked={{true}} />
61+
```
62+
63+
```hbs
64+
<Textarea @value="Hello, Tom!" /></Textarea>
65+
```
66+
67+
## Migration
68+
69+
- Add the `@` character in front of the relevant attributes to convert them
70+
into component argument
71+
72+
## Related Rules
73+
74+
- [template-no-unknown-arguments-for-builtin-components](template-no-unknown-arguments-for-builtin-components.md)
75+
76+
## References
77+
78+
- [`Input` component API documentation](https://api.emberjs.com/ember/release/classes/Ember.Templates.components/methods/Input?anchor=Input)
79+
- [`Textarea` component API documentation](https://api.emberjs.com/ember/release/classes/Ember.Templates.components/methods/Textarea?anchor=Textarea)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# ember/template-deprecated-inline-view-helper
2+
3+
💼 This rule is enabled in the following [configs](https://github.com/ember-cli/eslint-plugin-ember#-configurations): `strict-gjs`, `strict-gts`.
4+
5+
<!-- end auto-generated rule header -->
6+
7+
## Examples
8+
9+
See ember-template-lint documentation.
10+
11+
## References
12+
13+
- [ember-template-lint](https://github.com/ember-template-lint/ember-template-lint)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# ember/template-deprecated-render-helper
2+
3+
💼 This rule is enabled in the following [configs](https://github.com/ember-cli/eslint-plugin-ember#-configurations): `strict-gjs`, `strict-gts`.
4+
5+
<!-- end auto-generated rule header -->
6+
7+
Disallows the {{render}} helper which is deprecated.
8+
9+
## Examples
10+
11+
Incorrect:
12+
13+
```gjs
14+
<template>{{render "user"}}</template>
15+
```
16+
17+
Correct:
18+
19+
```gjs
20+
<template><User /></template>
21+
```
22+
23+
## References
24+
25+
- [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: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# ember/template-inline-link-to
2+
3+
💼 This rule is enabled in the following [configs](https://github.com/ember-cli/eslint-plugin-ember#-configurations): `strict-gjs`, `strict-gts`.
4+
5+
🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
6+
7+
<!-- end auto-generated rule header -->
8+
9+
Disallows the inline form of the `link-to` component and enforces the block form instead.
10+
11+
Ember's `link-to` component has both an inline form and a block form. This rule forbids the inline form.
12+
13+
## Examples
14+
15+
This rule **forbids** the following (inline form):
16+
17+
```hbs
18+
{{link-to 'Link text' 'routeName' prop1 prop2}}
19+
```
20+
21+
This rule **allows** the following (block form):
22+
23+
```hbs
24+
{{#link-to 'routeName' prop1 prop2}}Link text{{/link-to}}
25+
```
26+
27+
## Rationale
28+
29+
The block form is a little longer but has advantages over the inline form:
30+
31+
- It maps closer to the use of HTML anchor tags which wrap their inner content.
32+
- It provides an obvious way for developers to put nested markup and components inside of their link.
33+
- The block form's argument order is more direct: "link to route". The inline form's argument order is somewhat ambiguous (link text then link target). This is opposite of the order in HTML (`href` then link text).
34+
35+
## References
36+
37+
- [Ember guides/routing](https://guides.emberjs.com/release/routing/linking-between-routes/#toc_the-linkto--component)
38+
- [Ember api/LinkTo component](https://api.emberjs.com/ember/release/classes/Ember.Templates.components/methods/LinkTo?anchor=LinkTo)
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# ember/template-link-href-attributes
2+
3+
💼 This rule is enabled in the following [configs](https://github.com/ember-cli/eslint-plugin-ember#-configurations): `strict-gjs`, `strict-gts`.
4+
5+
<!-- end auto-generated rule header -->
6+
7+
Requires `href` attribute on `<a>` elements.
8+
9+
Anchor elements should have an `href` attribute to be properly recognized as links by browsers and assistive technologies. If an element is meant to be interactive but not navigate, use a `<button>` instead.
10+
11+
## Rule Details
12+
13+
This rule ensures that all `<a>` elements have an `href` attribute.
14+
15+
## Examples
16+
17+
Examples of **incorrect** code for this rule:
18+
19+
```gjs
20+
<template>
21+
<a>Link</a>
22+
</template>
23+
```
24+
25+
```gjs
26+
<template>
27+
<a onclick={{this.handleClick}}>Click me</a>
28+
</template>
29+
```
30+
31+
```gjs
32+
<template>
33+
<a role="button">Action</a>
34+
</template>
35+
```
36+
37+
Examples of **correct** code for this rule:
38+
39+
```gjs
40+
<template>
41+
<a href="/about">About Us</a>
42+
</template>
43+
```
44+
45+
```gjs
46+
<template>
47+
<a href="https://example.com">External Link</a>
48+
</template>
49+
```
50+
51+
```gjs
52+
<template>
53+
<button {{on "click" this.handleClick}}>Click me</button>
54+
</template>
55+
```
56+
57+
## References
58+
59+
- [MDN: The Anchor element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a)
60+
- [WebAIM: Links and Hypertext](https://webaim.org/techniques/hypertext/)
61+
- [ember-template-lint link-href-attributes](https://github.com/ember-template-lint/ember-template-lint/blob/master/docs/rule/link-href-attributes.md)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# ember/template-link-rel-noopener
2+
3+
💼 This rule is enabled in the following [configs](https://github.com/ember-cli/eslint-plugin-ember#-configurations): `strict-gjs`, `strict-gts`.
4+
5+
🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
6+
7+
<!-- end auto-generated rule header -->
8+
9+
## Examples
10+
11+
See ember-template-lint documentation.
12+
13+
## References
14+
15+
- [ember-template-lint link-rel-noopener](https://github.com/ember-template-lint/ember-template-lint/blob/master/docs/rule/link-rel-noopener.md)

0 commit comments

Comments
 (0)