File tree 2 files changed +10
-50
lines changed
2 files changed +10
-50
lines changed Original file line number Diff line number Diff line change @@ -13,60 +13,20 @@ description: enforce user to add type declaration to object props
13
13
14
14
## :book : Rule Details
15
15
16
- Prevent missing type declaration of not primitive objects in a TypeScript projects.
17
-
18
- Bad:
19
-
20
- <eslint-code-block :rules =" {'vue/force-types-on-object-props': ['error']} " >
21
-
22
- ``` js
23
- export default {
24
- props: {
25
- prop: {
26
- type: Object ,
27
- },
28
- },
29
- }
30
- ```
31
-
32
- </eslint-code-block >
33
-
34
- <eslint-code-block :rules =" {'vue/force-types-on-object-props': ['error']} " >
35
-
36
- ``` ts
37
- export default {
38
- props: {
39
- prop: {
40
- type: Array
41
- }
42
- }
43
- }
44
- ```
45
-
46
- </eslint-code-block >
47
-
48
- Good:
16
+ Prevent missing type declarations for non-primitive object props in TypeScript projects.
49
17
50
18
<eslint-code-block :rules =" {'vue/force-types-on-object-props': ['error']} " >
51
19
52
20
``` ts
53
21
export default {
54
22
props: {
55
23
prop: {
24
+ // ✗ BAD
25
+ type: Object ,
26
+ type: Array ,
27
+
28
+ // ✓ GOOD
56
29
type: Object as Props <Anything >,
57
- }
58
- }
59
- }
60
- ```
61
-
62
- </eslint-code-block >
63
-
64
- <eslint-code-block :rules =" {'vue/force-types-on-object-props': ['error']} " >
65
-
66
- ``` ts
67
- export default {
68
- props: {
69
- prop: {
70
30
type: String , // or any other primitive type
71
31
}
72
32
}
@@ -81,7 +41,7 @@ Nothing.
81
41
82
42
## :mute : When Not To Use It
83
43
84
- When you're not using TypeScript in the project**** .
44
+ When you're not using TypeScript in the project.
85
45
86
46
## :books : Further Reading
87
47
Original file line number Diff line number Diff line change @@ -37,8 +37,8 @@ module.exports = {
37
37
meta : {
38
38
type : 'suggestion' ,
39
39
docs : {
40
- description : 'enforce user to add type declaration to object props' ,
41
- categories : [ 'base ' ] ,
40
+ description : 'enforce adding type declarations to object props' ,
41
+ categories : [ 'suggestion ' ] ,
42
42
recommended : false ,
43
43
url : 'https://eslint.vuejs.org/rules/force-types-on-object-props.html'
44
44
} ,
@@ -108,7 +108,7 @@ module.exports = {
108
108
) {
109
109
context . report ( {
110
110
node : prop ,
111
- message : 'Object props has to contains type .'
111
+ message : 'Expected type annotation on object prop .'
112
112
} )
113
113
}
114
114
}
You can’t perform that action at this time.
0 commit comments