Skip to content

New rule: svelte/prefer-derived-over-derived-by #1246

Open
@baseballyama

Description

@baseballyama

Motivation

From a consistency perspective, this rule reports unnecessary usage of $derived.by. There is no performance difference. It purely enforces a consistent coding style. Even if included in recommended config, a warning level should be sufficient.

Description

This rule reports unnecessary usage of $derived.by. It also provides a fixer to automatically convert $derived.by to $derived.

Examples

<script>
// ✓ GOOD
const foo = $derived(a.b);

// ✗ BAD
const bar = $derived.by(() => a.b);
</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