Skip to content
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

vue/no-undef-properties have some error when use toRefs #1915

Open
sufuwang opened this issue Jun 18, 2022 · 3 comments
Open

vue/no-undef-properties have some error when use toRefs #1915

sufuwang opened this issue Jun 18, 2022 · 3 comments

Comments

@sufuwang
Copy link

    "eslint": "8.18.0",
    "eslint-plugin-prettier": "4.0.0",
    "eslint-plugin-vue": "9.1.1",
module.exports = {
  root: true,
  globals: {
    uni: 'readonly',
    wx: 'readonly',
    App: 'readonly',
    ProcessEnvVueAppEnv: 'readonly',
    ProcessEnvWxPlatform: 'readonly',
    ProcessEnvBuildTime: 'readonly',
    getCurrentPages: 'readonly',
    getApp: 'readonly',
    PropType: 'readonly',
    AnyObject: 'readonly',
    Ref: 'readonly'
  },
  extends: ['plugin:vue/vue3-recommended'],
  parser: 'vue-eslint-parser',
  parserOptions: {
    parser: '@typescript-eslint/parser',
    extraFileExtensions: ['.vue'],
    createDefaultProgram: true,
  },
  plugins: ['@typescript-eslint', 'vue'],
  env: {
    browser: true,
    node: true,
  },
  rules: {
    'vue/no-undef-properties': 'error',
  },
  overrides: [
    {
      files: ['*.js', '*.vue'],
      rules: {
        'no-undef': 'error',
      },
    },
  ],
};
<template>
  <div>{{ a }}</div>
</template>
<script>
export default defineComponent({
  setup() {
    const data = reactive({
      a: 1,
      b: 1,
    });
    return {
      ...toRefs(data),
    };
  },
});
</script>

image

@sufuwang
Copy link
Author

@ota-meshi
hi,do you have some solution ? it is bothering me .

@DaniilIsupov

This comment was marked as spam.

@FloEdelmann
Copy link
Member

PR welcome. As a workaround, you have to specify the properties manually:

const data = reactive({
  a: 1,
  b: 1,
});
return {
  a: toRef(data, 'a'),
  b: toRef(data, 'b'),
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants