Skip to content

no-useless-assignment false positive on write-only $bindable #1478

@tomasz13nocon

Description

@tomasz13nocon

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.

What version of ESLint are you using?

10.0.1

What version of eslint-plugin-svelte are you using?

3.15.0

What did you do?

A $bindable prop, which is modified, but not read will cause the eslint error no-useless-assignment which is included in eslint's recommended (default) ruleset as of eslint v10. The value could be read in a parent component, but eslint doesn't see this.

What did you expect to happen?

no eslint error for correct svelte code

What actually happened?

error This assigned value is not used in subsequent statements no-useless-assignment

Link to GitHub Repo with Minimal Reproducible Example

<script lang="ts">
	let { count = $bindable() }: { count: number } = $props();

	function onclick() {
		count = 0;
	}
</script>

<button {onclick}>Reset</button>

Additional comments

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions