Skip to content

Latest commit

 

History

History
90 lines (63 loc) · 2.15 KB

File metadata and controls

90 lines (63 loc) · 2.15 KB

ember/template-no-action-modifiers

🔧 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 {{action}} modifiers in templates.

The {{action}} modifier has been deprecated in favor of the {{on}} modifier. The {{on}} modifier provides a more explicit and flexible way to handle events.

Rule Details

This rule disallows using {{action}} as an element modifier.

Examples

Incorrect ❌

<template>
  <button {{action "save"}}>Save</button>
</template>
<template>
  <div {{action "onClick"}}>Click me</div>
</template>
<template>
  <form {{action "submit" on="submit"}}>Submit</form>
</template>

Correct ✅

<template>
  <button {{on "click" this.handleClick}}>Save</button>
</template>
<template>
  <div {{on "click" this.onClick}}>Click me</div>
</template>
<template>
  <form {{on "submit" this.handleSubmit}}>Submit</form>
</template>

Options

Name Type Default Description
allowlist string[] [] List of element tag names where {{action}} modifiers should be allowed

The option can be passed as an array (shorthand) or an object:

Shorthand:

{
  "ember/template-no-action-modifiers": ["error", ["button"]]
}

Object form:

{
  "ember/template-no-action-modifiers": ["error", { "allowlist": ["button"] }]
}

Related Rules

References