Skip to content

Latest commit

 

History

History
54 lines (39 loc) · 1.65 KB

File metadata and controls

54 lines (39 loc) · 1.65 KB

ember/template-no-unnecessary-component-helper

💼 This rule is enabled in the 📋 template-lint-migration config.

🔧 This rule is automatically fixable by the --fix CLI option.

HBS Only: This rule applies to classic .hbs template files only (loose mode). It is not relevant for gjs/gts files (strict mode), where these patterns cannot occur.

The component template helper can be used to dynamically pick the component being rendered based on the provided property. But if the component name is passed as a string because it's already known, then the component should be invoked directly, instead of using the component helper.

Examples

This rule forbids the following:

<template>
  {{component "my-component"}}
</template>

This rule allows the following:

<template>
  {{component SOME_COMPONENT_NAME}}
</template>
<template>
  {{!-- the `component` helper is needed to invoke this --}}
  {{component "addon-name@component-name"}}
</template>
<template>
  {{my-component}}
</template>
<template>
  {{my-component close=(component "link-to" "index")}}
  <MyComponent @close={{component "link-to" "index"}} />
</template>

References