Skip to content

Commit eac4005

Browse files
committed
Extract rule: template-no-restricted-invocations
1 parent b430b92 commit eac4005

4 files changed

Lines changed: 994 additions & 0 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ rules in templates can be disabled with eslint directives with mustache or html
261261
| [template-no-page-title-component](docs/rules/template-no-page-title-component.md) | disallow usage of ember-page-title component | | | |
262262
| [template-no-positional-data-test-selectors](docs/rules/template-no-positional-data-test-selectors.md) | disallow positional data-test-* params in curly invocations | | | |
263263
| [template-no-potential-path-strings](docs/rules/template-no-potential-path-strings.md) | disallow potential path strings in attribute values | | | |
264+
| [template-no-restricted-invocations](docs/rules/template-no-restricted-invocations.md) | disallow certain components, helpers or modifiers from being used | | | |
264265
| [template-no-splattributes-with-class](docs/rules/template-no-splattributes-with-class.md) | disallow splattributes with class attribute | | | |
265266
| [template-no-this-in-template-only-components](docs/rules/template-no-this-in-template-only-components.md) | disallow this in template-only components (gjs/gts) | | 🔧 | |
266267
| [template-no-trailing-spaces](docs/rules/template-no-trailing-spaces.md) | disallow trailing whitespace at the end of lines in templates | | 🔧 | |
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# ember/template-no-restricted-invocations
2+
3+
<!-- end auto-generated rule header -->
4+
5+
Disallow certain components, helpers or modifiers from being used.
6+
7+
Use cases include:
8+
9+
- You bring in some addon with helpers or components, but your team deems one or many not suitable and wants to guard against their usage
10+
- You want to discourage use of a deprecated component
11+
12+
## Examples
13+
14+
Given a config of:
15+
16+
```json
17+
{ "template-no-restricted-invocations": ["foo-bar"] }
18+
```
19+
20+
This rule **forbids** the following:
21+
22+
```gjs
23+
<template>{{foo-bar}}</template>
24+
```
25+
26+
```gjs
27+
<template>{{#foo-bar}}{{/foo-bar}}</template>
28+
```
29+
30+
```gjs
31+
<template><FooBar /></template>
32+
```
33+
34+
This rule **allows** the following:
35+
36+
```gjs
37+
<template>{{baz}}</template>
38+
```
39+
40+
```gjs
41+
<template><Baz /></template>
42+
```
43+
44+
## Configuration
45+
46+
One of these:
47+
48+
- `string[]` - helpers or components to disallow (using kebab-case names like `nested-scope/component-name`)
49+
- `object[]` - with the following keys:
50+
- `names` - `string[]` - helpers or components to disallow
51+
- `message` - `string` - custom error message to report for violations
52+
53+
```js
54+
// .eslintrc.js
55+
module.exports = {
56+
rules: {
57+
'ember/template-no-restricted-invocations': [
58+
'error',
59+
[
60+
'foo-bar',
61+
{
62+
names: ['deprecated-component'],
63+
message: 'Use new-component instead',
64+
},
65+
],
66+
],
67+
},
68+
};
69+
```
70+
71+
## Related Rules
72+
73+
- [ember/no-restricted-service-injections](https://github.com/ember-cli/eslint-plugin-ember/blob/master/docs/rules/no-restricted-service-injections.md)
74+
75+
## References
76+
77+
- [emberjs.com - Deprecations](https://guides.emberjs.com/release/deprecations/)

0 commit comments

Comments
 (0)