File tree 5 files changed +34
-0
lines changed
packages/eslint-plugin-svelte/src
5 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -425,6 +425,7 @@ These rules relate to better ways of doing things to help you avoid problems:
425
425
| [ svelte/no-svelte-internal] ( https://sveltejs.github.io/eslint-plugin-svelte/rules/no-svelte-internal/ ) | svelte/internal will be removed in Svelte 6. | |
426
426
| [ svelte/no-unused-class-name] ( https://sveltejs.github.io/eslint-plugin-svelte/rules/no-unused-class-name/ ) | disallow the use of a class in the template without a corresponding style | |
427
427
| [ svelte/no-unused-svelte-ignore] ( https://sveltejs.github.io/eslint-plugin-svelte/rules/no-unused-svelte-ignore/ ) | disallow unused svelte-ignore comments | :star : |
428
+ | [ svelte/no-useless-children-snippet] ( https://sveltejs.github.io/eslint-plugin-svelte/rules/no-useless-children-snippet/ ) | disallow explicit children snippet where it's not needed | |
428
429
| [ svelte/no-useless-mustaches] ( https://sveltejs.github.io/eslint-plugin-svelte/rules/no-useless-mustaches/ ) | disallow unnecessary mustache interpolations | :wrench : |
429
430
| [ svelte/prefer-destructured-store-props] ( https://sveltejs.github.io/eslint-plugin-svelte/rules/prefer-destructured-store-props/ ) | destructure values from object stores for better change tracking & fewer redraws | :bulb : |
430
431
| [ svelte/require-each-key] ( https://sveltejs.github.io/eslint-plugin-svelte/rules/require-each-key/ ) | require keyed ` {#each} ` block | |
Original file line number Diff line number Diff line change @@ -62,6 +62,7 @@ These rules relate to better ways of doing things to help you avoid problems:
62
62
| [ svelte/no-svelte-internal] ( ./rules/no-svelte-internal.md ) | svelte/internal will be removed in Svelte 6. | |
63
63
| [ svelte/no-unused-class-name] ( ./rules/no-unused-class-name.md ) | disallow the use of a class in the template without a corresponding style | |
64
64
| [ svelte/no-unused-svelte-ignore] ( ./rules/no-unused-svelte-ignore.md ) | disallow unused svelte-ignore comments | :star : |
65
+ | [ svelte/no-useless-children-snippet] ( ./rules/no-useless-children-snippet.md ) | disallow explicit children snippet where it's not needed | |
65
66
| [ svelte/no-useless-mustaches] ( ./rules/no-useless-mustaches.md ) | disallow unnecessary mustache interpolations | :wrench : |
66
67
| [ svelte/prefer-destructured-store-props] ( ./rules/prefer-destructured-store-props.md ) | destructure values from object stores for better change tracking & fewer redraws | :bulb : |
67
68
| [ svelte/require-each-key] ( ./rules/require-each-key.md ) | require keyed ` {#each} ` block | |
Original file line number Diff line number Diff line change @@ -249,6 +249,11 @@ export interface RuleOptions {
249
249
* @see https://sveltejs.github.io/eslint-plugin-svelte/rules/no-unused-svelte-ignore/
250
250
*/
251
251
'svelte/no-unused-svelte-ignore' ?: Linter . RuleEntry < [ ] >
252
+ /**
253
+ * disallow explicit children snippet where it's not needed
254
+ * @see https://sveltejs.github.io/eslint-plugin-svelte/rules/no-useless-children-snippet/
255
+ */
256
+ 'svelte/no-useless-children-snippet' ?: Linter . RuleEntry < [ ] >
252
257
/**
253
258
* disallow unnecessary mustache interpolations
254
259
* @see https://sveltejs.github.io/eslint-plugin-svelte/rules/no-useless-mustaches/
Original file line number Diff line number Diff line change
1
+ import { createRule } from '../utils' ;
2
+
3
+ export default createRule ( 'no-useless-children-snippet' , {
4
+ meta : {
5
+ docs : {
6
+ description : "disallow explicit children snippet where it's not needed" ,
7
+ category : 'Best Practices' ,
8
+ recommended : false
9
+ } ,
10
+ schema : [ ] ,
11
+ messages : {
12
+ uselessSnippet : "Found an unnecessary children snippet."
13
+ } ,
14
+ type : 'suggestion'
15
+ } ,
16
+ create ( context ) {
17
+ return {
18
+ SvelteSnippetBlock ( node ) {
19
+ if ( node . id . name === "children" && node . params . length === 0 ) {
20
+ context . report ( { node, messageId : "uselessSnippet" } )
21
+ }
22
+ }
23
+ } ;
24
+ }
25
+ } ) ;
Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ import noTrailingSpaces from '../rules/no-trailing-spaces';
49
49
import noUnknownStyleDirectiveProperty from '../rules/no-unknown-style-directive-property' ;
50
50
import noUnusedClassName from '../rules/no-unused-class-name' ;
51
51
import noUnusedSvelteIgnore from '../rules/no-unused-svelte-ignore' ;
52
+ import noUselessChildrenSnippet from '../rules/no-useless-children-snippet' ;
52
53
import noUselessMustaches from '../rules/no-useless-mustaches' ;
53
54
import preferClassDirective from '../rules/prefer-class-directive' ;
54
55
import preferDestructuredStoreProps from '../rules/prefer-destructured-store-props' ;
@@ -116,6 +117,7 @@ export const rules = [
116
117
noUnknownStyleDirectiveProperty ,
117
118
noUnusedClassName ,
118
119
noUnusedSvelteIgnore ,
120
+ noUselessChildrenSnippet ,
119
121
noUselessMustaches ,
120
122
preferClassDirective ,
121
123
preferDestructuredStoreProps ,
You can’t perform that action at this time.
0 commit comments