Skip to content

Latest commit

 

History

History
74 lines (52 loc) · 1.48 KB

simple-unless.md

File metadata and controls

74 lines (52 loc) · 1.48 KB

simple-unless

✅ The extends: 'recommended' property in a configuration file enables this rule.

This rule strongly advises against {{unless}} blocks in the following situations:

  • With other block helpers (e.g. {{else}}, {{else if}})
  • With template helpers in the condition

Common solutions are to use an {{if}} block, or refactor potentially confusing logic within the template.

Examples

This rule forbids the following:

{{!-- `unless` condition has a template helper  --}}

{{unless (if true) "This is not recommended"}}
{{!-- `unless` statement has an `else` block  --}}

{{#unless bandwagoner}}
  Go Niners!
{{else}}
  Go Seahawks!
{{/unless}}
{{!-- conditional statement has an `else unless` block  --}}

{{#if condition}}
  Hello
{{else unless otherCondition}}
  World
{{/unless}}

This rule allows the following:

{{#if bandwagoner}}
  Go Blue Jays!
{{else}}
  Go Mariners!
{{/if}}
{{#unless condition}}
  Hello World
{{/unless}}

Configuration

The following values are valid configuration:

  • boolean -- true for enabled / false for disabled
  • object --
    • allowlist -- array - ['or'] for specific helpers / [] for wildcard
    • denylist -- array - ['or'] for specific helpers / [] for none
    • maxHelpers -- number - use -1 for no limit

Related Rules

References