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-unused-properties doesn't recognize usages of props with toRefs #1496

Closed
2 tasks done
unshame opened this issue May 22, 2021 · 1 comment
Closed
2 tasks done

Comments

@unshame
Copy link

unshame commented May 22, 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.25.0
  • eslint-plugin-vue version: 7.9.0
  • Node version: v12.18.2
  • Operating System: Windows 10

Please show your full configuration:

module.exports = {
    extends: [
        'plugin:vue/vue3-recommended',
    ],
    rules: {
        'vue/no-unused-properties': [
            'error',
            {
                groups: [
                    'props', // TODO: figure out why doesn't work for toRefs
                    'data',
                    'setup',
                ],
                deepData: false,
                ignorePublicMembers: true, // mark with /** @public */
            },
        ],
    }
}

What did you do?

<template>
  <div class="hello">
    <h1>{{ msgInternal }}</h1>
  </div>
</template>

<script>
import { computed, defineComponent, toRefs } from '@vue/composition-api';

export default defineComponent({
    name: 'HelloWorld',
    props: {
        msg: {
            type: String,
            required: true,
        },
    },

    setup(props) {
        const { msg } = toRefs(props);

        return {
            msgInternal: computed(() => msg.value),
        }
    }
});
</script>

What did you expect to happen?
prop msg would be marked as used.

What actually happened?

E:\Git\vue-unused-props-debug\src\components\HelloWorld.vue
13:9 error 'msg' of property found, but never used vue/no-unused-properties

Repository to reproduce this issue
https://github.com/unshame/vue-unused-props-debug

@ota-meshi
Copy link
Member

Fixed in #1647.

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

2 participants