Skip to content

Commit 84b85e3

Browse files
committed
Sync with ember-template-lint
1 parent 40bdae0 commit 84b85e3

2 files changed

Lines changed: 24 additions & 26 deletions

File tree

docs/rules/template-no-unknown-arguments-for-builtin-components.md

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,40 @@
22

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

5-
Disallow unknown arguments for built-in Ember components.
5+
The builtin components `LinkTo`, `Input`, `Textarea` has list of allowed arguments, and some argument names may be mistyped, this rule trying to highlight possible typos, checking for unknown arguments, also, some components has conflicted and required arguments, rule addressing this behavior.
66

7-
## Rule Details
8-
9-
This rule checks that only known arguments are used with built-in Ember components like `<Input>`, `<Textarea>`, and `<LinkTo>`.
7+
This rule warns about `unknown`, `required` and `conflicted` arguments for `LinkTo`, `Input`, `Textarea` components.
108

119
## Examples
1210

13-
Examples of **incorrect** code for this rule:
11+
This rule **forbids** the following:
12+
13+
```hbs
14+
<LinkTo @unsupportedArgument='foo'> some link with unknown argument</LinkTo>
15+
<LinkTo @route='info' @model='a' @models='b'> info </LinkTo>
16+
<LinkTo @models='b'> info </LinkTo>
17+
```
1418

15-
```gjs
16-
<template>
17-
<Input @unknownArg="value" />
18-
</template>
19+
```hbs
20+
<Input @foo='bar' />
1921
```
2022

21-
```gjs
22-
<template>
23-
<Textarea @invalidProp={{this.value}} />
24-
</template>
23+
```hbs
24+
<Textarea @foo='bar' />
2525
```
2626

27-
Examples of **correct** code for this rule:
27+
This rule **allows** the following:
28+
29+
```hbs
30+
<LinkTo @route='readme'> readme </LinkTo>
31+
```
2832

29-
```gjs
30-
<template>
31-
<Input @type="text" @value={{this.value}} />
32-
</template>
33+
```hbs
34+
<Input @value='someValue' />
3335
```
3436

35-
```gjs
36-
<template>
37-
<Textarea @value={{this.text}} rows="10" />
38-
</template>
37+
```hbs
38+
<Textarea @value='someValue' />
3939
```
4040

4141
## Migration
@@ -51,4 +51,4 @@ Examples of **correct** code for this rule:
5151

5252
## References
5353

54-
- [Ember Built-in Components](https://api.emberjs.com/ember/release/classes/Ember.Templates.components)
54+
- [Reduce API Surface of Built-In Components](https://github.com/emberjs/rfcs/blob/master/text/0707-modernize-built-in-components-2.md#summary)

lib/rules/template-no-unknown-arguments-for-builtin-components.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -384,9 +384,7 @@ module.exports = {
384384
const scope = sourceCode.getScope(node.parent);
385385
const isShadowed = scope.references.some(
386386
(ref) =>
387-
ref.identifier === node.parts[0] &&
388-
ref.resolved &&
389-
ref.resolved.defs.length > 0
387+
ref.identifier === node.parts[0] && ref.resolved && ref.resolved.defs.length > 0
390388
);
391389
if (isShadowed) {
392390
return;

0 commit comments

Comments
 (0)