1
- # enforce valid ` slot-scope ` attributes (vue/valid-slot-scope)
1
+ ---
2
+ pageClass : rule-details
3
+ sidebarDepth : 0
4
+ title : vue/valid-slot-scope
5
+ description : enforce valid `slot-scope` attributes
6
+ ---
7
+ # vue/valid-slot-scope
8
+ > enforce valid ` slot-scope ` attributes
2
9
3
10
This rule checks whether every ` slot-scope ` (or ` scope ` ) attributes is valid.
4
11
@@ -8,46 +15,44 @@ This rule reports `slot-scope` attributes in the following cases:
8
15
9
16
- The ` slot-scope ` attribute does not have that attribute value. E.g. ` <div slot-scope></div> `
10
17
11
- This rule does not check syntax errors in directives because it's checked by [ no-parsing-error] rule.
12
-
13
- :-1 : Examples of ** incorrect** code for this rule:
14
-
18
+ <eslint-code-block :rules =" {'vue/valid-slot-scope': ['error']} " >
15
19
``` vue
16
20
<template>
21
+ <!-- ✓ GOOD -->
17
22
<TheComponent>
18
- <template slot-scope>
23
+ <template slot-scope="prop" >
19
24
...
20
25
</template>
21
26
</TheComponent>
22
27
<TheComponent>
23
- <template slot-scope="">
28
+ <template slot-scope="{ a, b, c } ">
24
29
...
25
30
</template>
26
31
</TheComponent>
27
- </template>
28
- ```
29
-
30
- :+1 : Examples of ** correct** code for this rule:
31
-
32
- ``` vue
33
- <template>
34
32
<TheComponent>
35
- <template slot-scope="prop ">
33
+ <template slot-scope="[ a, b, c ] ">
36
34
...
37
35
</template>
38
36
</TheComponent>
37
+
38
+ <!-- ✗ BAD -->
39
39
<TheComponent>
40
- <template slot-scope="{ a, b, c }" >
40
+ <template slot-scope>
41
41
...
42
42
</template>
43
43
</TheComponent>
44
44
<TheComponent>
45
- <template slot-scope="[ a, b, c ] ">
45
+ <template slot-scope="">
46
46
...
47
47
</template>
48
48
</TheComponent>
49
49
</template>
50
50
```
51
+ </eslint-code-block >
52
+
53
+ ::: warning Note
54
+ This rule does not check syntax errors in directives because it's checked by [ no-parsing-error] rule.
55
+ :::
51
56
52
57
## :wrench : Options
53
58
@@ -57,8 +62,13 @@ Nothing.
57
62
58
63
- [ no-parsing-error]
59
64
60
- ## Related links
65
+ ## : books : Further reading
61
66
62
67
- [ Guide - Scoped Slots] ( https://vuejs.org/v2/guide/components-slots.html#Scoped-Slots )
63
68
64
69
[ no-parsing-error ] : no-parsing-error.md
70
+
71
+ ## :mag : Implementation
72
+
73
+ - [ Rule source] ( https://github.com/vuejs/eslint-plugin-vue/blob/master/lib/rules/valid-slot-scope.js )
74
+ - [ Test source] ( https://github.com/vuejs/eslint-plugin-vue/blob/master/tests/lib/rules/valid-slot-scope.js )
0 commit comments