Skip to content

Latest commit

 

History

History
75 lines (55 loc) · 1.9 KB

File metadata and controls

75 lines (55 loc) · 1.9 KB

ember/template-simple-unless

💼 This rule is enabled in the 📋 template-lint-migration config.

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

Require simple conditions in {{#unless}} blocks. Complex expressions should use {{#if}} with negation instead.

Rule Details

This rule enforces using simple property paths in {{#unless}} blocks rather than complex helper expressions.

Examples

Examples of incorrect code for this rule:

<template>
  {{#unless (or (eq a 1) (gt b 2))}}
    Complex condition
  {{/unless}}
</template>
<template>
  {{#unless (and isAdmin (not isBanned))}}
    Not allowed
  {{/unless}}
</template>

Examples of correct code for this rule:

<template>
  {{#unless isHidden}}
    Visible
  {{/unless}}
</template>
<template>
  {{#unless (eq value 1)}}
    Not one
  {{/unless}}
</template>
<template>
  {{#if (not (or a b))}}
    Neither
  {{/if}}
</template>

Options

Name Type Default Description
allowlist string[] [] Helper names allowed inside {{unless}}.
denylist string[] [] Helper names explicitly denied inside {{unless}}.
maxHelpers integer 1 Maximum number of helpers allowed inside {{unless}} (-1 for unlimited).

Related Rules

References