Skip to content

Conversation

paoloricciuti
Copy link
Member

@paoloricciuti paoloricciuti commented Sep 18, 2025

This adds three autofixers:

set, update autofixer

Given this code

<script>
    let something = $state(0);
    something.set(43);
</script>

it suggest

You are trying to update the stateful variable "something" using "set". stateful variables should be updated with a normal assignment/mutation, do not use methods to update them.

As a note given code like this

<script>
    let something = $state({});
    something.set(43);
</script>

it suggests

You are trying to update the stateful variable "something" using "${method}". stateful variables should be updated with a normal assignment/mutation, do not use methods to update them. However I can't verify if "count" is a state variable of an object or a class with a "set" method on it. Please verify that before updating the code to use a normal assignment

No imported runes

Pretty straightforward given code like this

<script>
    import { state } from "svelte";
</script>

suggests

You are importing "state" from "svelte". This is not necessary, all runes are globally available. Please remove this import and use "$state" directly.

Note that it's checking for dollarless imports since if the AI tries to import $state it will receive a warning from the compiler itself.

Derived with function

This also pretty straightforward

<script>
    let der = $derived(()=>34);
</script>

will suggest

You are passing a function to $derived when declaring "der" but $derived expects an expression. You can use $derived.by instead.

@paoloricciuti paoloricciuti merged commit d4edef1 into main Sep 18, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants