Skip to content

Latest commit

 

History

History
55 lines (37 loc) · 1.57 KB

File metadata and controls

55 lines (37 loc) · 1.57 KB

ember/template-no-negated-condition

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

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

Disallow negated conditions in {{#if}} blocks. Use {{#unless}} instead or rewrite the condition.

Rule Details

This rule discourages the use of {{#if (not condition)}} in favor of {{#unless condition}} for better readability.

Examples

Examples of incorrect code for this rule:

<template>
  {{#if (not isValid)}}
    Invalid
  {{/if}}
</template>

Examples of correct code for this rule:

<template>
  {{#unless isValid}}
    Invalid
  {{/unless}}
</template>

<template>
  {{#if isValid}}
    Valid
  {{/if}}
</template>

Options

Name Type Default Description
simplifyHelpers boolean true When true, also reports negated comparison helpers (e.g. (not (eq ...))) and suggests using (not-eq ...) instead.

Related Rules

References