Skip to content

vue/no-undef-properties does not respect Nuxt's asyncData #1668

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
2 tasks done
FloEdelmann opened this issue Oct 21, 2021 · 2 comments · Fixed by #1679
Closed
2 tasks done

vue/no-undef-properties does not respect Nuxt's asyncData #1668

FloEdelmann opened this issue Oct 21, 2021 · 2 comments · Fixed by #1679

Comments

@FloEdelmann
Copy link
Member

FloEdelmann commented Oct 21, 2021

Checklist

  • I have tried restarting my IDE and the issue persists.
  • I have read the FAQ and my problem is not listed.

Tell us about your environment

  • ESLint version: 7.32.0
  • eslint-plugin-vue version: 7.20.0
  • Node version: 14.18.1
  • Operating System: Ubuntu 20.04
  • Nuxt.js version: 2.15.8

Please show your full configuration:

{
  "env": {
    "es6": true,
    "node": true,
  },
  "parserOptions": {
    "ecmaVersion": 2021,
  },
  "plugins": ["vue"],
  "extends": ["eslint:recommended", "plugin:vue/recommended"],
  "rules": {
    "vue/no-undef-properties": "error"
  }
}

What did you do?

<template>
  <div>
    <h1>{{ post.title }}</h1>
    <p>{{ post.description }}</p>
  </div>
</template>

<script>
export default {
  async asyncData({ params, $http }) {
    const post = await $http.$get(`https://api.nuxtjs.dev/posts/${params.id}`);
    return { post };
  },
};
</script>

What did you expect to happen?
No error, since post is returned from asyncData. Please see https://nuxtjs.org/docs/features/data-fetching#async-data.

What actually happened?

error: 'post' is not defined (vue/no-undef-properties) at ui/pages/test-asyncdata.vue:3:12:
  1 | <template>
  2 |   <div>
> 3 |     <h1>{{ post.title }}</h1>
    |            ^
  4 |     <p>{{ post.description }}</p>
  5 |   </div>
  6 | </template>

Repository to reproduce this issue

OpenLightingProject/open-fixture-library@debug-eslint-vue-7.20.0/ui/pages/test-asyncdata.vue

Note that the ESLint config file there is more elaborate than the minimal example provided in this issue.

@ota-meshi
Copy link
Member

Thanks for posting this issue!
That rule currently doesn't parse Nuxt options. If there are other options that need to be parsed, could you share them in this issue?

@FloEdelmann
Copy link
Member Author

I just had a look through the Nuxt docs and didn't find any other problematic options.

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.

2 participants