-
-
Notifications
You must be signed in to change notification settings - Fork 58
Open
Labels
Description
Motivation
Is there a rule to point out when a prop the is $bindable
, could be a normal prop? Meaning that we are not actually modifying such value in the component.
Description
The rule should point out when a Prop defined as $bindable
is not being modified in the component, nor being bind to any other children.
Examples
<!-- ✓ GOOD -->
<script lang="ts">
import AnotherComponent from './AnotherComponent.svelte';
interface Props {
step?: string;
}
let { step = 'initial-value' }: Props = $props();
</script>
<AnotherComponent {step} />
<!-- ✓ GOOD -->
<script lang="ts">
import AnotherComponent from './AnotherComponent.svelte';
interface Props {
step?: string;
}
let { step = $bindable('initial-value') }: Props = $props();
step = 'another-value';
</script>
<AnotherComponent {step} />
<!-- ✓ GOOD -->
<script lang="ts">
import AnotherComponent from './AnotherComponent.svelte';
interface Props {
step?: string;
}
let { step = $bindable('initial-value') }: Props = $props();
</script>
<AnotherComponent bind:step />
<!-- ✗ BAD -->
<script lang="ts">
import AnotherComponent from './AnotherComponent.svelte';
interface Props {
step?: string;
}
let { step = $bindable('initial-value') }: Props = $props();
</script>
<AnotherComponent {step} />