Skip to content

svelte/prefer-destructured-store-props doesn't like $derived.by in .svelte.ts files #1433

@KieranP

Description

@KieranP

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?

9.39.1

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

3.13.0

What did you do?

test.svelte.ts

export class Test {
  private readonly a = $state(0)
  private readonly b = $derived.by(() => this.a * 2)

  public output(): void {
    console.log(this.a, this.b)
  }
}

What did you expect to happen?

No linting errors

What actually happened?

test.svelte.ts
  3:24  error  Destructure by from $derived for better change tracking & fewer redraws  svelte/prefer-destructured-store-props

It's wanting me to do this, which makes no sense:

const { by } = $derived

Link to GitHub Repo with Minimal Reproducible Example

export class Test {
  private readonly a = $state(0)
  private readonly b = $derived.by(() => this.a * 2)

  public output(): void {
    console.log(this.a, this.b)
  }
}

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