Skip to content

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

Closed
@FloEdelmann

Description

@FloEdelmann

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions