-
-
Notifications
You must be signed in to change notification settings - Fork 53
Open
Labels
Description
Motivation
In our dev team, some devs tend to redefine event handlers as props which makes code more verbose than it needs to be.
Button.svelte
export let onClick = () => {}
...
<button on:click={onClick}>Click me</button>
Instead, we can rely on event forwarding like this:
Button.svelte
// no onClick prop
...
<button on:click>Click me</button>
See more: https://learn.svelte.dev/tutorial/event-forwarding
Description
The rule should report on props that mirror native HTML event handlers and suggest simplifying them with event forwarding.
Examples
<!-- ✓ GOOD -->
<button on:click>Click me</button>
<!-- ✗ BAD -->
<script>
export let onClick = () => {}
</script>
<button on:click={onClick}>Click me</button>
Additional comments
No response
Rican7