Skip to content
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

vue/no-template-key, vue/valid-v-for need to be updated for vue-next 3.0.0-rc.6 #1279

Closed
1 task done
bompus opened this issue Aug 19, 2020 · 6 comments · Fixed by #1289
Closed
1 task done

vue/no-template-key, vue/valid-v-for need to be updated for vue-next 3.0.0-rc.6 #1279

bompus opened this issue Aug 19, 2020 · 6 comments · Fixed by #1289

Comments

@bompus
Copy link

bompus commented Aug 19, 2020

Due to a vue compiler error, I was made aware that in Vue 3, :key can/should be placed directly on instead of the direct child element. I'm not sure when this changed, but a recent vue-next commit that is now part of 3.0.0-rc.6 now throws the error when compiling.

Re: vuejs/core@b0d01e9

Checklist

  • I checked the FAQ.

Tell us about your environment

  • ESLint version: 7.7.0
  • eslint-plugin-vue version: 7.0.0-beta.2
  • Node version: 14.8.0
  • Operating System: Ubuntu 20.04.1 LTS

What did you do?

<template v-for="val in tree" :key="val.refId">
   <component :is="MyComponent" :item="val" />
</template>

What did you expect to happen?
No ESLint rule errors.

What actually happened?

error: '<template>' cannot be keyed. Place the key on real elements instead (vue/no-template-key) at src/ContentFrame/ContentFrame.vue:36:5:
  35 |   <div ref="root" class="ContentFrame">
> 36 |     <template v-for="val in tree" :key="val.refId">
     |     ^
  37 |       <component :is="MyComponent" :item="val"

error: Custom elements in iteration require 'v-bind:key' directives (vue/valid-v-for) at src/ContentFrame/ContentFrame.vue:37:7:
  36 |     <template v-for="val in tree" :key="val.refId">
> 37 |       <component :is="MyComponent" :item="val"
     |       ^

@bompus bompus changed the title Fixes for vue 3.0.0-rc.6 [vue/no-template-key] [vue/valid-v-for] vue/no-template-key, vue/valid-v-for need to be updated for vue-next 3.0.0-rc.6 Aug 19, 2020
@ota-meshi
Copy link
Member

ota-meshi commented Aug 20, 2020

Thank you for this issue.
I didn't know about changing the template key handling. I need to check the template key handling in Vue3 and think about changing this plugin.
Please work around the this problem by turning off the false positive rules until the fix and released.

@sodatea
Copy link
Member

sodatea commented Aug 20, 2020

See also vuejs/core#1734 (comment)

@ota-meshi
Copy link
Member

I missed that, sorry 😅

@ota-meshi
Copy link
Member

ota-meshi commented Aug 20, 2020

related: vuejs/core#1907

@ota-meshi
Copy link
Member

ota-meshi commented Aug 21, 2020

I considered changing this plugin to solve this problem.

First, we need to make four changes:

Next, I think it's useful to add the following new rule for Vue3:

I welcome your opinions. If you have any opinions please comment this issue.

I will work on these when I have time.

@bompus
Copy link
Author

bompus commented Aug 21, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants