Skip to content

Latest commit

 

History

History
102 lines (76 loc) · 1.62 KB

File metadata and controls

102 lines (76 loc) · 1.62 KB

ember/template-no-chained-this

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

Disallow redundant this.this in templates.

Using this.this.* in templates is almost always a typo or copy/paste mistake. These patterns are misleading and result in unnecessary ambiguity about scope and component context.

Rule Details

This rule disallows this.this.* patterns in templates (e.g., {{this.this.foo}} or <this.this.Bar />).

Examples

Incorrect ❌

<template>
  {{this.this.value}}
</template>
<template>
  {{#this.this.foo}}
    some text
  {{/this.this.foo}}
</template>
<template>
  {{helper value=this.this.foo}}
</template>
<template>
  <this.this.Component />
</template>
<template>
  {{component this.this.dynamicComponent}}
</template>

Correct ✅

<template>
  {{this.value}}
</template>
<template>
  <this.Component />
</template>
<template>
  {{component this.dynamicComponent}}
</template>
<template>
  {{@argName}}
</template>

Migration

Remove the extra this:

Before:

<template>
  {{this.this.foo}}
  <this.this.bar />
</template>

After:

<template>
  {{this.foo}}
  <this.bar />
</template>

References