forked from r5n-labs/vscode-react-javascript-snippets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpropTypes.ts
291 lines (257 loc) · 7.53 KB
/
propTypes.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
import { SnippetMapping } from '../types';
type PropTypesMapping = {
propTypeAny: 'ptany';
propTypeArray: 'pta';
propTypeArrayOf: 'ptao';
propTypeArrayOfRequired: 'ptaor';
propTypeArrayRequired: 'ptar';
propTypeBool: 'ptb';
propTypeBoolRequired: 'ptbr';
propTypeElement: 'ptel';
propTypeElementRequired: 'ptelr';
propTypeEnum: 'pte';
propTypeEnumRequired: 'pter';
propTypeExact: 'ptex';
propTypeExactRequired: 'ptexr';
propTypeFunc: 'ptf';
propTypeFuncRequired: 'ptfr';
propTypeInstanceOf: 'pti';
propTypeInstanceOfRequired: 'ptir';
propTypeNode: 'ptnd';
propTypeNodeRequired: 'ptndr';
propTypeNumber: 'ptn';
propTypeNumberRequired: 'ptnr';
propTypeObject: 'pto';
propTypeObjectOf: 'ptoo';
propTypeObjectOfRequired: 'ptoor';
propTypeObjectRequired: 'ptor';
propTypeOneOfType: 'ptet';
propTypeOneOfTypeRequired: 'ptetr';
propTypeShape: 'ptsh';
propTypeShapeRequired: 'ptshr';
propTypeString: 'pts';
propTypeStringRequired: 'ptsr';
};
export type PropTypesSnippet = SnippetMapping<PropTypesMapping>;
const propTypeArray: PropTypesSnippet = {
key: 'propTypeArray',
prefix: 'pta',
body: ['PropTypes.array'],
description: 'Array prop type',
};
const propTypeArrayRequired: PropTypesSnippet = {
key: 'propTypeArrayRequired',
prefix: 'ptar',
body: ['PropTypes.array.isRequired'],
description: 'Array prop type required',
};
const propTypeBool: PropTypesSnippet = {
key: 'propTypeBool',
prefix: 'ptb',
body: ['PropTypes.bool'],
description: 'Bool prop type',
};
const propTypeBoolRequired: PropTypesSnippet = {
key: 'propTypeBoolRequired',
prefix: 'ptbr',
body: ['PropTypes.bool.isRequired'],
description: 'Bool prop type required',
};
const propTypeFunc: PropTypesSnippet = {
key: 'propTypeFunc',
prefix: 'ptf',
body: ['PropTypes.func'],
description: 'Func prop type',
};
const propTypeFuncRequired: PropTypesSnippet = {
key: 'propTypeFuncRequired',
prefix: 'ptfr',
body: ['PropTypes.func.isRequired'],
description: 'Func prop type required',
};
const propTypeNumber: PropTypesSnippet = {
key: 'propTypeNumber',
prefix: 'ptn',
body: ['PropTypes.number'],
description: 'Number prop type',
};
const propTypeNumberRequired: PropTypesSnippet = {
key: 'propTypeNumberRequired',
prefix: 'ptnr',
body: ['PropTypes.number.isRequired'],
description: 'Number prop type required',
};
const propTypeObject: PropTypesSnippet = {
key: 'propTypeObject',
prefix: 'pto',
body: ['PropTypes.object'],
description: 'Object prop type',
};
const propTypeObjectRequired: PropTypesSnippet = {
key: 'propTypeObjectRequired',
prefix: 'ptor',
body: ['PropTypes.object.isRequired'],
description: 'Object prop type required',
};
const propTypeString: PropTypesSnippet = {
key: 'propTypeString',
prefix: 'pts',
body: ['PropTypes.string'],
description: 'String prop type',
};
const propTypeStringRequired: PropTypesSnippet = {
key: 'propTypeStringRequired',
prefix: 'ptsr',
body: ['PropTypes.string.isRequired'],
description: 'String prop type required',
};
const propTypeNode: PropTypesSnippet = {
key: 'propTypeNode',
prefix: 'ptnd',
body: ['PropTypes.node'],
description:
'Anything that can be rendered: numbers, strings, elements or an array',
};
const propTypeNodeRequired: PropTypesSnippet = {
key: 'propTypeNodeRequired',
prefix: 'ptndr',
body: ['PropTypes.node.isRequired'],
description:
'Anything that can be rendered: numbers, strings, elements or an array required',
};
const propTypeElement: PropTypesSnippet = {
key: 'propTypeElement',
prefix: 'ptel',
body: ['PropTypes.element'],
description: 'React element prop type',
};
const propTypeElementRequired: PropTypesSnippet = {
key: 'propTypeElementRequired',
prefix: 'ptelr',
body: ['PropTypes.element.isRequired'],
description: 'React element prop type required',
};
const propTypeInstanceOf: PropTypesSnippet = {
key: 'propTypeInstanceOf',
prefix: 'pti',
body: ['PropTypes.instanceOf($0)'],
description: 'Is an instance of a class prop type',
};
const propTypeInstanceOfRequired: PropTypesSnippet = {
key: 'propTypeInstanceOfRequired',
prefix: 'ptir',
body: ['PropTypes.instanceOf($0).isRequired'],
description: 'Is an instance of a class prop type required',
};
const propTypeEnum: PropTypesSnippet = {
key: 'propTypeEnum',
prefix: 'pte',
body: ["PropTypes.oneOf(['$0'])"],
description: 'Prop type limited to specific values by treating it as an enum',
};
const propTypeEnumRequired: PropTypesSnippet = {
key: 'propTypeEnumRequired',
prefix: 'pter',
body: ["PropTypes.oneOf(['$0']).isRequired"],
description:
'Prop type limited to specific values by treating it as an enum required',
};
const propTypeOneOfType: PropTypesSnippet = {
key: 'propTypeOneOfType',
prefix: 'ptet',
body: ['PropTypes.oneOfType([', ' $0', '])'],
description: 'An object that could be one of many types',
};
const propTypeOneOfTypeRequired: PropTypesSnippet = {
key: 'propTypeOneOfTypeRequired',
prefix: 'ptetr',
body: ['PropTypes.oneOfType([', ' $0', ']).isRequired'],
description: 'An object that could be one of many types required',
};
const propTypeArrayOf: PropTypesSnippet = {
key: 'propTypeArrayOf',
prefix: 'ptao',
body: ['PropTypes.arrayOf($0)'],
description: 'An array of a certain type',
};
const propTypeArrayOfRequired: PropTypesSnippet = {
key: 'propTypeArrayOfRequired',
prefix: 'ptaor',
body: ['PropTypes.arrayOf($0).isRequired'],
description: 'An array of a certain type required',
};
const propTypeObjectOf: PropTypesSnippet = {
key: 'propTypeObjectOf',
prefix: 'ptoo',
body: ['PropTypes.objectOf($0)'],
description: 'An object with property values of a certain type',
};
const propTypeObjectOfRequired: PropTypesSnippet = {
key: 'propTypeObjectOfRequired',
prefix: 'ptoor',
body: ['PropTypes.objectOf($0).isRequired'],
description: 'An object with property values of a certain type required',
};
const propTypeShape: PropTypesSnippet = {
key: 'propTypeShape',
prefix: 'ptsh',
body: ['PropTypes.shape({', ' $0', '})'],
description: 'An object taking on a particular shape',
};
const propTypeShapeRequired: PropTypesSnippet = {
key: 'propTypeShapeRequired',
prefix: 'ptshr',
body: ['PropTypes.shape({', ' $0', '}).isRequired'],
description: 'An object taking on a particular shape required',
};
const propTypeExact: PropTypesSnippet = {
key: 'propTypeExact',
prefix: 'ptex',
body: ['PropTypes.exact({', ' $0', '})'],
description: 'An object with warnings on extra properties',
};
const propTypeExactRequired: PropTypesSnippet = {
key: 'propTypeExactRequired',
prefix: 'ptexr',
body: ['PropTypes.exact({', ' $0', '}).isRequired'],
description: 'An object with warnings on extra properties required',
};
const propTypeAny: PropTypesSnippet = {
key: 'propTypeAny',
prefix: 'ptany',
body: ['PropTypes.any'],
description: 'Any prop type',
};
export default [
propTypeArray,
propTypeArrayRequired,
propTypeBool,
propTypeBoolRequired,
propTypeFunc,
propTypeFuncRequired,
propTypeNumber,
propTypeNumberRequired,
propTypeObject,
propTypeObjectRequired,
propTypeString,
propTypeStringRequired,
propTypeNode,
propTypeNodeRequired,
propTypeElement,
propTypeElementRequired,
propTypeInstanceOf,
propTypeInstanceOfRequired,
propTypeEnum,
propTypeEnumRequired,
propTypeOneOfType,
propTypeOneOfTypeRequired,
propTypeArrayOf,
propTypeArrayOfRequired,
propTypeObjectOf,
propTypeObjectOfRequired,
propTypeShape,
propTypeShapeRequired,
propTypeExact,
propTypeExactRequired,
propTypeAny,
];