# svelte/require-event-prefix
require component event names to start with βonβ
- β
This rule has not been released yet.
# π Rule Details
Starting with Svelte 5, component events are just component props that are functions and so can be called like any function. Events for HTML elements all have their name begin with βonβ (e.g. onclick
). This rule enforces that all component events (i.e. function props) also begin with βonβ.
<script lang="ts">
/* eslint svelte/require-event-prefix: "error" */
/* β GOOD */
interface Props {
regularProp: string;
onclick(): void;
}
let { regularProp, onclick }: Props = $props();
</script>
<script lang="ts">
/* eslint svelte/require-event-prefix: "error" */
/* β BAD */
interface Props {
click(): void;
}
let { click }: Props = $props();
</script>
# π§ Options
{
"svelte/require-event-prefix": [
"error",
{
"checkAsyncFunctions": false
}
]
}
checkAsyncFunctions
β¦ Whether to also report asychronous function properties. Defaultfalse
.