Skip to content

Latest commit

 

History

History
67 lines (46 loc) · 1.34 KB

File metadata and controls

67 lines (46 loc) · 1.34 KB

ember/template-no-redundant-fn

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

Disallows unnecessary usage of the {{fn}} helper.

When {{fn}} is used with only a function reference and no arguments to curry, it's redundant. You can pass the function directly.

Rule Details

This rule detects when {{fn}} is called with only one argument (the function itself) and no curried arguments.

Examples

Examples of incorrect code for this rule:

<template>
  <button {{on "click" (fn this.handleClick)}}>Click</button>
</template>
<template>
  <Component @action={{fn this.save}} />
</template>

Examples of correct code for this rule:

<template>
  <button {{on "click" this.handleClick}}>Click</button>
</template>
<template>
  <button {{on "click" (fn this.handleClick arg)}}>Click</button>
</template>
<template>
  <Component @action={{this.save}} />
</template>

Migration

Replace:

<button {{on "click" (fn this.action)}}>

With:

<button {{on "click" this.action}}>

References