vuejs/vue-eslint-parser

9.1.1版本 v-for="item in enquirySwipers" :key="item.inquiryId" 会报 "Expected 'v-bind:key' directive to use the variables which are defined by the 'v-for' directive" 的错误,在9.1.0版本就正常

huzhen-v5 opened this issue · 3 comments

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I'm using eslint-plugin-vue.
  • I'm sure the problem is a parser problem. (If you are not sure, search for the issue in eslint-plugin-vue repo and open the issue in eslint-plugin-vue repo if there is no solution.
  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.

What version of ESLint are you using?

8.33.0

What version of eslint-plugin-vue and vue-eslint-parser are you using?

  • vue-eslint-parser@9.1.1
  • eslint-plugin-vue@9.9.0

What did you do?

Configuration
<!-- Paste your configuration here -->
<swiper-slide
  v-for="item in enquirySwipers"
  :key="item.inquiryId"
>
  <div class="item-container">
    <img :src="item.inquiryImgUrl" alt="" />
  </div>
</swiper-slide>

What did you expect to happen?

没有 vue/valid-v-for 的报错

What actually happened?

eslint报错:Expected 'v-bind:key' directive to use the variables which are defined by the 'v-for' directive.eslintvue/valid-v-for

Link to Minimal Reproducible Example

null

Additional comments

No response

I don't know what kind of problem you have, but at least it doesn't seem to be a parser problem.

目前9.3.1版本都有这个问题,楼主怎么解决的?

找到原因了,是因为@typescript-eslint/parser与vue-eslint-parse@9.1.1中template解析器不兼容导致,这样设置可以解决此问题:

parserOptions: {
        parser: {
          js: 'espree',
          ts: '@typescript-eslint/parser',
          '<template>': 'espree',
        },
      },