Skip to content

Latest commit

 

History

History
73 lines (52 loc) · 1.59 KB

File metadata and controls

73 lines (52 loc) · 1.59 KB

ember/template-no-array-prototype-extensions

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

💼 This rule is enabled in the following configs: strict-gjs, strict-gts.

Disallow usage of Ember Array prototype extensions.

Ember historically provided Array prototype extensions like firstObject and lastObject. These extensions are deprecated and should be replaced with native JavaScript array methods or computed properties.

Rule Details

This rule disallows using Ember Array prototype extensions in templates:

  • firstObject
  • lastObject
  • @each
  • []

Examples

Incorrect ❌

<template>
  {{this.items.firstObject}}
</template>
<template>
  {{this.users.lastObject}}
</template>
<template>
  {{this.data.@each}}
</template>

Correct ✅

<template>
  {{get this.items 0}}
</template>
<template>
  {{this.firstItem}}
</template>
<template>
  {{#each this.items as |item|}}
    {{item}}
  {{/each}}
</template>

Related Rules

References