Rule proposal: prefer-empty #2350
Closed
reduckted
started this conversation in
New Rule Proposals
Replies: 2 comments
-
I think |
Beta Was this translation helpful? Give feedback.
0 replies
-
Implemented in #2352. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Using the
@empty
flow control block is more readable than using an@if
block to achieve the same thing.@if (items.length > 0) { for (item of items; track $index) { {{ item }} } } @else { There are no items }
vs
There are two cases that I think can be detected.
@if
with only an@for
within it, and an@else
that checks the length of the same collection used in the@for
block.@for
block, followed immediately by an@if
block that checks the length of the same collection used in the@for
block.I'm not sold on the name though. It could easily be interpreted as something that is the opposite of
no-empty-control-flow
. Other possible names:prefer-at-empty
prefer-for-empty
prefer-empty-block
Beta Was this translation helpful? Give feedback.
All reactions