Skip to content

Nested v-for breaks variable usage detection #164

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

Closed
HerringtonDarkholme opened this issue Aug 24, 2017 · 1 comment
Closed

Nested v-for breaks variable usage detection #164

HerringtonDarkholme opened this issue Aug 24, 2017 · 1 comment

Comments

@HerringtonDarkholme
Copy link
Member

  • ESLint Version: 4.5.0
  • eslint-plugin-vue Version: 3.12.0
  • Node Version: 8.0.0
module.exports = {
  extends: [
    'eslint:recommended',
    'plugin:vue/recommended' // or 'plugin:vue/base'
  ],
}

Code:

<template>
  <div>
  <template v-for="item in dealItemList">
    <li v-for="snapItem in item.dealItemSnapList" :key="snapItem.id">
      123
    </li>
  </template>
  </div>
</template>

What did you expect to happen?

No error, since inner iterator snapItem depends on item, thus snapItem.id uses both inner and outer variables.

What actually happened? Please include the actual, raw output from ESLint.

Error.

@armano2
Copy link
Contributor

armano2 commented Aug 24, 2017

severity: 'Error'
message: 'Expected 'v-bind:key' directive to use the variables which are defined by the 'v-for' directive. (vue/valid-v-for)'
at: '4,51'
source: 'eslint'

armano2 added a commit to armano2/eslint-plugin-vue that referenced this issue Aug 24, 2017
HerringtonDarkholme added a commit to HerringtonDarkholme/eslint-plugin-vue that referenced this issue Aug 25, 2017
Fix vuejs#164, don't report error when nested v-for refers iterator.
Do report error when nested v-for doesn't refer iterator.
mysticatea pushed a commit that referenced this issue Sep 1, 2017
* polish template v-for error report

Fix #164, don't report error when nested v-for refers iterator.
Do report error when nested v-for doesn't refer iterator.

* update jsdoc

* check iterator usage in new way

* add more test cases

* fix code style

* cosmetic indentation
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