Skip to content

Rule to point out when a $bindable is not used as such #1455

@AntonioVentilii

Description

@AntonioVentilii

Motivation

It is useful and a better code (by dev's choice) to point out when a $bindable prop is not being used as bindable in the parent consumer.

Description

The rule will enforce the use of a prop as $bindable in the parent, if it is defined as such. Otherwise the exception should be explicitly set with eslint-disable-next-line (or similar).

Examples

<!-- Child -->
<script lang="ts">
	interface Props {
		value: number;
	}

	let { value = $bindable(0) }: Props = $props();
</script>

<button onclick={() => value++}>Increment</button>

The value is {value}
<!-- Parent -->
<script>
        let value = $state(0);
</script>

<!-- ✓ GOOD -->
<Child bind:value />

<!-- ✗ BAD -->
<Child {value} />

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