-
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(no-useless-children-snippet): added rule documentation
- Loading branch information
1 parent
5da3e86
commit be15b98
Showing
1 changed file
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
--- | ||
pageClass: 'rule-details' | ||
sidebarDepth: 0 | ||
title: 'svelte/no-useless-children-snippet' | ||
description: "disallow explicit children snippet where it's not needed" | ||
--- | ||
|
||
# svelte/no-useless-children-snippet | ||
|
||
> disallow explicit children snippet where it's not needed | ||
- :exclamation: <badge text="This rule has not been released yet." vertical="middle" type="error"> **_This rule has not been released yet._** </badge> | ||
|
||
## :book: Rule Details | ||
|
||
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. | ||
|
||
<ESLintCodeBlock> | ||
|
||
<!--eslint-skip--> | ||
|
||
```svelte | ||
<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> | ||
``` | ||
|
||
</ESLintCodeBlock> | ||
|
||
## :wrench: Options | ||
|
||
Nothing. | ||
|
||
## :mag: Implementation | ||
|
||
- [Rule source](https://github.com/sveltejs/eslint-plugin-svelte/blob/main/packages/eslint-plugin-svelte/src/rules/no-useless-children-snippet.ts) | ||
- [Test source](https://github.com/sveltejs/eslint-plugin-svelte/blob/main/packages/eslint-plugin-svelte/tests/src/rules/no-useless-children-snippet.ts) |