-
-
Notifications
You must be signed in to change notification settings - Fork 681
Replace require-v-for-key with new rule just for stateful elements #522
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
I'm adding some specific messages and examples for each case here, to make building the rule easier. Missing
|
This is how all proposal should look like! Really good piece of work @chrisvfritz 🥇 I agree with everything, but one case: So the way I see it is by having two separate rules:
We should also take cases with <template v-for="n in 2">
<my-component/> <!-- missing key -->
</template> <template v-for="n in 2">
<input> <!-- missing key -->
</template> <template v-for="n in 2">
<div v-html="n" /> <!-- missing key -->
</template> |
😊 🙈
That sounds good to me. 🙂
|
Hello people, any progress on this? I could probably take a shot at it, with a bit of guidance from a maintainer. Also, as a suggestion, can we also add a |
@michalsnik @chrisvfritz Ping? |
The Problem
A lot of users get upset when the linter yells at them for not providing a
key
when it doesn't create a real problem and Vue itself doesn't complain. The real intent with this rule is to maintain object constancy to avoid:data
properties being reset, lifecycle methods being re-run unnecessarily)input
,select
, etc (e.g.value
being lost if not passed as a prop)<transition>
or<transition-group>
elements.Potential Solution
To make everyone happy, I'm wondering if we may want to rename
require-v-for-key
to something likerequire-v-for-key-stateful-elements
, then change its behavior so that it only gives a warning on:v-html
<transition>
or<transition-group>
.Thoughts?
I'd like to get some other people weighing in on this before making the change, as there may be other cases I'm not considering.
The text was updated successfully, but these errors were encountered: