Skip to content

Latest commit

 

History

History
76 lines (54 loc) · 1.69 KB

simple-unless.md

File metadata and controls

76 lines (54 loc) · 1.69 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
    • whitelist -- deprecated, use allowlist. If both are provided, whitelist will be ignored.
    • denylist -- array - ['or'] for specific helpers / [] for none
    • blacklist -- deprecated, use denylist. If both are provided, blacklist will be ignored.
    • maxHelpers -- number - use -1 for no limit

Related Rules

References