Skip to content

Latest commit

 

History

History
56 lines (40 loc) · 1.41 KB

File metadata and controls

56 lines (40 loc) · 1.41 KB

ember/template-no-action

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

Disallows the use of {{action}} helper.

The {{action}} helper is deprecated in favor of the {{on}} modifier and {{fn}} helper, which provide better performance and clearer intent.

Examples

Examples of incorrect code for this rule:

<template>
  <button {{on "click" (action "save")}}>Save</button>
</template>
<template>
  {{action "doSomething"}}
</template>

Examples of correct code for this rule:

<template>
  <button {{on "click" this.save}}>Save</button>
</template>
<template>
  <button {{on "click" (fn this.save "arg")}}>Save with arg</button>
</template>
<template>
  {{this.action}}
</template>

Migration

  • Replace (action "methodName") with method references or (fn this.methodName)
  • Replace <button onclick={{action ...}}> with <button {{on "click" ...}}>

References