pageClass | sidebarDepth | title | description | since |
---|---|---|---|---|
rule-details |
0 |
svelte/no-useless-children-snippet |
disallow explicit children snippet where it's not needed |
v3.0.0-next.9 |
disallow explicit children snippet where it's not needed
- ⚙️ This rule is included in
"plugin:svelte/recommended"
.
Any content inside component tags that is not a snippet declaration implicitly becomes part of the children snippet. Thus, declaring the children snippet explicitly is only necessary when the snippet has parameters.
<script>
/* eslint svelte/no-useless-children-snippet: "error" */
import { Foo } from './Foo.svelte';
</script>
<!-- ✓ GOOD -->
<Foo>
{#snippet bar()}
Hello
{/snippet}
</Foo>
<Foo>
{#snippet children(val)}
Hello {val}
{/snippet}
</Foo>
<Foo>Hello</Foo>
<!-- ✗ BAD -->
<Foo>
{#snippet children()}
Hello
{/snippet}
</Foo>
Nothing.
This rule was introduced in eslint-plugin-svelte v3.0.0-next.9