ember/template-no-unavailable-this
March 21, 2026 ยท View on GitHub
Disallow this in templates that are not inside a class or function.
Rule Details
In Ember and Glimmer, this refers to the component instance. When a <template> tag is used at module level (not inside a class body or function), this has no meaningful value and will be undefined. This rule catches accidental usage of this in such templates.
Examples
Examples of incorrect code for this rule:
<template>
{{this.name}}
</template>
<template>
{{yield this}}
</template>
Examples of correct code for this rule:
import Component from '@glimmer/component';
class MyComponent extends Component {
<template>{{this.name}}</template>
}
function myComponent() {
return <template>{{this.name}}</template>;
}
<template>
{{@value}}
</template>