|
| 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