-
-
Notifications
You must be signed in to change notification settings - Fork 681
Rule suggestion: vue/no-use-v-else-with-v-for
#1939
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thank you for your suggestion. But I don't think it needs to be included in |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
I think it's a Volar bug. Volar transforms |
v-else-if
and v-else
in vue/no-use-v-if-with-v-for
vue/no-use-v-else-with-v-for
@kleinfreund Could you elaborate why you are against this rule? (I'm interpreting your 👎 reaction on the issue that way.) |
@FloEdelmann Because to me, the following is not ambiguous: <div v-if="foo">foo</div>
<div v-else v-for="x in xs">{{ x }}</div> I suppose the intent here is to avoid ambiguity like this: <div v-if="foo">foo</div>
<div v-else-if="x === thing" v-for="x in xs">{{ x }}</div> Now that’s perhaps something that’s worth it to make less ambiguous via stricter linter rules in which I don’t feel strongly about the introduction of the proposed rule. |
What rule do you want to change?
New rulevue/no-use-v-if-with-v-for
vue/no-use-v-else-with-v-for
Does this change cause the rule to produce more or fewer warnings?
More
How will the change be implemented? (New option, new default behavior, etc.)?
Not sure, but probably default behavior.
Please provide some example code that this change will affect:
<!-- BAD --> <div v-if="foo">foo</div> <div v-else v-for="x in xs">{{ x }}</div> <!-- GOOD --> <div v-if="foo">foo</div> <template v-else> <div v-for="x in xs">{{ x }}</div> </template>
<!-- BAD --> <div v-if="foo">foo</div> <div v-else-if="bar" v-for="x in xs">{{ x }}</div> <!-- GOOD --> <div v-if="foo">foo</div> <template v-else-if="bar"> <div v-for="x in xs">{{ x }}</div> </template>
What does the rule currently do for this code?
Only report the first case (
v-if
+v-for
).What will the rule do after it's changed?
Also warn about the other cases (
v-else
+v-for
andv-else-if
+v-for
), and maybe even autofix to add a wrapper<template>
tag.The text was updated successfully, but these errors were encountered: