vuetifyjs / vue-cli-plugins

🔌 A collection of Vuetify plugins for Vue CLI
https://vuetifyjs.com/en/getting-started/quick-start#vue-cli-3
Other
428 stars 113 forks source link

'v-slot' directive doesn't support any modifier #235

Closed sbernard31 closed 3 years ago

sbernard31 commented 3 years ago

I'm new in vue world.

And I'm currently writing a vue/vuetify application using vscodium as IDE.

I follow the standard way to create my app :

vue create my-app
cd my-app
vue add vuetify

Now in vscodium I get this kind of error :

vue/valid-v-slot]
'v-slot' directive doesn't support any modifier.eslint-plugin-vue

for this kind of code :

<template>
  <v-data-table
    dense
    :loading="loading"
    :headers="headers"
    :items="registrations"
    item-key="endpoint"
    :items-per-page="5"
    class="elevation-1"
    @click:row="openLink"
  >
    <!-- ======= ERROR FOR THIS 2 SLOTS ======== -->
    <template v-slot:item.registrationDate="{ item }">
      {{ new Date(item.registrationDate) | moment("from") }}
    </template>
    <template v-slot:item.lastUpdate="{ item }">
      {{ new Date(item.lastUpdate) | moment("from") }}
    </template>
  </v-data-table>
</template>

Capture d’écran de 2021-02-19 12-02-17

But the code works and it seems I follow the recommended way by vuetify : https://vuetifyjs.com/en/components/data-tables/#item

I checked eslint-plugin-vue issues there is a lot of issue reported related to this.

I also find some kind of workaround : Using this v-slot:[`item.registrationDate`] instead of v-slot:item.registrationDate seems to make the validator happy.

It seems there is also a kind of fix but it need some configuration : https://github.com/vuejs/eslint-plugin-vue/pull/1330#issuecomment-712625006

My question are :

  1. is the workaround the good way to go ? if yes is the vuetify doc should be updated ?
  2. is the configuration the good way to go ? if yes, should it be done by default by a vue-cli plugin for vuetify ?

I ask this question here hoping this is the best place halfway between vuetify and eslint-plugin-vue.

sbernard31 commented 3 years ago

Maybe some people from vuetify and other from eslint-plugin-vue should participate too ? I guess @ota-meshi from eslint-plugin-vue is aware about this issue. I don't know who to ask for vuetify ?

ElijahKotyluk commented 3 years ago

The eslint rule is coming from the Vue eslint plugin, which is provided by Vue cli when generating a project and selecting eslint as an option, you can disable the rule in your eslint config to get around it.

sbernard31 commented 3 years ago

Thx you very much for the answer. For my usage I find many way to resolve this issue either using the v-slot:[`item.registrationDate`] way or the config way :

fenilli commented 3 years ago
  • (for vscodium/vetur only : add "vetur.validation.template": false in vetur.config.js for me reopen folder is needed)

this one disables vetur validation completely, makes it really bad if you're working with eslint and prettier to format your code, as you don't get those amazing red lines that tell you that your code is too big and needs to be formated.

is there any other workaround this? as I don't want to disable vetur, I want vetur to use my rules inside eslintrc.

jasonbrent commented 3 years ago

Piling on to this closed issue.... Using the eslintrc.js workaround with nuxt/vuetify/vue2 works exactly once per save of eslintrc. As soon as I save the component again, the error reappears until I simply touch the eslintrc.