Skip to content

Add rule no-unused-props #1028

@oekazuma

Description

@oekazuma

Motivation

This rule aims to ensure consistency between the defined Props type and the actual use of $props().
This prevents mistakes due to overlooking properties and improves code readability and maintainability.
Enforcing this rule helps developers understand and reduces the risk of potential bugs.

Description

Issue a warning if the type of the defined Props does not match the variable destructuring assignment in $props().

Examples

<script lang="ts">
  /* ✓ GOOD */

  interface Props {
    a: string;
    b: number;
  }

  let { a, b }: Props = $props();

  /* ✗ BAD */

  interface Props {
    a: string;
    b: number;
  }

  let { a }: Props = $props();
</script>

Additional comments

No response

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