-
-
Notifications
You must be signed in to change notification settings - Fork 53
Closed
Labels
Description
Motivation
In Svelte 5, all HTML element events are props starting with "on". Component events can have any name, so it is not clear, which props are events and which are not.
Description
I'd like to add a rule that requires that all props that are events (i.e. that are functions) start with "on"
Examples
<script lang="ts">
/* ✓ GOOD */
interface Props {
regularProp: string;
onclick(): void;
}
let { regularProp, onclick }: Props = $props;
/* ✗ BAD */
interface Props {
click(): void;
}
let { click }: Props = $props;
</script>
Additional comments
I think this works even without TS, as the type would be in the parsed AST, right?
lishaduck