Skip to content

[no-unused-properties] can't recognize $props.xxx used #2344

Closed
@levchak0910

Description

@levchak0910

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: 8.55.0
  • eslint-plugin-vue version: 9.19.2
  • Node version: not applied, repro in playground
  • Operating System: not applied, repro in playground

Please show your full configuration:

{
    "rules": {
        'vue/no-unused-properties': 'error',
    }
}

What did you do?

<template>
  <div :class="$props.class"></div>
  <div>{{$props.for}}</div>
</template>

<script lang="ts" setup>
defineProps<{
  class: string
  for: number
}>()
</script>

What did you expect to happen?

props: class and for not reported as unused

What actually happened?

props: class and for reported as unused

Repository to reproduce this issue

playground link

Bug description:

When we want to define a prop name as a js keyword (for example: class, for, ...) it is required to use them as $props.PROP, because using simply as PROP will lead to parsing error.

Another option is to use as props.PROP with props variable declaration

<template>
  <div :class="props.class"></div>
  <div>{{props.for}}</div>
</template>

<script lang="ts" setup>
const props = defineProps<{
  class: string
  for: number
}>()
</script>

but the rule doesn't support it too #2193

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions