eslint-plugin-vue icon indicating copy to clipboard operation
eslint-plugin-vue copied to clipboard

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

Open sufuwang opened this issue 3 years ago • 4 comments

    "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 avatar Jun 18 '22 01:06 sufuwang

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

sufuwang avatar Jun 18 '22 08:06 sufuwang

i'm experiencing same problem

DaniilIsupov avatar Oct 26 '23 15:10 DaniilIsupov

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'),
};

FloEdelmann avatar Dec 06 '23 16:12 FloEdelmann