Skip to content

Latest commit

 

History

History
60 lines (47 loc) · 1.35 KB

no-with.md

File metadata and controls

60 lines (47 loc) · 1.35 KB

no-with

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

The use of {{with}} has been deprecated, you should replace it with either {{let}} or a combination of {{let}}, {{if}} and {{else}}.

Examples

This rule forbids the following:

{{#with (hash name="Ben" age=4) as |person|}}
  Hi {{person.name}}, you are {{person.age}} years old.
{{/with}}
{{#with user.posts as |blogPosts|}}
  There are {{blogPosts.length}} blog posts.
{{/with}}
{{#with user.posts as |blogPosts|}}
  There are {{blogPosts.length}} blog posts.
{{else}}
  There are no blog posts.
{{/with}}

This rule allows the following:

{{#let (hash name="Ben" age=4) as |person|}}
  Hi {{person.name}}, you are {{person.age}} years old.
{{/let}}
{{#let user.posts as |blogPosts|}}
  {{#if blogPosts.length}}
    There are {{blogPosts.length}} blog posts.
  {{/if}}
{{/let}}
{{#let user.posts as |blogPosts|}}
  {{#if blogPosts.length}}
    There are {{blogPosts.length}} blog posts.
  {{else}}
    There are no blog posts.
  {{/if}}
{{/let}}

References