Skip to content

vue/no-unused-properties doesn't recognize usages of props with toRefs #1496

Closed
@unshame

Description

@unshame

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

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