Skip to content

Commit 15d9f8d

Browse files
committed
Port over gjs/gts relevant ember-template-lint
1 parent 0064152 commit 15d9f8d

74 files changed

Lines changed: 4316 additions & 497 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.

README.md

Lines changed: 133 additions & 117 deletions
Large diffs are not rendered by default.

docs/rules/template-block-indentation.md

Lines changed: 0 additions & 35 deletions
This file was deleted.
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)

docs/rules/template-eol-last.md

Lines changed: 0 additions & 73 deletions
This file was deleted.
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)

docs/rules/template-linebreak-style.md

Lines changed: 0 additions & 27 deletions
This file was deleted.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# ember/template-modifier-name-case
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+
Requires dasherized names for modifiers.
10+
11+
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.
12+
13+
## Examples
14+
15+
This rule **forbids** the following:
16+
17+
```hbs
18+
<div {{didInsert}}></div>
19+
```
20+
21+
```hbs
22+
<div {{onFocus}}></div>
23+
```
24+
25+
```hbs
26+
<div {{modifier 'didInsert'}}></div>
27+
```
28+
29+
This rule **allows** the following:
30+
31+
```hbs
32+
<div {{did-insert}}></div>
33+
```
34+
35+
```hbs
36+
<div {{on-focus}}></div>
37+
```
38+
39+
```hbs
40+
<div {{modifier 'did-insert'}}></div>
41+
```
42+
43+
## See Also
44+
45+
- [named-functions-in-promises](named-functions-in-promises.md)
46+
47+
## References
48+
49+
- [Template syntax guide - Modifiers](https://guides.emberjs.com/release/components/template-syntax/#toc_modifiers)

docs/rules/template-no-bare-yield.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# ember/template-no-bare-yield
22

3+
💼 This rule is enabled in the following [configs](https://github.com/ember-cli/eslint-plugin-ember#-configurations): `strict-gjs`, `strict-gts`.
4+
35
<!-- end auto-generated rule header -->
46

57
✅ The `extends: 'plugin:ember/strict-gjs'` or `extends: 'plugin:ember/strict-gts'` property in a configuration file enables this rule.
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# ember/template-no-curly-component-invocation
2+
3+
💼 This rule is enabled in the following [configs](https://github.com/ember-cli/eslint-plugin-ember#-configurations): ✅ `recommended`, `strict-gjs`, `strict-gts`.
4+
5+
<!-- end auto-generated rule header -->
6+
7+
Disallows curly component invocation syntax. Use angle bracket syntax instead.
8+
9+
There are two ways to invoke a component in a template: curly component syntax
10+
(`{{my-component}}`), and angle bracket syntax (`<MyComponent />`). The
11+
difference between them is syntactical. You should favour angle bracket syntax
12+
as it improves readability of templates, i.e. disambiguates components from
13+
helpers, and is also the future direction Ember is going with the Octane
14+
Edition.
15+
16+
This rule checks all the curly braces in your app and warns about those that
17+
look like they could be component invocations.
18+
19+
## Examples
20+
21+
This rule **forbids** the following:
22+
23+
```hbs
24+
{{foo-bar}}
25+
```
26+
27+
```hbs
28+
{{nested/component}}
29+
```
30+
31+
```hbs
32+
{{#foo-bar}}content{{/foo-bar}}
33+
```
34+
35+
This rule **allows** the following:
36+
37+
```hbs
38+
{{foo bar}}
39+
```
40+
41+
```hbs
42+
<FooBar />
43+
```
44+
45+
```hbs
46+
<Nested::Component />
47+
```
48+
49+
## Configuration
50+
51+
This rule accepts an options object with the following properties:
52+
53+
- `allow` (default: `[]`) - Array of component names to allow in curly syntax
54+
- `disallow` (default: `[]`) - Array of component names to disallow in curly syntax
55+
- `requireDash` (default: `false`) - Require dashes in component names
56+
- `noImplicitThis` (default: `true`) - Don't allow implicit `this` references
57+
58+
```js
59+
// .eslintrc.js
60+
module.exports = {
61+
rules: {
62+
'ember/template-no-curly-component-invocation': [
63+
'error',
64+
{
65+
allow: ['some-helper'],
66+
disallow: [],
67+
},
68+
],
69+
},
70+
};
71+
```
72+
73+
## References
74+
75+
- [Ember Guides - Angle Bracket Syntax](https://guides.emberjs.com/release/components/template-syntax/#toc_angle-bracket-syntax)

0 commit comments

Comments
 (0)