Skip to content

Commit 9ba83ed

Browse files
Merge pull request #2583 from NullVoxPopuli/nvp/template-lint-extract-rule-template-no-unknown-arguments-for-builtin-components
Extract rule: template-no-unknown-arguments-for-builtin-components
2 parents 300da43 + 6343fbd commit 9ba83ed

4 files changed

Lines changed: 924 additions & 7 deletions

README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -412,13 +412,14 @@ rules in templates can be disabled with eslint directives with mustache or html
412412

413413
### Possible Errors
414414

415-
| Name                                     | Description | 💼 | 🔧 | 💡 |
416-
| :------------------------------------------------------------------------------------------------- | :---------------------------------------------------------------- | :- | :- | :- |
417-
| [template-no-extra-mut-helper-argument](docs/rules/template-no-extra-mut-helper-argument.md) | disallow passing more than one argument to the mut helper | | | |
418-
| [template-no-jsx-attributes](docs/rules/template-no-jsx-attributes.md) | disallow JSX-style camelCase attributes | | 🔧 | |
419-
| [template-no-scope-outside-table-headings](docs/rules/template-no-scope-outside-table-headings.md) | disallow scope attribute outside th elements | | | |
420-
| [template-no-shadowed-elements](docs/rules/template-no-shadowed-elements.md) | disallow ambiguity with block param names shadowing HTML elements | | | |
421-
| [template-no-unbalanced-curlies](docs/rules/template-no-unbalanced-curlies.md) | disallow unbalanced mustache curlies | | | |
415+
| Name                                                 | Description | 💼 | 🔧 | 💡 |
416+
| :------------------------------------------------------------------------------------------------------------------------- | :---------------------------------------------------------------- | :- | :- | :- |
417+
| [template-no-extra-mut-helper-argument](docs/rules/template-no-extra-mut-helper-argument.md) | disallow passing more than one argument to the mut helper | | | |
418+
| [template-no-jsx-attributes](docs/rules/template-no-jsx-attributes.md) | disallow JSX-style camelCase attributes | | 🔧 | |
419+
| [template-no-scope-outside-table-headings](docs/rules/template-no-scope-outside-table-headings.md) | disallow scope attribute outside th elements | | | |
420+
| [template-no-shadowed-elements](docs/rules/template-no-shadowed-elements.md) | disallow ambiguity with block param names shadowing HTML elements | | | |
421+
| [template-no-unbalanced-curlies](docs/rules/template-no-unbalanced-curlies.md) | disallow unbalanced mustache curlies | | | |
422+
| [template-no-unknown-arguments-for-builtin-components](docs/rules/template-no-unknown-arguments-for-builtin-components.md) | disallow unknown arguments for built-in components | | | |
422423

423424
### Routes
424425

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# ember/template-no-unknown-arguments-for-builtin-components
2+
3+
<!-- end auto-generated rule header -->
4+
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.
6+
7+
This rule warns about `unknown`, `required` and `conflicted` arguments for `LinkTo`, `Input`, `Textarea` components.
8+
9+
## Examples
10+
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+
```
18+
19+
```hbs
20+
<Input @foo='bar' />
21+
```
22+
23+
```hbs
24+
<Textarea @foo='bar' />
25+
```
26+
27+
This rule **allows** the following:
28+
29+
```hbs
30+
<LinkTo @route='readme'> readme </LinkTo>
31+
```
32+
33+
```hbs
34+
<Input @value='someValue' />
35+
```
36+
37+
```hbs
38+
<Textarea @value='someValue' />
39+
```
40+
41+
## Migration
42+
43+
- Check references section to get allowed arguments list.
44+
- If argument represents html attribute, remove `@` from name.
45+
46+
## Related Rules
47+
48+
- [no-link-to-tagname](template-no-link-to-tagname.md)
49+
- [no-input-tagname](template-no-input-tagname.md)
50+
- [builtin-component-arguments](template-builtin-component-arguments.md)
51+
52+
## References
53+
54+
- [Reduce API Surface of Built-In Components](https://github.com/emberjs/rfcs/blob/master/text/0707-modernize-built-in-components-2.md#summary)

0 commit comments

Comments
 (0)