@eslint-react/shared 1.23.2-next.3 → 1.23.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +1808 -172
- package/dist/index.d.ts +1808 -172
- package/dist/index.js +1023 -73
- package/dist/index.mjs +967 -22
- package/package.json +6 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,60 +1,1346 @@
|
|
|
1
1
|
import { ESLintUtils } from '@typescript-eslint/utils';
|
|
2
2
|
import { E } from '@eslint-react/eff';
|
|
3
|
-
import * as valibot from 'valibot';
|
|
4
|
-
import { InferOutput } from 'valibot';
|
|
5
3
|
|
|
6
4
|
/**
|
|
7
|
-
*
|
|
5
|
+
* Schema with pipe type.
|
|
6
|
+
*/
|
|
7
|
+
type SchemaWithPipe<TPipe extends [
|
|
8
|
+
BaseSchema<unknown, unknown, BaseIssue<unknown>>,
|
|
9
|
+
...PipeItem<any, unknown, BaseIssue<unknown>>[]
|
|
10
|
+
]> = Omit<FirstTupleItem<TPipe>, '~standard' | '~run' | '~types'> & {
|
|
11
|
+
/**
|
|
12
|
+
* The pipe items.
|
|
13
|
+
*/
|
|
14
|
+
readonly pipe: TPipe;
|
|
15
|
+
/**
|
|
16
|
+
* The Standard Schema properties.
|
|
17
|
+
*
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
readonly '~standard': StandardSchemaProps<InferInput<FirstTupleItem<TPipe>>, InferOutput<LastTupleItem<TPipe>>>;
|
|
21
|
+
/**
|
|
22
|
+
* Parses unknown input values.
|
|
23
|
+
*
|
|
24
|
+
* @param dataset The input dataset.
|
|
25
|
+
* @param config The configuration.
|
|
26
|
+
*
|
|
27
|
+
* @returns The output dataset.
|
|
28
|
+
*
|
|
29
|
+
* @internal
|
|
30
|
+
*/
|
|
31
|
+
readonly '~run': (dataset: UnknownDataset, config: Config<BaseIssue<unknown>>) => OutputDataset<InferOutput<LastTupleItem<TPipe>>, InferIssue<TPipe[number]>>;
|
|
32
|
+
/**
|
|
33
|
+
* The input, output and issue type.
|
|
34
|
+
*
|
|
35
|
+
* @internal
|
|
36
|
+
*/
|
|
37
|
+
readonly '~types'?: {
|
|
38
|
+
readonly input: InferInput<FirstTupleItem<TPipe>>;
|
|
39
|
+
readonly output: InferOutput<LastTupleItem<TPipe>>;
|
|
40
|
+
readonly issue: InferIssue<TPipe[number]>;
|
|
41
|
+
} | undefined;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Schema with pipe async type.
|
|
46
|
+
*/
|
|
47
|
+
type SchemaWithPipeAsync<TPipe extends [
|
|
48
|
+
(BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>),
|
|
49
|
+
...(PipeItem<any, unknown, BaseIssue<unknown>> | PipeItemAsync<any, unknown, BaseIssue<unknown>>)[]
|
|
50
|
+
]> = Omit<FirstTupleItem<TPipe>, 'async' | '~standard' | '~run' | '~types'> & {
|
|
51
|
+
/**
|
|
52
|
+
* The pipe items.
|
|
53
|
+
*/
|
|
54
|
+
readonly pipe: TPipe;
|
|
55
|
+
/**
|
|
56
|
+
* Whether it's async.
|
|
57
|
+
*/
|
|
58
|
+
readonly async: true;
|
|
59
|
+
/**
|
|
60
|
+
* The Standard Schema properties.
|
|
61
|
+
*
|
|
62
|
+
* @internal
|
|
63
|
+
*/
|
|
64
|
+
readonly '~standard': StandardSchemaProps<InferInput<FirstTupleItem<TPipe>>, InferOutput<LastTupleItem<TPipe>>>;
|
|
65
|
+
/**
|
|
66
|
+
* Parses unknown input values.
|
|
67
|
+
*
|
|
68
|
+
* @param dataset The input dataset.
|
|
69
|
+
* @param config The configuration.
|
|
70
|
+
*
|
|
71
|
+
* @returns The output dataset.
|
|
72
|
+
*
|
|
73
|
+
* @internal
|
|
74
|
+
*/
|
|
75
|
+
readonly '~run': (dataset: UnknownDataset, config: Config<BaseIssue<unknown>>) => Promise<OutputDataset<InferOutput<LastTupleItem<TPipe>>, InferIssue<TPipe[number]>>>;
|
|
76
|
+
/**
|
|
77
|
+
* The input, output and issue type.
|
|
78
|
+
*
|
|
79
|
+
* @internal
|
|
80
|
+
*/
|
|
81
|
+
readonly '~types'?: {
|
|
82
|
+
readonly input: InferInput<FirstTupleItem<TPipe>>;
|
|
83
|
+
readonly output: InferOutput<LastTupleItem<TPipe>>;
|
|
84
|
+
readonly issue: InferIssue<TPipe[number]>;
|
|
85
|
+
} | undefined;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Base metadata type.
|
|
90
|
+
*/
|
|
91
|
+
interface BaseMetadata<TInput> {
|
|
92
|
+
/**
|
|
93
|
+
* The object kind.
|
|
94
|
+
*/
|
|
95
|
+
readonly kind: 'metadata';
|
|
96
|
+
/**
|
|
97
|
+
* The metadata type.
|
|
98
|
+
*/
|
|
99
|
+
readonly type: string;
|
|
100
|
+
/**
|
|
101
|
+
* The metadata reference.
|
|
102
|
+
*/
|
|
103
|
+
readonly reference: (...args: any[]) => BaseMetadata<any>;
|
|
104
|
+
/**
|
|
105
|
+
* The input, output and issue type.
|
|
106
|
+
*
|
|
107
|
+
* @internal
|
|
108
|
+
*/
|
|
109
|
+
readonly '~types'?: {
|
|
110
|
+
readonly input: TInput;
|
|
111
|
+
readonly output: TInput;
|
|
112
|
+
readonly issue: never;
|
|
113
|
+
} | undefined;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Unknown dataset type.
|
|
118
|
+
*/
|
|
119
|
+
interface UnknownDataset {
|
|
120
|
+
/**
|
|
121
|
+
* Whether is's typed.
|
|
122
|
+
*/
|
|
123
|
+
typed?: false;
|
|
124
|
+
/**
|
|
125
|
+
* The dataset value.
|
|
126
|
+
*/
|
|
127
|
+
value: unknown;
|
|
128
|
+
/**
|
|
129
|
+
* The dataset issues.
|
|
130
|
+
*/
|
|
131
|
+
issues?: undefined;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Success dataset type.
|
|
135
|
+
*/
|
|
136
|
+
interface SuccessDataset<TValue> {
|
|
137
|
+
/**
|
|
138
|
+
* Whether is's typed.
|
|
139
|
+
*/
|
|
140
|
+
typed: true;
|
|
141
|
+
/**
|
|
142
|
+
* The dataset value.
|
|
143
|
+
*/
|
|
144
|
+
value: TValue;
|
|
145
|
+
/**
|
|
146
|
+
* The dataset issues.
|
|
147
|
+
*/
|
|
148
|
+
issues?: undefined;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Partial dataset type.
|
|
152
|
+
*/
|
|
153
|
+
interface PartialDataset<TValue, TIssue extends BaseIssue<unknown>> {
|
|
154
|
+
/**
|
|
155
|
+
* Whether is's typed.
|
|
156
|
+
*/
|
|
157
|
+
typed: true;
|
|
158
|
+
/**
|
|
159
|
+
* The dataset value.
|
|
160
|
+
*/
|
|
161
|
+
value: TValue;
|
|
162
|
+
/**
|
|
163
|
+
* The dataset issues.
|
|
164
|
+
*/
|
|
165
|
+
issues: [TIssue, ...TIssue[]];
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Failure dataset type.
|
|
169
|
+
*/
|
|
170
|
+
interface FailureDataset<TIssue extends BaseIssue<unknown>> {
|
|
171
|
+
/**
|
|
172
|
+
* Whether is's typed.
|
|
173
|
+
*/
|
|
174
|
+
typed: false;
|
|
175
|
+
/**
|
|
176
|
+
* The dataset value.
|
|
177
|
+
*/
|
|
178
|
+
value: unknown;
|
|
179
|
+
/**
|
|
180
|
+
* The dataset issues.
|
|
181
|
+
*/
|
|
182
|
+
issues: [TIssue, ...TIssue[]];
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Output dataset type.
|
|
186
|
+
*/
|
|
187
|
+
type OutputDataset<TValue, TIssue extends BaseIssue<unknown>> = SuccessDataset<TValue> | PartialDataset<TValue, TIssue> | FailureDataset<TIssue>;
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* The Standard Schema properties interface.
|
|
191
|
+
*/
|
|
192
|
+
interface StandardSchemaProps<Input, Output> {
|
|
193
|
+
/**
|
|
194
|
+
* The version number of the standard.
|
|
195
|
+
*/
|
|
196
|
+
readonly version: 1;
|
|
197
|
+
/**
|
|
198
|
+
* The vendor name of the schema library.
|
|
199
|
+
*/
|
|
200
|
+
readonly vendor: 'valibot';
|
|
201
|
+
/**
|
|
202
|
+
* Validates unknown input values.
|
|
203
|
+
*/
|
|
204
|
+
readonly validate: (value: unknown) => StandardResult<Output> | Promise<StandardResult<Output>>;
|
|
205
|
+
/**
|
|
206
|
+
* Inferred types associated with the schema.
|
|
207
|
+
*/
|
|
208
|
+
readonly types?: StandardTypes<Input, Output> | undefined;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* The result interface of the validate function.
|
|
212
|
+
*/
|
|
213
|
+
type StandardResult<Output> = StandardSuccessResult<Output> | StandardFailureResult;
|
|
214
|
+
/**
|
|
215
|
+
* The result interface if validation succeeds.
|
|
216
|
+
*/
|
|
217
|
+
interface StandardSuccessResult<Output> {
|
|
218
|
+
/**
|
|
219
|
+
* The typed output value.
|
|
220
|
+
*/
|
|
221
|
+
readonly value: Output;
|
|
222
|
+
/**
|
|
223
|
+
* The non-existent issues.
|
|
224
|
+
*/
|
|
225
|
+
readonly issues?: undefined;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* The result interface if validation fails.
|
|
229
|
+
*/
|
|
230
|
+
interface StandardFailureResult {
|
|
231
|
+
/**
|
|
232
|
+
* The issues of failed validation.
|
|
233
|
+
*/
|
|
234
|
+
readonly issues: readonly StandardIssue[];
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* The issue interface of the failure output.
|
|
238
|
+
*/
|
|
239
|
+
interface StandardIssue {
|
|
240
|
+
/**
|
|
241
|
+
* The error message of the issue.
|
|
242
|
+
*/
|
|
243
|
+
readonly message: string;
|
|
244
|
+
/**
|
|
245
|
+
* The path of the issue, if any.
|
|
246
|
+
*/
|
|
247
|
+
readonly path?: readonly (PropertyKey | StandardPathSegment)[] | undefined;
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* The path segment interface of the issue.
|
|
251
|
+
*/
|
|
252
|
+
interface StandardPathSegment {
|
|
253
|
+
/**
|
|
254
|
+
* The key representing a path segment.
|
|
255
|
+
*/
|
|
256
|
+
readonly key: PropertyKey;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* The base types interface of Standard Schema.
|
|
260
|
+
*/
|
|
261
|
+
interface StandardTypes<Input, Output> {
|
|
262
|
+
/**
|
|
263
|
+
* The input type of the schema.
|
|
264
|
+
*/
|
|
265
|
+
readonly input: Input;
|
|
266
|
+
/**
|
|
267
|
+
* The output type of the schema.
|
|
268
|
+
*/
|
|
269
|
+
readonly output: Output;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* Base schema type.
|
|
274
|
+
*/
|
|
275
|
+
interface BaseSchema<TInput, TOutput, TIssue extends BaseIssue<unknown>> {
|
|
276
|
+
/**
|
|
277
|
+
* The object kind.
|
|
278
|
+
*/
|
|
279
|
+
readonly kind: 'schema';
|
|
280
|
+
/**
|
|
281
|
+
* The schema type.
|
|
282
|
+
*/
|
|
283
|
+
readonly type: string;
|
|
284
|
+
/**
|
|
285
|
+
* The schema reference.
|
|
286
|
+
*/
|
|
287
|
+
readonly reference: (...args: any[]) => BaseSchema<unknown, unknown, BaseIssue<unknown>>;
|
|
288
|
+
/**
|
|
289
|
+
* The expected property.
|
|
290
|
+
*/
|
|
291
|
+
readonly expects: string;
|
|
292
|
+
/**
|
|
293
|
+
* Whether it's async.
|
|
294
|
+
*/
|
|
295
|
+
readonly async: false;
|
|
296
|
+
/**
|
|
297
|
+
* The Standard Schema properties.
|
|
298
|
+
*
|
|
299
|
+
* @internal
|
|
300
|
+
*/
|
|
301
|
+
readonly '~standard': StandardSchemaProps<TInput, TOutput>;
|
|
302
|
+
/**
|
|
303
|
+
* Parses unknown input values.
|
|
304
|
+
*
|
|
305
|
+
* @param dataset The input dataset.
|
|
306
|
+
* @param config The configuration.
|
|
307
|
+
*
|
|
308
|
+
* @returns The output dataset.
|
|
309
|
+
*
|
|
310
|
+
* @internal
|
|
311
|
+
*/
|
|
312
|
+
readonly '~run': (dataset: UnknownDataset, config: Config<BaseIssue<unknown>>) => OutputDataset<TOutput, TIssue>;
|
|
313
|
+
/**
|
|
314
|
+
* The input, output and issue type.
|
|
315
|
+
*
|
|
316
|
+
* @internal
|
|
317
|
+
*/
|
|
318
|
+
readonly '~types'?: {
|
|
319
|
+
readonly input: TInput;
|
|
320
|
+
readonly output: TOutput;
|
|
321
|
+
readonly issue: TIssue;
|
|
322
|
+
} | undefined;
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Base schema async type.
|
|
326
|
+
*/
|
|
327
|
+
interface BaseSchemaAsync<TInput, TOutput, TIssue extends BaseIssue<unknown>> extends Omit<BaseSchema<TInput, TOutput, TIssue>, 'reference' | 'async' | '~run'> {
|
|
328
|
+
/**
|
|
329
|
+
* The schema reference.
|
|
330
|
+
*/
|
|
331
|
+
readonly reference: (...args: any[]) => BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>;
|
|
332
|
+
/**
|
|
333
|
+
* Whether it's async.
|
|
334
|
+
*/
|
|
335
|
+
readonly async: true;
|
|
336
|
+
/**
|
|
337
|
+
* Parses unknown input values.
|
|
338
|
+
*
|
|
339
|
+
* @param dataset The input dataset.
|
|
340
|
+
* @param config The configuration.
|
|
341
|
+
*
|
|
342
|
+
* @returns The output dataset.
|
|
343
|
+
*
|
|
344
|
+
* @internal
|
|
345
|
+
*/
|
|
346
|
+
readonly '~run': (dataset: UnknownDataset, config: Config<BaseIssue<unknown>>) => Promise<OutputDataset<TOutput, TIssue>>;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* Base transformation type.
|
|
351
|
+
*/
|
|
352
|
+
interface BaseTransformation<TInput, TOutput, TIssue extends BaseIssue<unknown>> {
|
|
353
|
+
/**
|
|
354
|
+
* The object kind.
|
|
355
|
+
*/
|
|
356
|
+
readonly kind: 'transformation';
|
|
357
|
+
/**
|
|
358
|
+
* The transformation type.
|
|
359
|
+
*/
|
|
360
|
+
readonly type: string;
|
|
361
|
+
/**
|
|
362
|
+
* The transformation reference.
|
|
363
|
+
*/
|
|
364
|
+
readonly reference: (...args: any[]) => BaseTransformation<any, any, BaseIssue<unknown>>;
|
|
365
|
+
/**
|
|
366
|
+
* Whether it's async.
|
|
367
|
+
*/
|
|
368
|
+
readonly async: false;
|
|
369
|
+
/**
|
|
370
|
+
* Transforms known input values.
|
|
371
|
+
*
|
|
372
|
+
* @param dataset The input dataset.
|
|
373
|
+
* @param config The configuration.
|
|
374
|
+
*
|
|
375
|
+
* @returns The output dataset.
|
|
376
|
+
*
|
|
377
|
+
* @internal
|
|
378
|
+
*/
|
|
379
|
+
readonly '~run': (dataset: SuccessDataset<TInput>, config: Config<BaseIssue<unknown>>) => OutputDataset<TOutput, BaseIssue<unknown> | TIssue>;
|
|
380
|
+
/**
|
|
381
|
+
* The input, output and issue type.
|
|
382
|
+
*
|
|
383
|
+
* @internal
|
|
384
|
+
*/
|
|
385
|
+
readonly '~types'?: {
|
|
386
|
+
readonly input: TInput;
|
|
387
|
+
readonly output: TOutput;
|
|
388
|
+
readonly issue: TIssue;
|
|
389
|
+
} | undefined;
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* Base transformation async type.
|
|
393
|
+
*/
|
|
394
|
+
interface BaseTransformationAsync<TInput, TOutput, TIssue extends BaseIssue<unknown>> extends Omit<BaseTransformation<TInput, TOutput, TIssue>, 'reference' | 'async' | '~run'> {
|
|
395
|
+
/**
|
|
396
|
+
* The transformation reference.
|
|
397
|
+
*/
|
|
398
|
+
readonly reference: (...args: any[]) => BaseTransformation<any, any, BaseIssue<unknown>> | BaseTransformationAsync<any, any, BaseIssue<unknown>>;
|
|
399
|
+
/**
|
|
400
|
+
* Whether it's async.
|
|
401
|
+
*/
|
|
402
|
+
readonly async: true;
|
|
403
|
+
/**
|
|
404
|
+
* Transforms known input values.
|
|
405
|
+
*
|
|
406
|
+
* @param dataset The input dataset.
|
|
407
|
+
* @param config The configuration.
|
|
408
|
+
*
|
|
409
|
+
* @returns The output dataset.
|
|
410
|
+
*
|
|
411
|
+
* @internal
|
|
412
|
+
*/
|
|
413
|
+
readonly '~run': (dataset: SuccessDataset<TInput>, config: Config<BaseIssue<unknown>>) => Promise<OutputDataset<TOutput, BaseIssue<unknown> | TIssue>>;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* Base validation type.
|
|
418
|
+
*/
|
|
419
|
+
interface BaseValidation<TInput, TOutput, TIssue extends BaseIssue<unknown>> {
|
|
420
|
+
/**
|
|
421
|
+
* The object kind.
|
|
422
|
+
*/
|
|
423
|
+
readonly kind: 'validation';
|
|
424
|
+
/**
|
|
425
|
+
* The validation type.
|
|
426
|
+
*/
|
|
427
|
+
readonly type: string;
|
|
428
|
+
/**
|
|
429
|
+
* The validation reference.
|
|
430
|
+
*/
|
|
431
|
+
readonly reference: (...args: any[]) => BaseValidation<any, any, BaseIssue<unknown>>;
|
|
432
|
+
/**
|
|
433
|
+
* The expected property.
|
|
434
|
+
*/
|
|
435
|
+
readonly expects: string | null;
|
|
436
|
+
/**
|
|
437
|
+
* Whether it's async.
|
|
438
|
+
*/
|
|
439
|
+
readonly async: false;
|
|
440
|
+
/**
|
|
441
|
+
* Validates known input values.
|
|
442
|
+
*
|
|
443
|
+
* @param dataset The input dataset.
|
|
444
|
+
* @param config The configuration.
|
|
445
|
+
*
|
|
446
|
+
* @returns The output dataset.
|
|
447
|
+
*
|
|
448
|
+
* @internal
|
|
449
|
+
*/
|
|
450
|
+
readonly '~run': (dataset: OutputDataset<TInput, BaseIssue<unknown>>, config: Config<BaseIssue<unknown>>) => OutputDataset<TOutput, BaseIssue<unknown> | TIssue>;
|
|
451
|
+
/**
|
|
452
|
+
* The input, output and issue type.
|
|
453
|
+
*
|
|
454
|
+
* @internal
|
|
455
|
+
*/
|
|
456
|
+
readonly '~types'?: {
|
|
457
|
+
readonly input: TInput;
|
|
458
|
+
readonly output: TOutput;
|
|
459
|
+
readonly issue: TIssue;
|
|
460
|
+
} | undefined;
|
|
461
|
+
}
|
|
462
|
+
/**
|
|
463
|
+
* Base validation async type.
|
|
464
|
+
*/
|
|
465
|
+
interface BaseValidationAsync<TInput, TOutput, TIssue extends BaseIssue<unknown>> extends Omit<BaseValidation<TInput, TOutput, TIssue>, 'reference' | 'async' | '~run'> {
|
|
466
|
+
/**
|
|
467
|
+
* The validation reference.
|
|
468
|
+
*/
|
|
469
|
+
readonly reference: (...args: any[]) => BaseValidation<any, any, BaseIssue<unknown>> | BaseValidationAsync<any, any, BaseIssue<unknown>>;
|
|
470
|
+
/**
|
|
471
|
+
* Whether it's async.
|
|
472
|
+
*/
|
|
473
|
+
readonly async: true;
|
|
474
|
+
/**
|
|
475
|
+
* Validates known input values.
|
|
476
|
+
*
|
|
477
|
+
* @param dataset The input dataset.
|
|
478
|
+
* @param config The configuration.
|
|
479
|
+
*
|
|
480
|
+
* @returns The output dataset.
|
|
481
|
+
*
|
|
482
|
+
* @internal
|
|
483
|
+
*/
|
|
484
|
+
readonly '~run': (dataset: OutputDataset<TInput, BaseIssue<unknown>>, config: Config<BaseIssue<unknown>>) => Promise<OutputDataset<TOutput, BaseIssue<unknown> | TIssue>>;
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
/**
|
|
488
|
+
* Infer input type.
|
|
489
|
+
*/
|
|
490
|
+
type InferInput<TItem extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>> | BaseValidation<any, unknown, BaseIssue<unknown>> | BaseValidationAsync<any, unknown, BaseIssue<unknown>> | BaseTransformation<any, unknown, BaseIssue<unknown>> | BaseTransformationAsync<any, unknown, BaseIssue<unknown>> | BaseMetadata<any>> = NonNullable<TItem['~types']>['input'];
|
|
491
|
+
/**
|
|
492
|
+
* Infer output type.
|
|
493
|
+
*/
|
|
494
|
+
type InferOutput<TItem extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>> | BaseValidation<any, unknown, BaseIssue<unknown>> | BaseValidationAsync<any, unknown, BaseIssue<unknown>> | BaseTransformation<any, unknown, BaseIssue<unknown>> | BaseTransformationAsync<any, unknown, BaseIssue<unknown>> | BaseMetadata<any>> = NonNullable<TItem['~types']>['output'];
|
|
495
|
+
/**
|
|
496
|
+
* Infer issue type.
|
|
497
|
+
*/
|
|
498
|
+
type InferIssue<TItem extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>> | BaseValidation<any, unknown, BaseIssue<unknown>> | BaseValidationAsync<any, unknown, BaseIssue<unknown>> | BaseTransformation<any, unknown, BaseIssue<unknown>> | BaseTransformationAsync<any, unknown, BaseIssue<unknown>> | BaseMetadata<any>> = NonNullable<TItem['~types']>['issue'];
|
|
499
|
+
/**
|
|
500
|
+
* Constructs a type that is maybe readonly.
|
|
501
|
+
*/
|
|
502
|
+
type MaybeReadonly<TValue> = TValue | Readonly<TValue>;
|
|
503
|
+
/**
|
|
504
|
+
* Constructs a type that is maybe a promise.
|
|
505
|
+
*/
|
|
506
|
+
type MaybePromise<TValue> = TValue | Promise<TValue>;
|
|
507
|
+
/**
|
|
508
|
+
* Prettifies a type for better readability.
|
|
509
|
+
*
|
|
510
|
+
* Hint: This type has no effect and is only used so that TypeScript displays
|
|
511
|
+
* the final type in the preview instead of the utility types used.
|
|
512
|
+
*/
|
|
513
|
+
type Prettify<TObject> = {
|
|
514
|
+
[TKey in keyof TObject]: TObject[TKey];
|
|
515
|
+
} & {};
|
|
516
|
+
/**
|
|
517
|
+
* Marks specific keys as optional.
|
|
518
|
+
*/
|
|
519
|
+
type MarkOptional<TObject, TKeys extends keyof TObject> = Omit<TObject, TKeys> & Partial<Pick<TObject, TKeys>>;
|
|
520
|
+
/**
|
|
521
|
+
* Extracts first tuple item.
|
|
522
|
+
*/
|
|
523
|
+
type FirstTupleItem<TTuple extends [unknown, ...unknown[]]> = TTuple[0];
|
|
524
|
+
/**
|
|
525
|
+
* Extracts last tuple item.
|
|
526
|
+
*/
|
|
527
|
+
type LastTupleItem<TTuple extends [unknown, ...unknown[]]> = TTuple[TTuple extends [unknown, ...infer TRest] ? TRest['length'] : never];
|
|
528
|
+
|
|
529
|
+
/**
|
|
530
|
+
* Error message type.
|
|
531
|
+
*/
|
|
532
|
+
type ErrorMessage<TIssue extends BaseIssue<unknown>> = ((issue: TIssue) => string) | string;
|
|
533
|
+
/**
|
|
534
|
+
* Default type.
|
|
535
|
+
*/
|
|
536
|
+
type Default<TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>>, TInput extends null | undefined> = MaybeReadonly<InferInput<TWrapped> | TInput> | ((dataset?: UnknownDataset, config?: Config<InferIssue<TWrapped>>) => MaybeReadonly<InferInput<TWrapped> | TInput>) | undefined;
|
|
537
|
+
/**
|
|
538
|
+
* Default async type.
|
|
539
|
+
*/
|
|
540
|
+
type DefaultAsync<TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, TInput extends null | undefined> = MaybeReadonly<InferInput<TWrapped> | TInput> | ((dataset?: UnknownDataset, config?: Config<InferIssue<TWrapped>>) => MaybePromise<MaybeReadonly<InferInput<TWrapped> | TInput>>) | undefined;
|
|
541
|
+
/**
|
|
542
|
+
* Default value type.
|
|
543
|
+
*/
|
|
544
|
+
type DefaultValue<TDefault extends Default<BaseSchema<unknown, unknown, BaseIssue<unknown>>, null | undefined> | DefaultAsync<BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, null | undefined>> = TDefault extends DefaultAsync<infer TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, infer TInput> ? TDefault extends (dataset?: UnknownDataset, config?: Config<InferIssue<TWrapped>>) => MaybePromise<InferInput<TWrapped> | TInput> ? Awaited<ReturnType<TDefault>> : TDefault : never;
|
|
545
|
+
|
|
546
|
+
/**
|
|
547
|
+
* Pipe action type.
|
|
548
|
+
*/
|
|
549
|
+
type PipeAction<TInput, TOutput, TIssue extends BaseIssue<unknown>> = BaseValidation<TInput, TOutput, TIssue> | BaseTransformation<TInput, TOutput, TIssue> | BaseMetadata<TInput>;
|
|
550
|
+
/**
|
|
551
|
+
* Pipe action async type.
|
|
552
|
+
*/
|
|
553
|
+
type PipeActionAsync<TInput, TOutput, TIssue extends BaseIssue<unknown>> = BaseValidationAsync<TInput, TOutput, TIssue> | BaseTransformationAsync<TInput, TOutput, TIssue>;
|
|
554
|
+
/**
|
|
555
|
+
* Pipe item type.
|
|
556
|
+
*/
|
|
557
|
+
type PipeItem<TInput, TOutput, TIssue extends BaseIssue<unknown>> = BaseSchema<TInput, TOutput, TIssue> | PipeAction<TInput, TOutput, TIssue>;
|
|
558
|
+
/**
|
|
559
|
+
* Pipe item async type.
|
|
560
|
+
*/
|
|
561
|
+
type PipeItemAsync<TInput, TOutput, TIssue extends BaseIssue<unknown>> = BaseSchemaAsync<TInput, TOutput, TIssue> | PipeActionAsync<TInput, TOutput, TIssue>;
|
|
562
|
+
/**
|
|
563
|
+
* Schema without pipe type.
|
|
564
|
+
*/
|
|
565
|
+
type SchemaWithoutPipe<TSchema extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>> = TSchema & {
|
|
566
|
+
pipe?: never;
|
|
567
|
+
};
|
|
568
|
+
|
|
569
|
+
/**
|
|
570
|
+
* Object entries type.
|
|
571
|
+
*/
|
|
572
|
+
interface ObjectEntries {
|
|
573
|
+
[key: string]: BaseSchema<unknown, unknown, BaseIssue<unknown>>;
|
|
574
|
+
}
|
|
575
|
+
/**
|
|
576
|
+
* Object entries async type.
|
|
577
|
+
*/
|
|
578
|
+
interface ObjectEntriesAsync {
|
|
579
|
+
[key: string]: BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>;
|
|
580
|
+
}
|
|
581
|
+
/**
|
|
582
|
+
* Question mark schema type.
|
|
583
|
+
*/
|
|
584
|
+
type QuestionMarkSchema = NullishSchema<BaseSchema<unknown, unknown, BaseIssue<unknown>>, unknown> | NullishSchemaAsync<BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, unknown> | OptionalSchema<BaseSchema<unknown, unknown, BaseIssue<unknown>>, unknown> | OptionalSchemaAsync<BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, unknown>;
|
|
585
|
+
/**
|
|
586
|
+
* Has default type.
|
|
587
|
+
*/
|
|
588
|
+
type HasDefault<TSchema extends QuestionMarkSchema> = undefined extends TSchema['default'] ? false : true;
|
|
589
|
+
/**
|
|
590
|
+
* Exact optional input type.
|
|
591
|
+
*/
|
|
592
|
+
type ExactOptionalInput<TSchema extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>> = TSchema extends OptionalSchema<infer TWrapped, unknown> | OptionalSchemaAsync<infer TWrapped, unknown> ? ExactOptionalInput<TWrapped> : InferInput<TSchema>;
|
|
593
|
+
/**
|
|
594
|
+
* Exact optional output type.
|
|
595
|
+
*/
|
|
596
|
+
type ExactOptionalOutput<TSchema extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>> = TSchema extends SchemaWithoutPipe<OptionalSchema<infer TWrapped, unknown>> | SchemaWithoutPipe<OptionalSchemaAsync<infer TWrapped, unknown>> ? HasDefault<TSchema> extends true ? InferOutput<TSchema> : ExactOptionalOutput<TWrapped> : InferOutput<TSchema>;
|
|
597
|
+
/**
|
|
598
|
+
* Infer entries input type.
|
|
599
|
+
*/
|
|
600
|
+
type InferEntriesInput<TEntries extends ObjectEntries | ObjectEntriesAsync> = {
|
|
601
|
+
-readonly [TKey in keyof TEntries]: ExactOptionalInput<TEntries[TKey]>;
|
|
602
|
+
};
|
|
603
|
+
/**
|
|
604
|
+
* Infer entries output type.
|
|
605
|
+
*/
|
|
606
|
+
type InferEntriesOutput<TEntries extends ObjectEntries | ObjectEntriesAsync> = {
|
|
607
|
+
-readonly [TKey in keyof TEntries]: ExactOptionalOutput<TEntries[TKey]>;
|
|
608
|
+
};
|
|
609
|
+
/**
|
|
610
|
+
* Optional input keys type.
|
|
611
|
+
*/
|
|
612
|
+
type OptionalInputKeys<TEntries extends ObjectEntries | ObjectEntriesAsync> = {
|
|
613
|
+
[TKey in keyof TEntries]: TEntries[TKey] extends QuestionMarkSchema ? TKey : never;
|
|
614
|
+
}[keyof TEntries];
|
|
615
|
+
/**
|
|
616
|
+
* Optional output keys type.
|
|
617
|
+
*/
|
|
618
|
+
type OptionalOutputKeys<TEntries extends ObjectEntries | ObjectEntriesAsync> = {
|
|
619
|
+
[TKey in keyof TEntries]: TEntries[TKey] extends QuestionMarkSchema ? undefined extends InferOutput<TEntries[TKey]> ? HasDefault<TEntries[TKey]> extends false ? TKey : never : never : never;
|
|
620
|
+
}[keyof TEntries];
|
|
621
|
+
/**
|
|
622
|
+
* Input with question marks type.
|
|
623
|
+
*/
|
|
624
|
+
type InputWithQuestionMarks<TEntries extends ObjectEntries | ObjectEntriesAsync, TObject extends InferEntriesInput<TEntries>> = MarkOptional<TObject, OptionalInputKeys<TEntries>>;
|
|
625
|
+
/**
|
|
626
|
+
* Output with question marks type.
|
|
627
|
+
*/
|
|
628
|
+
type OutputWithQuestionMarks<TEntries extends ObjectEntries | ObjectEntriesAsync, TObject extends InferEntriesOutput<TEntries>> = MarkOptional<TObject, OptionalOutputKeys<TEntries>>;
|
|
629
|
+
/**
|
|
630
|
+
* Readonly output keys type.
|
|
631
|
+
*/
|
|
632
|
+
type ReadonlyOutputKeys<TEntries extends ObjectEntries | ObjectEntriesAsync> = {
|
|
633
|
+
[TKey in keyof TEntries]: TEntries[TKey] extends SchemaWithPipe<infer TPipe> | SchemaWithPipeAsync<infer TPipe> ? ReadonlyAction<any> extends TPipe[number] ? TKey : never : never;
|
|
634
|
+
}[keyof TEntries];
|
|
635
|
+
/**
|
|
636
|
+
* Output with readonly type.
|
|
637
|
+
*/
|
|
638
|
+
type OutputWithReadonly<TEntries extends ObjectEntries | ObjectEntriesAsync, TObject extends OutputWithQuestionMarks<TEntries, InferEntriesOutput<TEntries>>> = Readonly<TObject> & Pick<TObject, Exclude<keyof TObject, ReadonlyOutputKeys<TEntries>>>;
|
|
639
|
+
/**
|
|
640
|
+
* Infer object input type.
|
|
641
|
+
*/
|
|
642
|
+
type InferObjectInput<TEntries extends ObjectEntries | ObjectEntriesAsync> = Prettify<InputWithQuestionMarks<TEntries, InferEntriesInput<TEntries>>>;
|
|
643
|
+
/**
|
|
644
|
+
* Infer object output type.
|
|
645
|
+
*/
|
|
646
|
+
type InferObjectOutput<TEntries extends ObjectEntries | ObjectEntriesAsync> = Prettify<OutputWithReadonly<TEntries, OutputWithQuestionMarks<TEntries, InferEntriesOutput<TEntries>>>>;
|
|
647
|
+
/**
|
|
648
|
+
* Infer object issue type.
|
|
649
|
+
*/
|
|
650
|
+
type InferObjectIssue<TEntries extends ObjectEntries | ObjectEntriesAsync> = InferIssue<TEntries[keyof TEntries]>;
|
|
651
|
+
|
|
652
|
+
/**
|
|
653
|
+
* Array path item type.
|
|
654
|
+
*/
|
|
655
|
+
interface ArrayPathItem {
|
|
656
|
+
/**
|
|
657
|
+
* The path item type.
|
|
658
|
+
*/
|
|
659
|
+
readonly type: 'array';
|
|
660
|
+
/**
|
|
661
|
+
* The path item origin.
|
|
662
|
+
*/
|
|
663
|
+
readonly origin: 'value';
|
|
664
|
+
/**
|
|
665
|
+
* The path item input.
|
|
666
|
+
*/
|
|
667
|
+
readonly input: MaybeReadonly<unknown[]>;
|
|
668
|
+
/**
|
|
669
|
+
* The path item key.
|
|
670
|
+
*/
|
|
671
|
+
readonly key: number;
|
|
672
|
+
/**
|
|
673
|
+
* The path item value.
|
|
674
|
+
*/
|
|
675
|
+
readonly value: unknown;
|
|
676
|
+
}
|
|
677
|
+
/**
|
|
678
|
+
* Map path item type.
|
|
679
|
+
*/
|
|
680
|
+
interface MapPathItem {
|
|
681
|
+
/**
|
|
682
|
+
* The path item type.
|
|
683
|
+
*/
|
|
684
|
+
readonly type: 'map';
|
|
685
|
+
/**
|
|
686
|
+
* The path item origin.
|
|
687
|
+
*/
|
|
688
|
+
readonly origin: 'key' | 'value';
|
|
689
|
+
/**
|
|
690
|
+
* The path item input.
|
|
691
|
+
*/
|
|
692
|
+
readonly input: Map<unknown, unknown>;
|
|
693
|
+
/**
|
|
694
|
+
* The path item key.
|
|
695
|
+
*/
|
|
696
|
+
readonly key: unknown;
|
|
697
|
+
/**
|
|
698
|
+
* The path item value.
|
|
699
|
+
*/
|
|
700
|
+
readonly value: unknown;
|
|
701
|
+
}
|
|
702
|
+
/**
|
|
703
|
+
* Object path item type.
|
|
704
|
+
*/
|
|
705
|
+
interface ObjectPathItem {
|
|
706
|
+
/**
|
|
707
|
+
* The path item type.
|
|
708
|
+
*/
|
|
709
|
+
readonly type: 'object';
|
|
710
|
+
/**
|
|
711
|
+
* The path item origin.
|
|
712
|
+
*/
|
|
713
|
+
readonly origin: 'key' | 'value';
|
|
714
|
+
/**
|
|
715
|
+
* The path item input.
|
|
716
|
+
*/
|
|
717
|
+
readonly input: Record<string, unknown>;
|
|
718
|
+
/**
|
|
719
|
+
* The path item key.
|
|
720
|
+
*/
|
|
721
|
+
readonly key: string;
|
|
722
|
+
/**
|
|
723
|
+
* The path item value.
|
|
724
|
+
*/
|
|
725
|
+
readonly value: unknown;
|
|
726
|
+
}
|
|
727
|
+
/**
|
|
728
|
+
* Set path item type.
|
|
729
|
+
*/
|
|
730
|
+
interface SetPathItem {
|
|
731
|
+
/**
|
|
732
|
+
* The path item type.
|
|
733
|
+
*/
|
|
734
|
+
readonly type: 'set';
|
|
735
|
+
/**
|
|
736
|
+
* The path item origin.
|
|
737
|
+
*/
|
|
738
|
+
readonly origin: 'value';
|
|
739
|
+
/**
|
|
740
|
+
* The path item input.
|
|
741
|
+
*/
|
|
742
|
+
readonly input: Set<unknown>;
|
|
743
|
+
/**
|
|
744
|
+
* The path item key.
|
|
745
|
+
*/
|
|
746
|
+
readonly key: null;
|
|
747
|
+
/**
|
|
748
|
+
* The path item key.
|
|
749
|
+
*/
|
|
750
|
+
readonly value: unknown;
|
|
751
|
+
}
|
|
752
|
+
/**
|
|
753
|
+
* Unknown path item type.
|
|
754
|
+
*/
|
|
755
|
+
interface UnknownPathItem {
|
|
756
|
+
/**
|
|
757
|
+
* The path item type.
|
|
758
|
+
*/
|
|
759
|
+
readonly type: 'unknown';
|
|
760
|
+
/**
|
|
761
|
+
* The path item origin.
|
|
762
|
+
*/
|
|
763
|
+
readonly origin: 'key' | 'value';
|
|
764
|
+
/**
|
|
765
|
+
* The path item input.
|
|
766
|
+
*/
|
|
767
|
+
readonly input: unknown;
|
|
768
|
+
/**
|
|
769
|
+
* The path item key.
|
|
770
|
+
*/
|
|
771
|
+
readonly key: unknown;
|
|
772
|
+
/**
|
|
773
|
+
* The path item value.
|
|
774
|
+
*/
|
|
775
|
+
readonly value: unknown;
|
|
776
|
+
}
|
|
777
|
+
/**
|
|
778
|
+
* Issue path item type.
|
|
779
|
+
*/
|
|
780
|
+
type IssuePathItem = ArrayPathItem | MapPathItem | ObjectPathItem | SetPathItem | UnknownPathItem;
|
|
781
|
+
/**
|
|
782
|
+
* Base issue type.
|
|
783
|
+
*/
|
|
784
|
+
interface BaseIssue<TInput> extends Config<BaseIssue<TInput>> {
|
|
785
|
+
/**
|
|
786
|
+
* The issue kind.
|
|
787
|
+
*/
|
|
788
|
+
readonly kind: 'schema' | 'validation' | 'transformation';
|
|
789
|
+
/**
|
|
790
|
+
* The issue type.
|
|
791
|
+
*/
|
|
792
|
+
readonly type: string;
|
|
793
|
+
/**
|
|
794
|
+
* The raw input data.
|
|
795
|
+
*/
|
|
796
|
+
readonly input: TInput;
|
|
797
|
+
/**
|
|
798
|
+
* The expected property.
|
|
799
|
+
*/
|
|
800
|
+
readonly expected: string | null;
|
|
801
|
+
/**
|
|
802
|
+
* The received property.
|
|
803
|
+
*/
|
|
804
|
+
readonly received: string;
|
|
805
|
+
/**
|
|
806
|
+
* The error message.
|
|
807
|
+
*/
|
|
808
|
+
readonly message: string;
|
|
809
|
+
/**
|
|
810
|
+
* The input requirement.
|
|
811
|
+
*/
|
|
812
|
+
readonly requirement?: unknown | undefined;
|
|
813
|
+
/**
|
|
814
|
+
* The issue path.
|
|
815
|
+
*/
|
|
816
|
+
readonly path?: [IssuePathItem, ...IssuePathItem[]] | undefined;
|
|
817
|
+
/**
|
|
818
|
+
* The sub issues.
|
|
819
|
+
*/
|
|
820
|
+
readonly issues?: [BaseIssue<TInput>, ...BaseIssue<TInput>[]] | undefined;
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
/**
|
|
824
|
+
* Config type.
|
|
825
|
+
*/
|
|
826
|
+
interface Config<TIssue extends BaseIssue<unknown>> {
|
|
827
|
+
/**
|
|
828
|
+
* The selected language.
|
|
829
|
+
*/
|
|
830
|
+
readonly lang?: string | undefined;
|
|
831
|
+
/**
|
|
832
|
+
* The error message.
|
|
833
|
+
*/
|
|
834
|
+
readonly message?: ErrorMessage<TIssue> | undefined;
|
|
835
|
+
/**
|
|
836
|
+
* Whether it was abort early.
|
|
837
|
+
*/
|
|
838
|
+
readonly abortEarly?: boolean | undefined;
|
|
839
|
+
/**
|
|
840
|
+
* Whether the pipe was abort early.
|
|
841
|
+
*/
|
|
842
|
+
readonly abortPipeEarly?: boolean | undefined;
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
/**
|
|
846
|
+
* Array issue type.
|
|
847
|
+
*/
|
|
848
|
+
interface ArrayIssue extends BaseIssue<unknown> {
|
|
849
|
+
/**
|
|
850
|
+
* The issue kind.
|
|
851
|
+
*/
|
|
852
|
+
readonly kind: 'schema';
|
|
853
|
+
/**
|
|
854
|
+
* The issue type.
|
|
855
|
+
*/
|
|
856
|
+
readonly type: 'array';
|
|
857
|
+
/**
|
|
858
|
+
* The expected property.
|
|
859
|
+
*/
|
|
860
|
+
readonly expected: 'Array';
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
/**
|
|
864
|
+
* Array schema type.
|
|
865
|
+
*/
|
|
866
|
+
interface ArraySchema<TItem extends BaseSchema<unknown, unknown, BaseIssue<unknown>>, TMessage extends ErrorMessage<ArrayIssue> | undefined> extends BaseSchema<InferInput<TItem>[], InferOutput<TItem>[], ArrayIssue | InferIssue<TItem>> {
|
|
867
|
+
/**
|
|
868
|
+
* The schema type.
|
|
869
|
+
*/
|
|
870
|
+
readonly type: 'array';
|
|
871
|
+
/**
|
|
872
|
+
* The schema reference.
|
|
873
|
+
*/
|
|
874
|
+
readonly reference: typeof array;
|
|
875
|
+
/**
|
|
876
|
+
* The expected property.
|
|
877
|
+
*/
|
|
878
|
+
readonly expects: 'Array';
|
|
879
|
+
/**
|
|
880
|
+
* The array item schema.
|
|
881
|
+
*/
|
|
882
|
+
readonly item: TItem;
|
|
883
|
+
/**
|
|
884
|
+
* The error message.
|
|
885
|
+
*/
|
|
886
|
+
readonly message: TMessage;
|
|
887
|
+
}
|
|
888
|
+
/**
|
|
889
|
+
* Creates an array schema.
|
|
890
|
+
*
|
|
891
|
+
* @param item The item schema.
|
|
892
|
+
*
|
|
893
|
+
* @returns An array schema.
|
|
894
|
+
*/
|
|
895
|
+
declare function array<const TItem extends BaseSchema<unknown, unknown, BaseIssue<unknown>>>(item: TItem): ArraySchema<TItem, undefined>;
|
|
896
|
+
/**
|
|
897
|
+
* Creates an array schema.
|
|
898
|
+
*
|
|
899
|
+
* @param item The item schema.
|
|
900
|
+
* @param message The error message.
|
|
901
|
+
*
|
|
902
|
+
* @returns An array schema.
|
|
903
|
+
*/
|
|
904
|
+
declare function array<const TItem extends BaseSchema<unknown, unknown, BaseIssue<unknown>>, const TMessage extends ErrorMessage<ArrayIssue> | undefined>(item: TItem, message: TMessage): ArraySchema<TItem, TMessage>;
|
|
905
|
+
|
|
906
|
+
/**
|
|
907
|
+
* Boolean issue type.
|
|
908
|
+
*/
|
|
909
|
+
interface BooleanIssue extends BaseIssue<unknown> {
|
|
910
|
+
/**
|
|
911
|
+
* The issue kind.
|
|
912
|
+
*/
|
|
913
|
+
readonly kind: 'schema';
|
|
914
|
+
/**
|
|
915
|
+
* The issue type.
|
|
916
|
+
*/
|
|
917
|
+
readonly type: 'boolean';
|
|
918
|
+
/**
|
|
919
|
+
* The expected property.
|
|
920
|
+
*/
|
|
921
|
+
readonly expected: 'boolean';
|
|
922
|
+
}
|
|
923
|
+
/**
|
|
924
|
+
* Boolean schema type.
|
|
925
|
+
*/
|
|
926
|
+
interface BooleanSchema<TMessage extends ErrorMessage<BooleanIssue> | undefined> extends BaseSchema<boolean, boolean, BooleanIssue> {
|
|
927
|
+
/**
|
|
928
|
+
* The schema type.
|
|
929
|
+
*/
|
|
930
|
+
readonly type: 'boolean';
|
|
931
|
+
/**
|
|
932
|
+
* The schema reference.
|
|
933
|
+
*/
|
|
934
|
+
readonly reference: typeof boolean;
|
|
935
|
+
/**
|
|
936
|
+
* The expected property.
|
|
937
|
+
*/
|
|
938
|
+
readonly expects: 'boolean';
|
|
939
|
+
/**
|
|
940
|
+
* The error message.
|
|
941
|
+
*/
|
|
942
|
+
readonly message: TMessage;
|
|
943
|
+
}
|
|
944
|
+
/**
|
|
945
|
+
* Creates a boolean schema.
|
|
946
|
+
*
|
|
947
|
+
* @returns A boolean schema.
|
|
948
|
+
*/
|
|
949
|
+
declare function boolean(): BooleanSchema<undefined>;
|
|
950
|
+
/**
|
|
951
|
+
* Creates a boolean schema.
|
|
952
|
+
*
|
|
953
|
+
* @param message The error message.
|
|
954
|
+
*
|
|
955
|
+
* @returns A boolean schema.
|
|
956
|
+
*/
|
|
957
|
+
declare function boolean<const TMessage extends ErrorMessage<BooleanIssue> | undefined>(message: TMessage): BooleanSchema<TMessage>;
|
|
958
|
+
|
|
959
|
+
/**
|
|
960
|
+
* Class type.
|
|
961
|
+
*/
|
|
962
|
+
type Class = new (...args: any[]) => any;
|
|
963
|
+
/**
|
|
964
|
+
* Instance issue type.
|
|
965
|
+
*/
|
|
966
|
+
interface InstanceIssue extends BaseIssue<unknown> {
|
|
967
|
+
/**
|
|
968
|
+
* The issue kind.
|
|
969
|
+
*/
|
|
970
|
+
readonly kind: 'schema';
|
|
971
|
+
/**
|
|
972
|
+
* The issue type.
|
|
973
|
+
*/
|
|
974
|
+
readonly type: 'instance';
|
|
975
|
+
/**
|
|
976
|
+
* The expected property.
|
|
977
|
+
*/
|
|
978
|
+
readonly expected: string;
|
|
979
|
+
}
|
|
980
|
+
/**
|
|
981
|
+
* Instance schema type.
|
|
982
|
+
*/
|
|
983
|
+
interface InstanceSchema<TClass extends Class, TMessage extends ErrorMessage<InstanceIssue> | undefined> extends BaseSchema<InstanceType<TClass>, InstanceType<TClass>, InstanceIssue> {
|
|
984
|
+
/**
|
|
985
|
+
* The schema type.
|
|
986
|
+
*/
|
|
987
|
+
readonly type: 'instance';
|
|
988
|
+
/**
|
|
989
|
+
* The schema reference.
|
|
990
|
+
*/
|
|
991
|
+
readonly reference: typeof instance;
|
|
992
|
+
/**
|
|
993
|
+
* The class of the instance.
|
|
994
|
+
*/
|
|
995
|
+
readonly class: TClass;
|
|
996
|
+
/**
|
|
997
|
+
* The error message.
|
|
998
|
+
*/
|
|
999
|
+
readonly message: TMessage;
|
|
1000
|
+
}
|
|
1001
|
+
/**
|
|
1002
|
+
* Creates an instance schema.
|
|
1003
|
+
*
|
|
1004
|
+
* @param class_ The class of the instance.
|
|
1005
|
+
*
|
|
1006
|
+
* @returns An instance schema.
|
|
1007
|
+
*/
|
|
1008
|
+
declare function instance<TClass extends Class>(class_: TClass): InstanceSchema<TClass, undefined>;
|
|
1009
|
+
/**
|
|
1010
|
+
* Creates an instance schema.
|
|
1011
|
+
*
|
|
1012
|
+
* @param class_ The class of the instance.
|
|
1013
|
+
* @param message The error message.
|
|
1014
|
+
*
|
|
1015
|
+
* @returns An instance schema.
|
|
1016
|
+
*/
|
|
1017
|
+
declare function instance<TClass extends Class, const TMessage extends ErrorMessage<InstanceIssue> | undefined>(class_: TClass, message: TMessage): InstanceSchema<TClass, TMessage>;
|
|
1018
|
+
|
|
1019
|
+
/**
|
|
1020
|
+
* Infer nullish output type.
|
|
1021
|
+
*/
|
|
1022
|
+
type InferNullishOutput<TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, TDefault extends DefaultAsync<TWrapped, null | undefined>> = undefined extends TDefault ? InferOutput<TWrapped> | null | undefined : InferOutput<TWrapped> | Extract<DefaultValue<TDefault>, null | undefined>;
|
|
1023
|
+
|
|
1024
|
+
/**
|
|
1025
|
+
* Nullish schema type.
|
|
1026
|
+
*/
|
|
1027
|
+
interface NullishSchema<TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>>, TDefault extends Default<TWrapped, null | undefined>> extends BaseSchema<InferInput<TWrapped> | null | undefined, InferNullishOutput<TWrapped, TDefault>, InferIssue<TWrapped>> {
|
|
1028
|
+
/**
|
|
1029
|
+
* The schema type.
|
|
1030
|
+
*/
|
|
1031
|
+
readonly type: 'nullish';
|
|
1032
|
+
/**
|
|
1033
|
+
* The schema reference.
|
|
1034
|
+
*/
|
|
1035
|
+
readonly reference: typeof nullish;
|
|
1036
|
+
/**
|
|
1037
|
+
* The expected property.
|
|
1038
|
+
*/
|
|
1039
|
+
readonly expects: `(${TWrapped['expects']} | null | undefined)`;
|
|
1040
|
+
/**
|
|
1041
|
+
* The wrapped schema.
|
|
1042
|
+
*/
|
|
1043
|
+
readonly wrapped: TWrapped;
|
|
1044
|
+
/**
|
|
1045
|
+
* The default value.
|
|
1046
|
+
*/
|
|
1047
|
+
readonly default: TDefault;
|
|
1048
|
+
}
|
|
1049
|
+
/**
|
|
1050
|
+
* Creates a nullish schema.
|
|
1051
|
+
*
|
|
1052
|
+
* @param wrapped The wrapped schema.
|
|
1053
|
+
*
|
|
1054
|
+
* @returns A nullish schema.
|
|
8
1055
|
*/
|
|
9
|
-
declare const
|
|
1056
|
+
declare function nullish<const TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>>>(wrapped: TWrapped): NullishSchema<TWrapped, undefined>;
|
|
10
1057
|
/**
|
|
11
|
-
*
|
|
1058
|
+
* Creates a nullish schema.
|
|
1059
|
+
*
|
|
1060
|
+
* @param wrapped The wrapped schema.
|
|
1061
|
+
* @param default_ The default value.
|
|
1062
|
+
*
|
|
1063
|
+
* @returns A nullish schema.
|
|
12
1064
|
*/
|
|
13
|
-
declare const
|
|
1065
|
+
declare function nullish<const TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>>, const TDefault extends Default<TWrapped, null | undefined>>(wrapped: TWrapped, default_: TDefault): NullishSchema<TWrapped, TDefault>;
|
|
1066
|
+
|
|
14
1067
|
/**
|
|
15
|
-
*
|
|
1068
|
+
* Nullish schema async type.
|
|
16
1069
|
*/
|
|
17
|
-
|
|
1070
|
+
interface NullishSchemaAsync<TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, TDefault extends DefaultAsync<TWrapped, null | undefined>> extends BaseSchemaAsync<InferInput<TWrapped> | null | undefined, InferNullishOutput<TWrapped, TDefault>, InferIssue<TWrapped>> {
|
|
1071
|
+
/**
|
|
1072
|
+
* The schema type.
|
|
1073
|
+
*/
|
|
1074
|
+
readonly type: 'nullish';
|
|
1075
|
+
/**
|
|
1076
|
+
* The schema reference.
|
|
1077
|
+
*/
|
|
1078
|
+
readonly reference: typeof nullishAsync;
|
|
1079
|
+
/**
|
|
1080
|
+
* The expected property.
|
|
1081
|
+
*/
|
|
1082
|
+
readonly expects: `(${TWrapped['expects']} | null | undefined)`;
|
|
1083
|
+
/**
|
|
1084
|
+
* The wrapped schema.
|
|
1085
|
+
*/
|
|
1086
|
+
readonly wrapped: TWrapped;
|
|
1087
|
+
/**
|
|
1088
|
+
* The default value.
|
|
1089
|
+
*/
|
|
1090
|
+
readonly default: TDefault;
|
|
1091
|
+
}
|
|
18
1092
|
/**
|
|
19
|
-
*
|
|
1093
|
+
* Creates a nullish schema.
|
|
1094
|
+
*
|
|
1095
|
+
* @param wrapped The wrapped schema.
|
|
1096
|
+
*
|
|
1097
|
+
* @returns A nullish schema.
|
|
20
1098
|
*/
|
|
21
|
-
declare const
|
|
1099
|
+
declare function nullishAsync<const TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>>(wrapped: TWrapped): NullishSchemaAsync<TWrapped, undefined>;
|
|
22
1100
|
/**
|
|
23
|
-
*
|
|
1101
|
+
* Creates a nullish schema.
|
|
1102
|
+
*
|
|
1103
|
+
* @param wrapped The wrapped schema.
|
|
1104
|
+
* @param default_ The default value.
|
|
1105
|
+
*
|
|
1106
|
+
* @returns A nullish schema.
|
|
24
1107
|
*/
|
|
25
|
-
declare const
|
|
1108
|
+
declare function nullishAsync<const TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, const TDefault extends DefaultAsync<TWrapped, null | undefined>>(wrapped: TWrapped, default_: TDefault): NullishSchemaAsync<TWrapped, TDefault>;
|
|
1109
|
+
|
|
26
1110
|
/**
|
|
27
|
-
*
|
|
1111
|
+
* Object issue type.
|
|
28
1112
|
*/
|
|
29
|
-
|
|
1113
|
+
interface ObjectIssue extends BaseIssue<unknown> {
|
|
1114
|
+
/**
|
|
1115
|
+
* The issue kind.
|
|
1116
|
+
*/
|
|
1117
|
+
readonly kind: 'schema';
|
|
1118
|
+
/**
|
|
1119
|
+
* The issue type.
|
|
1120
|
+
*/
|
|
1121
|
+
readonly type: 'object';
|
|
1122
|
+
/**
|
|
1123
|
+
* The expected property.
|
|
1124
|
+
*/
|
|
1125
|
+
readonly expected: 'Object';
|
|
1126
|
+
}
|
|
1127
|
+
|
|
30
1128
|
/**
|
|
31
|
-
*
|
|
1129
|
+
* Object schema type.
|
|
32
1130
|
*/
|
|
33
|
-
|
|
1131
|
+
interface ObjectSchema<TEntries extends ObjectEntries, TMessage extends ErrorMessage<ObjectIssue> | undefined> extends BaseSchema<InferObjectInput<TEntries>, InferObjectOutput<TEntries>, ObjectIssue | InferObjectIssue<TEntries>> {
|
|
1132
|
+
/**
|
|
1133
|
+
* The schema type.
|
|
1134
|
+
*/
|
|
1135
|
+
readonly type: 'object';
|
|
1136
|
+
/**
|
|
1137
|
+
* The schema reference.
|
|
1138
|
+
*/
|
|
1139
|
+
readonly reference: typeof object;
|
|
1140
|
+
/**
|
|
1141
|
+
* The expected property.
|
|
1142
|
+
*/
|
|
1143
|
+
readonly expects: 'Object';
|
|
1144
|
+
/**
|
|
1145
|
+
* The entries schema.
|
|
1146
|
+
*/
|
|
1147
|
+
readonly entries: TEntries;
|
|
1148
|
+
/**
|
|
1149
|
+
* The error message.
|
|
1150
|
+
*/
|
|
1151
|
+
readonly message: TMessage;
|
|
1152
|
+
}
|
|
34
1153
|
/**
|
|
35
|
-
*
|
|
1154
|
+
* Creates an object schema.
|
|
1155
|
+
*
|
|
1156
|
+
* Hint: This schema removes unknown entries. The output will only include the
|
|
1157
|
+
* entries you specify. To include unknown entries, use `looseObject`. To
|
|
1158
|
+
* return an issue for unknown entries, use `strictObject`. To include and
|
|
1159
|
+
* validate unknown entries, use `objectWithRest`.
|
|
1160
|
+
*
|
|
1161
|
+
* @param entries The entries schema.
|
|
1162
|
+
*
|
|
1163
|
+
* @returns An object schema.
|
|
36
1164
|
*/
|
|
37
|
-
declare const
|
|
38
|
-
declare const RE_JAVASCRIPT_PROTOCOL: RegExp;
|
|
1165
|
+
declare function object<const TEntries extends ObjectEntries>(entries: TEntries): ObjectSchema<TEntries, undefined>;
|
|
39
1166
|
/**
|
|
40
|
-
*
|
|
1167
|
+
* Creates an object schema.
|
|
1168
|
+
*
|
|
1169
|
+
* Hint: This schema removes unknown entries. The output will only include the
|
|
1170
|
+
* entries you specify. To include unknown entries, use `looseObject`. To
|
|
1171
|
+
* return an issue for unknown entries, use `strictObject`. To include and
|
|
1172
|
+
* validate unknown entries, use `objectWithRest`.
|
|
1173
|
+
*
|
|
1174
|
+
* @param entries The entries schema.
|
|
1175
|
+
* @param message The error message.
|
|
1176
|
+
*
|
|
1177
|
+
* @returns An object schema.
|
|
41
1178
|
*/
|
|
42
|
-
declare
|
|
1179
|
+
declare function object<const TEntries extends ObjectEntries, const TMessage extends ErrorMessage<ObjectIssue> | undefined>(entries: TEntries, message: TMessage): ObjectSchema<TEntries, TMessage>;
|
|
1180
|
+
|
|
43
1181
|
/**
|
|
44
|
-
*
|
|
1182
|
+
* Infer optional output type.
|
|
45
1183
|
*/
|
|
46
|
-
|
|
47
|
-
declare const REACT_BUILD_IN_HOOKS: readonly ["use", "useActionState", "useCallback", "useContext", "useDebugValue", "useDeferredValue", "useEffect", "useFormStatus", "useId", "useImperativeHandle", "useInsertionEffect", "useLayoutEffect", "useMemo", "useOptimistic", "useReducer", "useRef", "useState", "useSyncExternalStore", "useTransition"];
|
|
1184
|
+
type InferOptionalOutput<TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, TDefault extends DefaultAsync<TWrapped, undefined>> = undefined extends TDefault ? InferOutput<TWrapped> | undefined : InferOutput<TWrapped> | Extract<DefaultValue<TDefault>, undefined>;
|
|
48
1185
|
|
|
49
1186
|
/**
|
|
50
|
-
*
|
|
51
|
-
* @internal
|
|
52
|
-
* @param pluginName The name of the plugin.
|
|
53
|
-
* @returns The ESLint rule creator.
|
|
1187
|
+
* Optional schema type.
|
|
54
1188
|
*/
|
|
55
|
-
|
|
1189
|
+
interface OptionalSchema<TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>>, TDefault extends Default<TWrapped, undefined>> extends BaseSchema<InferInput<TWrapped> | undefined, InferOptionalOutput<TWrapped, TDefault>, InferIssue<TWrapped>> {
|
|
1190
|
+
/**
|
|
1191
|
+
* The schema type.
|
|
1192
|
+
*/
|
|
1193
|
+
readonly type: 'optional';
|
|
1194
|
+
/**
|
|
1195
|
+
* The schema reference.
|
|
1196
|
+
*/
|
|
1197
|
+
readonly reference: typeof optional;
|
|
1198
|
+
/**
|
|
1199
|
+
* The expected property.
|
|
1200
|
+
*/
|
|
1201
|
+
readonly expects: `(${TWrapped['expects']} | undefined)`;
|
|
1202
|
+
/**
|
|
1203
|
+
* The wrapped schema.
|
|
1204
|
+
*/
|
|
1205
|
+
readonly wrapped: TWrapped;
|
|
1206
|
+
/**
|
|
1207
|
+
* The default value.
|
|
1208
|
+
*/
|
|
1209
|
+
readonly default: TDefault;
|
|
1210
|
+
}
|
|
1211
|
+
/**
|
|
1212
|
+
* Creates a optional schema.
|
|
1213
|
+
*
|
|
1214
|
+
* @param wrapped The wrapped schema.
|
|
1215
|
+
*
|
|
1216
|
+
* @returns A optional schema.
|
|
1217
|
+
*/
|
|
1218
|
+
declare function optional<const TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>>>(wrapped: TWrapped): OptionalSchema<TWrapped, undefined>;
|
|
1219
|
+
/**
|
|
1220
|
+
* Creates a optional schema.
|
|
1221
|
+
*
|
|
1222
|
+
* @param wrapped The wrapped schema.
|
|
1223
|
+
* @param default_ The default value.
|
|
1224
|
+
*
|
|
1225
|
+
* @returns A optional schema.
|
|
1226
|
+
*/
|
|
1227
|
+
declare function optional<const TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>>, const TDefault extends Default<TWrapped, undefined>>(wrapped: TWrapped, default_: TDefault): OptionalSchema<TWrapped, TDefault>;
|
|
56
1228
|
|
|
57
|
-
|
|
1229
|
+
/**
|
|
1230
|
+
* Optional schema async type.
|
|
1231
|
+
*/
|
|
1232
|
+
interface OptionalSchemaAsync<TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, TDefault extends DefaultAsync<TWrapped, undefined>> extends BaseSchemaAsync<InferInput<TWrapped> | undefined, InferOptionalOutput<TWrapped, TDefault>, InferIssue<TWrapped>> {
|
|
1233
|
+
/**
|
|
1234
|
+
* The schema type.
|
|
1235
|
+
*/
|
|
1236
|
+
readonly type: 'optional';
|
|
1237
|
+
/**
|
|
1238
|
+
* The schema reference.
|
|
1239
|
+
*/
|
|
1240
|
+
readonly reference: typeof optionalAsync;
|
|
1241
|
+
/**
|
|
1242
|
+
* The expected property.
|
|
1243
|
+
*/
|
|
1244
|
+
readonly expects: `(${TWrapped['expects']} | undefined)`;
|
|
1245
|
+
/**
|
|
1246
|
+
* The wrapped schema.
|
|
1247
|
+
*/
|
|
1248
|
+
readonly wrapped: TWrapped;
|
|
1249
|
+
/**
|
|
1250
|
+
* The default value.
|
|
1251
|
+
*/
|
|
1252
|
+
readonly default: TDefault;
|
|
1253
|
+
}
|
|
1254
|
+
/**
|
|
1255
|
+
* Creates an optional schema.
|
|
1256
|
+
*
|
|
1257
|
+
* @param wrapped The wrapped schema.
|
|
1258
|
+
*
|
|
1259
|
+
* @returns An optional schema.
|
|
1260
|
+
*/
|
|
1261
|
+
declare function optionalAsync<const TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>>(wrapped: TWrapped): OptionalSchemaAsync<TWrapped, undefined>;
|
|
1262
|
+
/**
|
|
1263
|
+
* Creates an optional schema.
|
|
1264
|
+
*
|
|
1265
|
+
* @param wrapped The wrapped schema.
|
|
1266
|
+
* @param default_ The default value.
|
|
1267
|
+
*
|
|
1268
|
+
* @returns An optional schema.
|
|
1269
|
+
*/
|
|
1270
|
+
declare function optionalAsync<const TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, const TDefault extends DefaultAsync<TWrapped, undefined>>(wrapped: TWrapped, default_: TDefault): OptionalSchemaAsync<TWrapped, TDefault>;
|
|
1271
|
+
|
|
1272
|
+
/**
|
|
1273
|
+
* String issue type.
|
|
1274
|
+
*/
|
|
1275
|
+
interface StringIssue extends BaseIssue<unknown> {
|
|
1276
|
+
/**
|
|
1277
|
+
* The issue kind.
|
|
1278
|
+
*/
|
|
1279
|
+
readonly kind: 'schema';
|
|
1280
|
+
/**
|
|
1281
|
+
* The issue type.
|
|
1282
|
+
*/
|
|
1283
|
+
readonly type: 'string';
|
|
1284
|
+
/**
|
|
1285
|
+
* The expected property.
|
|
1286
|
+
*/
|
|
1287
|
+
readonly expected: 'string';
|
|
1288
|
+
}
|
|
1289
|
+
/**
|
|
1290
|
+
* String schema type.
|
|
1291
|
+
*/
|
|
1292
|
+
interface StringSchema<TMessage extends ErrorMessage<StringIssue> | undefined> extends BaseSchema<string, string, StringIssue> {
|
|
1293
|
+
/**
|
|
1294
|
+
* The schema type.
|
|
1295
|
+
*/
|
|
1296
|
+
readonly type: 'string';
|
|
1297
|
+
/**
|
|
1298
|
+
* The schema reference.
|
|
1299
|
+
*/
|
|
1300
|
+
readonly reference: typeof string;
|
|
1301
|
+
/**
|
|
1302
|
+
* The expected property.
|
|
1303
|
+
*/
|
|
1304
|
+
readonly expects: 'string';
|
|
1305
|
+
/**
|
|
1306
|
+
* The error message.
|
|
1307
|
+
*/
|
|
1308
|
+
readonly message: TMessage;
|
|
1309
|
+
}
|
|
1310
|
+
/**
|
|
1311
|
+
* Creates a string schema.
|
|
1312
|
+
*
|
|
1313
|
+
* @returns A string schema.
|
|
1314
|
+
*/
|
|
1315
|
+
declare function string(): StringSchema<undefined>;
|
|
1316
|
+
/**
|
|
1317
|
+
* Creates a string schema.
|
|
1318
|
+
*
|
|
1319
|
+
* @param message The error message.
|
|
1320
|
+
*
|
|
1321
|
+
* @returns A string schema.
|
|
1322
|
+
*/
|
|
1323
|
+
declare function string<const TMessage extends ErrorMessage<StringIssue> | undefined>(message: TMessage): StringSchema<TMessage>;
|
|
1324
|
+
|
|
1325
|
+
/**
|
|
1326
|
+
* Readonly action type.
|
|
1327
|
+
*/
|
|
1328
|
+
interface ReadonlyAction<TInput> extends BaseTransformation<TInput, Readonly<TInput>, never> {
|
|
1329
|
+
/**
|
|
1330
|
+
* The action type.
|
|
1331
|
+
*/
|
|
1332
|
+
readonly type: 'readonly';
|
|
1333
|
+
/**
|
|
1334
|
+
* The action reference.
|
|
1335
|
+
*/
|
|
1336
|
+
readonly reference: typeof readonly;
|
|
1337
|
+
}
|
|
1338
|
+
/**
|
|
1339
|
+
* Creates a readonly transformation action.
|
|
1340
|
+
*
|
|
1341
|
+
* @returns A readonly action.
|
|
1342
|
+
*/
|
|
1343
|
+
declare function readonly<TInput>(): ReadonlyAction<TInput>;
|
|
58
1344
|
|
|
59
1345
|
/**
|
|
60
1346
|
* @internal
|
|
@@ -62,35 +1348,35 @@ declare function getReactVersion(at?: string): E.Either<string, unknown>;
|
|
|
62
1348
|
* This allows the rule to know some key information before checking for user-defined hooks.
|
|
63
1349
|
* For example, the position of the `deps` argument for the user-defined `useCustomEffect` hook that represents the built-in `useEffect` hook.
|
|
64
1350
|
*/
|
|
65
|
-
declare const CustomHookSchema:
|
|
1351
|
+
declare const CustomHookSchema: ObjectSchema<{}, undefined>;
|
|
66
1352
|
/**
|
|
67
1353
|
* @internal
|
|
68
1354
|
*/
|
|
69
|
-
declare const CustomAttributeSchema:
|
|
1355
|
+
declare const CustomAttributeSchema: ObjectSchema<{
|
|
70
1356
|
/**
|
|
71
1357
|
* The name of the attribute in the user-defined component.
|
|
72
1358
|
* @example
|
|
73
1359
|
* "to"
|
|
74
1360
|
*/
|
|
75
|
-
readonly name:
|
|
1361
|
+
readonly name: StringSchema<undefined>;
|
|
76
1362
|
/**
|
|
77
1363
|
* The name of the attribute in the built-in component.
|
|
78
1364
|
* @example
|
|
79
1365
|
* "href"
|
|
80
1366
|
*/
|
|
81
|
-
readonly as:
|
|
1367
|
+
readonly as: OptionalSchema<StringSchema<undefined>, undefined>;
|
|
82
1368
|
/**
|
|
83
1369
|
* Whether the attribute is controlled or not in the user-defined component.
|
|
84
1370
|
* @example
|
|
85
1371
|
* `true`
|
|
86
1372
|
*/
|
|
87
|
-
readonly controlled:
|
|
1373
|
+
readonly controlled: OptionalSchema<BooleanSchema<undefined>, undefined>;
|
|
88
1374
|
/**
|
|
89
1375
|
* The default value of the attribute in the user-defined component.
|
|
90
1376
|
* @example
|
|
91
1377
|
* `"/"`
|
|
92
1378
|
*/
|
|
93
|
-
readonly defaultValue:
|
|
1379
|
+
readonly defaultValue: OptionalSchema<StringSchema<undefined>, undefined>;
|
|
94
1380
|
}, undefined>;
|
|
95
1381
|
/**
|
|
96
1382
|
* @internal
|
|
@@ -100,188 +1386,188 @@ declare const CustomAttributeSchema: valibot.ObjectSchema<{
|
|
|
100
1386
|
* Which attribute is used as the `href` prop for the user-defined `Link` component that represents the built-in `a` element.
|
|
101
1387
|
* Which attributes are used as `children` props for a user-defined `Button` component to receive children of that component.
|
|
102
1388
|
*/
|
|
103
|
-
declare const CustomComponentSchema:
|
|
1389
|
+
declare const CustomComponentSchema: ObjectSchema<{
|
|
104
1390
|
/**
|
|
105
1391
|
* The name of the user-defined component.
|
|
106
1392
|
* @example
|
|
107
1393
|
* "Link"
|
|
108
1394
|
*/
|
|
109
|
-
readonly name:
|
|
1395
|
+
readonly name: StringSchema<undefined>;
|
|
110
1396
|
/**
|
|
111
1397
|
* The ESQuery selector to select the component precisely.
|
|
112
1398
|
* @example
|
|
113
1399
|
* `JSXElement:has(JSXAttribute[name.name='component'][value.value='a'])`
|
|
114
1400
|
*/
|
|
115
|
-
readonly selector:
|
|
1401
|
+
readonly selector: OptionalSchema<StringSchema<undefined>, undefined>;
|
|
116
1402
|
/**
|
|
117
1403
|
* The name of the built-in component that the user-defined component represents.
|
|
118
1404
|
* @example
|
|
119
1405
|
* "a"
|
|
120
1406
|
*/
|
|
121
|
-
readonly as:
|
|
1407
|
+
readonly as: OptionalSchema<StringSchema<undefined>, undefined>;
|
|
122
1408
|
/**
|
|
123
1409
|
* Pre-defined attributes that are used in the user-defined component.
|
|
124
1410
|
* @example
|
|
125
1411
|
* `Link` component has a `to` attribute that represents the `href` attribute in the built-in `a` element with a default value of `"/"`.
|
|
126
1412
|
*/
|
|
127
|
-
readonly attributes:
|
|
1413
|
+
readonly attributes: OptionalSchema<ArraySchema<ObjectSchema<{
|
|
128
1414
|
/**
|
|
129
1415
|
* The name of the attribute in the user-defined component.
|
|
130
1416
|
* @example
|
|
131
1417
|
* "to"
|
|
132
1418
|
*/
|
|
133
|
-
readonly name:
|
|
1419
|
+
readonly name: StringSchema<undefined>;
|
|
134
1420
|
/**
|
|
135
1421
|
* The name of the attribute in the built-in component.
|
|
136
1422
|
* @example
|
|
137
1423
|
* "href"
|
|
138
1424
|
*/
|
|
139
|
-
readonly as:
|
|
1425
|
+
readonly as: OptionalSchema<StringSchema<undefined>, undefined>;
|
|
140
1426
|
/**
|
|
141
1427
|
* Whether the attribute is controlled or not in the user-defined component.
|
|
142
1428
|
* @example
|
|
143
1429
|
* `true`
|
|
144
1430
|
*/
|
|
145
|
-
readonly controlled:
|
|
1431
|
+
readonly controlled: OptionalSchema<BooleanSchema<undefined>, undefined>;
|
|
146
1432
|
/**
|
|
147
1433
|
* The default value of the attribute in the user-defined component.
|
|
148
1434
|
* @example
|
|
149
1435
|
* `"/"`
|
|
150
1436
|
*/
|
|
151
|
-
readonly defaultValue:
|
|
1437
|
+
readonly defaultValue: OptionalSchema<StringSchema<undefined>, undefined>;
|
|
152
1438
|
}, undefined>, undefined>, undefined>;
|
|
153
1439
|
}, undefined>;
|
|
154
|
-
declare const CustomComponentNormalizedSchema:
|
|
155
|
-
readonly name:
|
|
156
|
-
readonly as:
|
|
157
|
-
readonly attributes:
|
|
1440
|
+
declare const CustomComponentNormalizedSchema: ObjectSchema<{
|
|
1441
|
+
readonly name: StringSchema<undefined>;
|
|
1442
|
+
readonly as: OptionalSchema<StringSchema<undefined>, undefined>;
|
|
1443
|
+
readonly attributes: OptionalSchema<ArraySchema<ObjectSchema<{
|
|
158
1444
|
/**
|
|
159
1445
|
* The name of the attribute in the user-defined component.
|
|
160
1446
|
* @example
|
|
161
1447
|
* "to"
|
|
162
1448
|
*/
|
|
163
|
-
readonly name:
|
|
1449
|
+
readonly name: StringSchema<undefined>;
|
|
164
1450
|
/**
|
|
165
1451
|
* The name of the attribute in the built-in component.
|
|
166
1452
|
* @example
|
|
167
1453
|
* "href"
|
|
168
1454
|
*/
|
|
169
|
-
readonly as:
|
|
1455
|
+
readonly as: OptionalSchema<StringSchema<undefined>, undefined>;
|
|
170
1456
|
/**
|
|
171
1457
|
* Whether the attribute is controlled or not in the user-defined component.
|
|
172
1458
|
* @example
|
|
173
1459
|
* `true`
|
|
174
1460
|
*/
|
|
175
|
-
readonly controlled:
|
|
1461
|
+
readonly controlled: OptionalSchema<BooleanSchema<undefined>, undefined>;
|
|
176
1462
|
/**
|
|
177
1463
|
* The default value of the attribute in the user-defined component.
|
|
178
1464
|
* @example
|
|
179
1465
|
* `"/"`
|
|
180
1466
|
*/
|
|
181
|
-
readonly defaultValue:
|
|
1467
|
+
readonly defaultValue: OptionalSchema<StringSchema<undefined>, undefined>;
|
|
182
1468
|
}, undefined>, undefined>, readonly []>;
|
|
183
|
-
readonly re:
|
|
184
|
-
readonly selector:
|
|
1469
|
+
readonly re: InstanceSchema<RegExpConstructor, undefined>;
|
|
1470
|
+
readonly selector: OptionalSchema<StringSchema<undefined>, undefined>;
|
|
185
1471
|
}, undefined>;
|
|
186
1472
|
/**
|
|
187
1473
|
* @internal
|
|
188
1474
|
*/
|
|
189
|
-
declare const ESLintReactSettingsSchema:
|
|
1475
|
+
declare const ESLintReactSettingsSchema: ObjectSchema<{
|
|
190
1476
|
/**
|
|
191
1477
|
* The source where React is imported from.
|
|
192
1478
|
* @description This allows to specify a custom import location for React when not using the official distribution.
|
|
193
1479
|
* @default `"react"`
|
|
194
1480
|
* @example `"@pika/react"`
|
|
195
1481
|
*/
|
|
196
|
-
readonly importSource:
|
|
1482
|
+
readonly importSource: OptionalSchema<StringSchema<undefined>, undefined>;
|
|
197
1483
|
/**
|
|
198
1484
|
* The identifier that’s used for JSX Element creation.
|
|
199
1485
|
* @default `"createElement"`
|
|
200
1486
|
* @deprecated
|
|
201
1487
|
*/
|
|
202
|
-
readonly jsxPragma:
|
|
1488
|
+
readonly jsxPragma: OptionalSchema<StringSchema<undefined>, undefined>;
|
|
203
1489
|
/**
|
|
204
1490
|
* The identifier that’s used for JSX fragment elements.
|
|
205
1491
|
* @description This should not be a member expression (i.e. use "Fragment" instead of "React.Fragment").
|
|
206
1492
|
* @default `"Fragment"`
|
|
207
1493
|
* @deprecated
|
|
208
1494
|
*/
|
|
209
|
-
readonly jsxPragmaFrag:
|
|
1495
|
+
readonly jsxPragmaFrag: OptionalSchema<StringSchema<undefined>, undefined>;
|
|
210
1496
|
/**
|
|
211
1497
|
* The name of the prop that is used for polymorphic components.
|
|
212
1498
|
* @description This is used to determine the type of the component.
|
|
213
1499
|
* @example `"as"`
|
|
214
1500
|
*/
|
|
215
|
-
readonly polymorphicPropName:
|
|
1501
|
+
readonly polymorphicPropName: OptionalSchema<StringSchema<undefined>, undefined>;
|
|
216
1502
|
/**
|
|
217
1503
|
* @internal
|
|
218
1504
|
*/
|
|
219
|
-
readonly strict:
|
|
1505
|
+
readonly strict: OptionalSchema<BooleanSchema<undefined>, undefined>;
|
|
220
1506
|
/**
|
|
221
1507
|
* @internal
|
|
222
1508
|
*/
|
|
223
|
-
readonly strictImportCheck:
|
|
1509
|
+
readonly strictImportCheck: OptionalSchema<BooleanSchema<undefined>, undefined>;
|
|
224
1510
|
/**
|
|
225
1511
|
* React version to use, "detect" means auto detect React version from the project’s dependencies.
|
|
226
1512
|
* If `importSource` is specified, an equivalent version of React should be provided here.
|
|
227
1513
|
* @example `"18.3.1"`
|
|
228
1514
|
* @default `"detect"`
|
|
229
1515
|
*/
|
|
230
|
-
readonly version:
|
|
1516
|
+
readonly version: OptionalSchema<StringSchema<undefined>, undefined>;
|
|
231
1517
|
/**
|
|
232
1518
|
* An array of user-defined components
|
|
233
1519
|
* @description This is used to inform the ESLint React plugins how to treat these components during checks.
|
|
234
1520
|
* @example `[{ name: "Link", as: "a", attributes: [{ name: "to", as: "href" }, { name: "rel", defaultValue: "noopener noreferrer" }] }]`
|
|
235
1521
|
*/
|
|
236
|
-
readonly additionalComponents:
|
|
1522
|
+
readonly additionalComponents: OptionalSchema<ArraySchema<ObjectSchema<{
|
|
237
1523
|
/**
|
|
238
1524
|
* The name of the user-defined component.
|
|
239
1525
|
* @example
|
|
240
1526
|
* "Link"
|
|
241
1527
|
*/
|
|
242
|
-
readonly name:
|
|
1528
|
+
readonly name: StringSchema<undefined>;
|
|
243
1529
|
/**
|
|
244
1530
|
* The ESQuery selector to select the component precisely.
|
|
245
1531
|
* @example
|
|
246
1532
|
* `JSXElement:has(JSXAttribute[name.name='component'][value.value='a'])`
|
|
247
1533
|
*/
|
|
248
|
-
readonly selector:
|
|
1534
|
+
readonly selector: OptionalSchema<StringSchema<undefined>, undefined>;
|
|
249
1535
|
/**
|
|
250
1536
|
* The name of the built-in component that the user-defined component represents.
|
|
251
1537
|
* @example
|
|
252
1538
|
* "a"
|
|
253
1539
|
*/
|
|
254
|
-
readonly as:
|
|
1540
|
+
readonly as: OptionalSchema<StringSchema<undefined>, undefined>;
|
|
255
1541
|
/**
|
|
256
1542
|
* Pre-defined attributes that are used in the user-defined component.
|
|
257
1543
|
* @example
|
|
258
1544
|
* `Link` component has a `to` attribute that represents the `href` attribute in the built-in `a` element with a default value of `"/"`.
|
|
259
1545
|
*/
|
|
260
|
-
readonly attributes:
|
|
1546
|
+
readonly attributes: OptionalSchema<ArraySchema<ObjectSchema<{
|
|
261
1547
|
/**
|
|
262
1548
|
* The name of the attribute in the user-defined component.
|
|
263
1549
|
* @example
|
|
264
1550
|
* "to"
|
|
265
1551
|
*/
|
|
266
|
-
readonly name:
|
|
1552
|
+
readonly name: StringSchema<undefined>;
|
|
267
1553
|
/**
|
|
268
1554
|
* The name of the attribute in the built-in component.
|
|
269
1555
|
* @example
|
|
270
1556
|
* "href"
|
|
271
1557
|
*/
|
|
272
|
-
readonly as:
|
|
1558
|
+
readonly as: OptionalSchema<StringSchema<undefined>, undefined>;
|
|
273
1559
|
/**
|
|
274
1560
|
* Whether the attribute is controlled or not in the user-defined component.
|
|
275
1561
|
* @example
|
|
276
1562
|
* `true`
|
|
277
1563
|
*/
|
|
278
|
-
readonly controlled:
|
|
1564
|
+
readonly controlled: OptionalSchema<BooleanSchema<undefined>, undefined>;
|
|
279
1565
|
/**
|
|
280
1566
|
* The default value of the attribute in the user-defined component.
|
|
281
1567
|
* @example
|
|
282
1568
|
* `"/"`
|
|
283
1569
|
*/
|
|
284
|
-
readonly defaultValue:
|
|
1570
|
+
readonly defaultValue: OptionalSchema<StringSchema<undefined>, undefined>;
|
|
285
1571
|
}, undefined>, undefined>, undefined>;
|
|
286
1572
|
}, undefined>, undefined>, undefined>;
|
|
287
1573
|
/**
|
|
@@ -289,128 +1575,128 @@ declare const ESLintReactSettingsSchema: valibot.ObjectSchema<{
|
|
|
289
1575
|
* @description ESLint React will recognize these aliases as equivalent to the built-in hooks in all its rules.
|
|
290
1576
|
* @example `{ useLayoutEffect: ["useIsomorphicLayoutEffect"] }`
|
|
291
1577
|
*/
|
|
292
|
-
readonly additionalHooks:
|
|
293
|
-
readonly use:
|
|
294
|
-
readonly useActionState:
|
|
295
|
-
readonly useCallback:
|
|
296
|
-
readonly useContext:
|
|
297
|
-
readonly useDebugValue:
|
|
298
|
-
readonly useDeferredValue:
|
|
299
|
-
readonly useEffect:
|
|
300
|
-
readonly useFormStatus:
|
|
301
|
-
readonly useId:
|
|
302
|
-
readonly useImperativeHandle:
|
|
303
|
-
readonly useInsertionEffect:
|
|
304
|
-
readonly useLayoutEffect:
|
|
305
|
-
readonly useMemo:
|
|
306
|
-
readonly useOptimistic:
|
|
307
|
-
readonly useReducer:
|
|
308
|
-
readonly useRef:
|
|
309
|
-
readonly useState:
|
|
310
|
-
readonly useSyncExternalStore:
|
|
311
|
-
readonly useTransition:
|
|
1578
|
+
readonly additionalHooks: OptionalSchema<ObjectSchema<{
|
|
1579
|
+
readonly use: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, undefined>;
|
|
1580
|
+
readonly useActionState: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, undefined>;
|
|
1581
|
+
readonly useCallback: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, undefined>;
|
|
1582
|
+
readonly useContext: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, undefined>;
|
|
1583
|
+
readonly useDebugValue: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, undefined>;
|
|
1584
|
+
readonly useDeferredValue: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, undefined>;
|
|
1585
|
+
readonly useEffect: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, undefined>;
|
|
1586
|
+
readonly useFormStatus: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, undefined>;
|
|
1587
|
+
readonly useId: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, undefined>;
|
|
1588
|
+
readonly useImperativeHandle: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, undefined>;
|
|
1589
|
+
readonly useInsertionEffect: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, undefined>;
|
|
1590
|
+
readonly useLayoutEffect: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, undefined>;
|
|
1591
|
+
readonly useMemo: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, undefined>;
|
|
1592
|
+
readonly useOptimistic: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, undefined>;
|
|
1593
|
+
readonly useReducer: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, undefined>;
|
|
1594
|
+
readonly useRef: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, undefined>;
|
|
1595
|
+
readonly useState: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, undefined>;
|
|
1596
|
+
readonly useSyncExternalStore: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, undefined>;
|
|
1597
|
+
readonly useTransition: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, undefined>;
|
|
312
1598
|
}, undefined>, undefined>;
|
|
313
1599
|
}, undefined>;
|
|
314
1600
|
/**
|
|
315
1601
|
* @internal
|
|
316
1602
|
*/
|
|
317
|
-
declare const ESLintSettingsSchema:
|
|
318
|
-
readonly "react-x":
|
|
1603
|
+
declare const ESLintSettingsSchema: OptionalSchema<ObjectSchema<{
|
|
1604
|
+
readonly "react-x": OptionalSchema<ObjectSchema<{
|
|
319
1605
|
/**
|
|
320
1606
|
* The source where React is imported from.
|
|
321
1607
|
* @description This allows to specify a custom import location for React when not using the official distribution.
|
|
322
1608
|
* @default `"react"`
|
|
323
1609
|
* @example `"@pika/react"`
|
|
324
1610
|
*/
|
|
325
|
-
readonly importSource:
|
|
1611
|
+
readonly importSource: OptionalSchema<StringSchema<undefined>, undefined>;
|
|
326
1612
|
/**
|
|
327
1613
|
* The identifier that’s used for JSX Element creation.
|
|
328
1614
|
* @default `"createElement"`
|
|
329
1615
|
* @deprecated
|
|
330
1616
|
*/
|
|
331
|
-
readonly jsxPragma:
|
|
1617
|
+
readonly jsxPragma: OptionalSchema<StringSchema<undefined>, undefined>;
|
|
332
1618
|
/**
|
|
333
1619
|
* The identifier that’s used for JSX fragment elements.
|
|
334
1620
|
* @description This should not be a member expression (i.e. use "Fragment" instead of "React.Fragment").
|
|
335
1621
|
* @default `"Fragment"`
|
|
336
1622
|
* @deprecated
|
|
337
1623
|
*/
|
|
338
|
-
readonly jsxPragmaFrag:
|
|
1624
|
+
readonly jsxPragmaFrag: OptionalSchema<StringSchema<undefined>, undefined>;
|
|
339
1625
|
/**
|
|
340
1626
|
* The name of the prop that is used for polymorphic components.
|
|
341
1627
|
* @description This is used to determine the type of the component.
|
|
342
1628
|
* @example `"as"`
|
|
343
1629
|
*/
|
|
344
|
-
readonly polymorphicPropName:
|
|
1630
|
+
readonly polymorphicPropName: OptionalSchema<StringSchema<undefined>, undefined>;
|
|
345
1631
|
/**
|
|
346
1632
|
* @internal
|
|
347
1633
|
*/
|
|
348
|
-
readonly strict:
|
|
1634
|
+
readonly strict: OptionalSchema<BooleanSchema<undefined>, undefined>;
|
|
349
1635
|
/**
|
|
350
1636
|
* @internal
|
|
351
1637
|
*/
|
|
352
|
-
readonly strictImportCheck:
|
|
1638
|
+
readonly strictImportCheck: OptionalSchema<BooleanSchema<undefined>, undefined>;
|
|
353
1639
|
/**
|
|
354
1640
|
* React version to use, "detect" means auto detect React version from the project’s dependencies.
|
|
355
1641
|
* If `importSource` is specified, an equivalent version of React should be provided here.
|
|
356
1642
|
* @example `"18.3.1"`
|
|
357
1643
|
* @default `"detect"`
|
|
358
1644
|
*/
|
|
359
|
-
readonly version:
|
|
1645
|
+
readonly version: OptionalSchema<StringSchema<undefined>, undefined>;
|
|
360
1646
|
/**
|
|
361
1647
|
* An array of user-defined components
|
|
362
1648
|
* @description This is used to inform the ESLint React plugins how to treat these components during checks.
|
|
363
1649
|
* @example `[{ name: "Link", as: "a", attributes: [{ name: "to", as: "href" }, { name: "rel", defaultValue: "noopener noreferrer" }] }]`
|
|
364
1650
|
*/
|
|
365
|
-
readonly additionalComponents:
|
|
1651
|
+
readonly additionalComponents: OptionalSchema<ArraySchema<ObjectSchema<{
|
|
366
1652
|
/**
|
|
367
1653
|
* The name of the user-defined component.
|
|
368
1654
|
* @example
|
|
369
1655
|
* "Link"
|
|
370
1656
|
*/
|
|
371
|
-
readonly name:
|
|
1657
|
+
readonly name: StringSchema<undefined>;
|
|
372
1658
|
/**
|
|
373
1659
|
* The ESQuery selector to select the component precisely.
|
|
374
1660
|
* @example
|
|
375
1661
|
* `JSXElement:has(JSXAttribute[name.name='component'][value.value='a'])`
|
|
376
1662
|
*/
|
|
377
|
-
readonly selector:
|
|
1663
|
+
readonly selector: OptionalSchema<StringSchema<undefined>, undefined>;
|
|
378
1664
|
/**
|
|
379
1665
|
* The name of the built-in component that the user-defined component represents.
|
|
380
1666
|
* @example
|
|
381
1667
|
* "a"
|
|
382
1668
|
*/
|
|
383
|
-
readonly as:
|
|
1669
|
+
readonly as: OptionalSchema<StringSchema<undefined>, undefined>;
|
|
384
1670
|
/**
|
|
385
1671
|
* Pre-defined attributes that are used in the user-defined component.
|
|
386
1672
|
* @example
|
|
387
1673
|
* `Link` component has a `to` attribute that represents the `href` attribute in the built-in `a` element with a default value of `"/"`.
|
|
388
1674
|
*/
|
|
389
|
-
readonly attributes:
|
|
1675
|
+
readonly attributes: OptionalSchema<ArraySchema<ObjectSchema<{
|
|
390
1676
|
/**
|
|
391
1677
|
* The name of the attribute in the user-defined component.
|
|
392
1678
|
* @example
|
|
393
1679
|
* "to"
|
|
394
1680
|
*/
|
|
395
|
-
readonly name:
|
|
1681
|
+
readonly name: StringSchema<undefined>;
|
|
396
1682
|
/**
|
|
397
1683
|
* The name of the attribute in the built-in component.
|
|
398
1684
|
* @example
|
|
399
1685
|
* "href"
|
|
400
1686
|
*/
|
|
401
|
-
readonly as:
|
|
1687
|
+
readonly as: OptionalSchema<StringSchema<undefined>, undefined>;
|
|
402
1688
|
/**
|
|
403
1689
|
* Whether the attribute is controlled or not in the user-defined component.
|
|
404
1690
|
* @example
|
|
405
1691
|
* `true`
|
|
406
1692
|
*/
|
|
407
|
-
readonly controlled:
|
|
1693
|
+
readonly controlled: OptionalSchema<BooleanSchema<undefined>, undefined>;
|
|
408
1694
|
/**
|
|
409
1695
|
* The default value of the attribute in the user-defined component.
|
|
410
1696
|
* @example
|
|
411
1697
|
* `"/"`
|
|
412
1698
|
*/
|
|
413
|
-
readonly defaultValue:
|
|
1699
|
+
readonly defaultValue: OptionalSchema<StringSchema<undefined>, undefined>;
|
|
414
1700
|
}, undefined>, undefined>, undefined>;
|
|
415
1701
|
}, undefined>, undefined>, undefined>;
|
|
416
1702
|
/**
|
|
@@ -418,125 +1704,125 @@ declare const ESLintSettingsSchema: valibot.OptionalSchema<valibot.ObjectSchema<
|
|
|
418
1704
|
* @description ESLint React will recognize these aliases as equivalent to the built-in hooks in all its rules.
|
|
419
1705
|
* @example `{ useLayoutEffect: ["useIsomorphicLayoutEffect"] }`
|
|
420
1706
|
*/
|
|
421
|
-
readonly additionalHooks:
|
|
422
|
-
readonly use:
|
|
423
|
-
readonly useActionState:
|
|
424
|
-
readonly useCallback:
|
|
425
|
-
readonly useContext:
|
|
426
|
-
readonly useDebugValue:
|
|
427
|
-
readonly useDeferredValue:
|
|
428
|
-
readonly useEffect:
|
|
429
|
-
readonly useFormStatus:
|
|
430
|
-
readonly useId:
|
|
431
|
-
readonly useImperativeHandle:
|
|
432
|
-
readonly useInsertionEffect:
|
|
433
|
-
readonly useLayoutEffect:
|
|
434
|
-
readonly useMemo:
|
|
435
|
-
readonly useOptimistic:
|
|
436
|
-
readonly useReducer:
|
|
437
|
-
readonly useRef:
|
|
438
|
-
readonly useState:
|
|
439
|
-
readonly useSyncExternalStore:
|
|
440
|
-
readonly useTransition:
|
|
1707
|
+
readonly additionalHooks: OptionalSchema<ObjectSchema<{
|
|
1708
|
+
readonly use: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, undefined>;
|
|
1709
|
+
readonly useActionState: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, undefined>;
|
|
1710
|
+
readonly useCallback: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, undefined>;
|
|
1711
|
+
readonly useContext: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, undefined>;
|
|
1712
|
+
readonly useDebugValue: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, undefined>;
|
|
1713
|
+
readonly useDeferredValue: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, undefined>;
|
|
1714
|
+
readonly useEffect: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, undefined>;
|
|
1715
|
+
readonly useFormStatus: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, undefined>;
|
|
1716
|
+
readonly useId: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, undefined>;
|
|
1717
|
+
readonly useImperativeHandle: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, undefined>;
|
|
1718
|
+
readonly useInsertionEffect: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, undefined>;
|
|
1719
|
+
readonly useLayoutEffect: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, undefined>;
|
|
1720
|
+
readonly useMemo: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, undefined>;
|
|
1721
|
+
readonly useOptimistic: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, undefined>;
|
|
1722
|
+
readonly useReducer: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, undefined>;
|
|
1723
|
+
readonly useRef: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, undefined>;
|
|
1724
|
+
readonly useState: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, undefined>;
|
|
1725
|
+
readonly useSyncExternalStore: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, undefined>;
|
|
1726
|
+
readonly useTransition: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, undefined>;
|
|
441
1727
|
}, undefined>, undefined>;
|
|
442
1728
|
}, undefined>, undefined>;
|
|
443
1729
|
/** @deprecated Use `react-x` instead */
|
|
444
|
-
readonly reactOptions:
|
|
1730
|
+
readonly reactOptions: OptionalSchema<ObjectSchema<{
|
|
445
1731
|
/**
|
|
446
1732
|
* The source where React is imported from.
|
|
447
1733
|
* @description This allows to specify a custom import location for React when not using the official distribution.
|
|
448
1734
|
* @default `"react"`
|
|
449
1735
|
* @example `"@pika/react"`
|
|
450
1736
|
*/
|
|
451
|
-
readonly importSource:
|
|
1737
|
+
readonly importSource: OptionalSchema<StringSchema<undefined>, undefined>;
|
|
452
1738
|
/**
|
|
453
1739
|
* The identifier that’s used for JSX Element creation.
|
|
454
1740
|
* @default `"createElement"`
|
|
455
1741
|
* @deprecated
|
|
456
1742
|
*/
|
|
457
|
-
readonly jsxPragma:
|
|
1743
|
+
readonly jsxPragma: OptionalSchema<StringSchema<undefined>, undefined>;
|
|
458
1744
|
/**
|
|
459
1745
|
* The identifier that’s used for JSX fragment elements.
|
|
460
1746
|
* @description This should not be a member expression (i.e. use "Fragment" instead of "React.Fragment").
|
|
461
1747
|
* @default `"Fragment"`
|
|
462
1748
|
* @deprecated
|
|
463
1749
|
*/
|
|
464
|
-
readonly jsxPragmaFrag:
|
|
1750
|
+
readonly jsxPragmaFrag: OptionalSchema<StringSchema<undefined>, undefined>;
|
|
465
1751
|
/**
|
|
466
1752
|
* The name of the prop that is used for polymorphic components.
|
|
467
1753
|
* @description This is used to determine the type of the component.
|
|
468
1754
|
* @example `"as"`
|
|
469
1755
|
*/
|
|
470
|
-
readonly polymorphicPropName:
|
|
1756
|
+
readonly polymorphicPropName: OptionalSchema<StringSchema<undefined>, undefined>;
|
|
471
1757
|
/**
|
|
472
1758
|
* @internal
|
|
473
1759
|
*/
|
|
474
|
-
readonly strict:
|
|
1760
|
+
readonly strict: OptionalSchema<BooleanSchema<undefined>, undefined>;
|
|
475
1761
|
/**
|
|
476
1762
|
* @internal
|
|
477
1763
|
*/
|
|
478
|
-
readonly strictImportCheck:
|
|
1764
|
+
readonly strictImportCheck: OptionalSchema<BooleanSchema<undefined>, undefined>;
|
|
479
1765
|
/**
|
|
480
1766
|
* React version to use, "detect" means auto detect React version from the project’s dependencies.
|
|
481
1767
|
* If `importSource` is specified, an equivalent version of React should be provided here.
|
|
482
1768
|
* @example `"18.3.1"`
|
|
483
1769
|
* @default `"detect"`
|
|
484
1770
|
*/
|
|
485
|
-
readonly version:
|
|
1771
|
+
readonly version: OptionalSchema<StringSchema<undefined>, undefined>;
|
|
486
1772
|
/**
|
|
487
1773
|
* An array of user-defined components
|
|
488
1774
|
* @description This is used to inform the ESLint React plugins how to treat these components during checks.
|
|
489
1775
|
* @example `[{ name: "Link", as: "a", attributes: [{ name: "to", as: "href" }, { name: "rel", defaultValue: "noopener noreferrer" }] }]`
|
|
490
1776
|
*/
|
|
491
|
-
readonly additionalComponents:
|
|
1777
|
+
readonly additionalComponents: OptionalSchema<ArraySchema<ObjectSchema<{
|
|
492
1778
|
/**
|
|
493
1779
|
* The name of the user-defined component.
|
|
494
1780
|
* @example
|
|
495
1781
|
* "Link"
|
|
496
1782
|
*/
|
|
497
|
-
readonly name:
|
|
1783
|
+
readonly name: StringSchema<undefined>;
|
|
498
1784
|
/**
|
|
499
1785
|
* The ESQuery selector to select the component precisely.
|
|
500
1786
|
* @example
|
|
501
1787
|
* `JSXElement:has(JSXAttribute[name.name='component'][value.value='a'])`
|
|
502
1788
|
*/
|
|
503
|
-
readonly selector:
|
|
1789
|
+
readonly selector: OptionalSchema<StringSchema<undefined>, undefined>;
|
|
504
1790
|
/**
|
|
505
1791
|
* The name of the built-in component that the user-defined component represents.
|
|
506
1792
|
* @example
|
|
507
1793
|
* "a"
|
|
508
1794
|
*/
|
|
509
|
-
readonly as:
|
|
1795
|
+
readonly as: OptionalSchema<StringSchema<undefined>, undefined>;
|
|
510
1796
|
/**
|
|
511
1797
|
* Pre-defined attributes that are used in the user-defined component.
|
|
512
1798
|
* @example
|
|
513
1799
|
* `Link` component has a `to` attribute that represents the `href` attribute in the built-in `a` element with a default value of `"/"`.
|
|
514
1800
|
*/
|
|
515
|
-
readonly attributes:
|
|
1801
|
+
readonly attributes: OptionalSchema<ArraySchema<ObjectSchema<{
|
|
516
1802
|
/**
|
|
517
1803
|
* The name of the attribute in the user-defined component.
|
|
518
1804
|
* @example
|
|
519
1805
|
* "to"
|
|
520
1806
|
*/
|
|
521
|
-
readonly name:
|
|
1807
|
+
readonly name: StringSchema<undefined>;
|
|
522
1808
|
/**
|
|
523
1809
|
* The name of the attribute in the built-in component.
|
|
524
1810
|
* @example
|
|
525
1811
|
* "href"
|
|
526
1812
|
*/
|
|
527
|
-
readonly as:
|
|
1813
|
+
readonly as: OptionalSchema<StringSchema<undefined>, undefined>;
|
|
528
1814
|
/**
|
|
529
1815
|
* Whether the attribute is controlled or not in the user-defined component.
|
|
530
1816
|
* @example
|
|
531
1817
|
* `true`
|
|
532
1818
|
*/
|
|
533
|
-
readonly controlled:
|
|
1819
|
+
readonly controlled: OptionalSchema<BooleanSchema<undefined>, undefined>;
|
|
534
1820
|
/**
|
|
535
1821
|
* The default value of the attribute in the user-defined component.
|
|
536
1822
|
* @example
|
|
537
1823
|
* `"/"`
|
|
538
1824
|
*/
|
|
539
|
-
readonly defaultValue:
|
|
1825
|
+
readonly defaultValue: OptionalSchema<StringSchema<undefined>, undefined>;
|
|
540
1826
|
}, undefined>, undefined>, undefined>;
|
|
541
1827
|
}, undefined>, undefined>, undefined>;
|
|
542
1828
|
/**
|
|
@@ -544,26 +1830,26 @@ declare const ESLintSettingsSchema: valibot.OptionalSchema<valibot.ObjectSchema<
|
|
|
544
1830
|
* @description ESLint React will recognize these aliases as equivalent to the built-in hooks in all its rules.
|
|
545
1831
|
* @example `{ useLayoutEffect: ["useIsomorphicLayoutEffect"] }`
|
|
546
1832
|
*/
|
|
547
|
-
readonly additionalHooks:
|
|
548
|
-
readonly use:
|
|
549
|
-
readonly useActionState:
|
|
550
|
-
readonly useCallback:
|
|
551
|
-
readonly useContext:
|
|
552
|
-
readonly useDebugValue:
|
|
553
|
-
readonly useDeferredValue:
|
|
554
|
-
readonly useEffect:
|
|
555
|
-
readonly useFormStatus:
|
|
556
|
-
readonly useId:
|
|
557
|
-
readonly useImperativeHandle:
|
|
558
|
-
readonly useInsertionEffect:
|
|
559
|
-
readonly useLayoutEffect:
|
|
560
|
-
readonly useMemo:
|
|
561
|
-
readonly useOptimistic:
|
|
562
|
-
readonly useReducer:
|
|
563
|
-
readonly useRef:
|
|
564
|
-
readonly useState:
|
|
565
|
-
readonly useSyncExternalStore:
|
|
566
|
-
readonly useTransition:
|
|
1833
|
+
readonly additionalHooks: OptionalSchema<ObjectSchema<{
|
|
1834
|
+
readonly use: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, undefined>;
|
|
1835
|
+
readonly useActionState: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, undefined>;
|
|
1836
|
+
readonly useCallback: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, undefined>;
|
|
1837
|
+
readonly useContext: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, undefined>;
|
|
1838
|
+
readonly useDebugValue: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, undefined>;
|
|
1839
|
+
readonly useDeferredValue: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, undefined>;
|
|
1840
|
+
readonly useEffect: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, undefined>;
|
|
1841
|
+
readonly useFormStatus: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, undefined>;
|
|
1842
|
+
readonly useId: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, undefined>;
|
|
1843
|
+
readonly useImperativeHandle: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, undefined>;
|
|
1844
|
+
readonly useInsertionEffect: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, undefined>;
|
|
1845
|
+
readonly useLayoutEffect: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, undefined>;
|
|
1846
|
+
readonly useMemo: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, undefined>;
|
|
1847
|
+
readonly useOptimistic: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, undefined>;
|
|
1848
|
+
readonly useReducer: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, undefined>;
|
|
1849
|
+
readonly useRef: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, undefined>;
|
|
1850
|
+
readonly useState: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, undefined>;
|
|
1851
|
+
readonly useSyncExternalStore: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, undefined>;
|
|
1852
|
+
readonly useTransition: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, undefined>;
|
|
567
1853
|
}, undefined>, undefined>;
|
|
568
1854
|
}, undefined>, undefined>;
|
|
569
1855
|
}, undefined>, {}>;
|
|
@@ -583,6 +1869,339 @@ interface ESLintReactSettingsNormalized extends ESLintReactSettings {
|
|
|
583
1869
|
version: string;
|
|
584
1870
|
}
|
|
585
1871
|
|
|
1872
|
+
declare const normalizedSettingsCache: WeakMap<{
|
|
1873
|
+
importSource?: string;
|
|
1874
|
+
jsxPragma?: string;
|
|
1875
|
+
jsxPragmaFrag?: string;
|
|
1876
|
+
polymorphicPropName?: string;
|
|
1877
|
+
strict?: boolean;
|
|
1878
|
+
strictImportCheck?: boolean;
|
|
1879
|
+
version?: string;
|
|
1880
|
+
additionalComponents?: {
|
|
1881
|
+
name: string;
|
|
1882
|
+
as?: string;
|
|
1883
|
+
selector?: string;
|
|
1884
|
+
attributes?: {
|
|
1885
|
+
name: string;
|
|
1886
|
+
as?: string;
|
|
1887
|
+
controlled?: boolean;
|
|
1888
|
+
defaultValue?: string;
|
|
1889
|
+
}[];
|
|
1890
|
+
}[];
|
|
1891
|
+
additionalHooks?: {
|
|
1892
|
+
use?: string[];
|
|
1893
|
+
useActionState?: string[];
|
|
1894
|
+
useCallback?: string[];
|
|
1895
|
+
useContext?: string[];
|
|
1896
|
+
useDebugValue?: string[];
|
|
1897
|
+
useDeferredValue?: string[];
|
|
1898
|
+
useEffect?: string[];
|
|
1899
|
+
useFormStatus?: string[];
|
|
1900
|
+
useId?: string[];
|
|
1901
|
+
useImperativeHandle?: string[];
|
|
1902
|
+
useInsertionEffect?: string[];
|
|
1903
|
+
useLayoutEffect?: string[];
|
|
1904
|
+
useMemo?: string[];
|
|
1905
|
+
useOptimistic?: string[];
|
|
1906
|
+
useReducer?: string[];
|
|
1907
|
+
useRef?: string[];
|
|
1908
|
+
useState?: string[];
|
|
1909
|
+
useSyncExternalStore?: string[];
|
|
1910
|
+
useTransition?: string[];
|
|
1911
|
+
};
|
|
1912
|
+
}, ESLintReactSettingsNormalized>;
|
|
1913
|
+
|
|
1914
|
+
/**
|
|
1915
|
+
* The NPM scope for this project.
|
|
1916
|
+
*/
|
|
1917
|
+
declare const NPM_SCOPE = "@eslint-react";
|
|
1918
|
+
/**
|
|
1919
|
+
* The GitHub repository for this project.
|
|
1920
|
+
*/
|
|
1921
|
+
declare const GITHUB_URL = "https://github.com/rEl1cx/eslint-react";
|
|
1922
|
+
/**
|
|
1923
|
+
* The URL to the project's website.
|
|
1924
|
+
*/
|
|
1925
|
+
declare const WEBSITE_URL = "https://eslint-react.xyz";
|
|
1926
|
+
/**
|
|
1927
|
+
* Regular expression for matching a PascalCase string.
|
|
1928
|
+
*/
|
|
1929
|
+
declare const RE_PASCAL_CASE: RegExp;
|
|
1930
|
+
/**
|
|
1931
|
+
* Regular expression for matching a camelCase string.
|
|
1932
|
+
*/
|
|
1933
|
+
declare const RE_CAMEL_CASE: RegExp;
|
|
1934
|
+
/**
|
|
1935
|
+
* Regular expression for matching a kebab-case string.
|
|
1936
|
+
*/
|
|
1937
|
+
declare const RE_KEBAB_CASE: RegExp;
|
|
1938
|
+
/**
|
|
1939
|
+
* Regular expression for matching a snake_case string.
|
|
1940
|
+
*/
|
|
1941
|
+
declare const RE_SNAKE_CASE: RegExp;
|
|
1942
|
+
/**
|
|
1943
|
+
* Regular expression for matching a CONSTANT_CASE string.
|
|
1944
|
+
*/
|
|
1945
|
+
declare const RE_CONSTANT_CASE: RegExp;
|
|
1946
|
+
declare const RE_JAVASCRIPT_PROTOCOL: RegExp;
|
|
1947
|
+
/**
|
|
1948
|
+
* @internal
|
|
1949
|
+
*/
|
|
1950
|
+
declare const DOM_HTML_COMPONENT_TYPES: readonly ["aside", "audio", "b", "base", "bdi", "bdo", "blockquote", "body", "br", "button", "canvas", "caption", "cite", "code", "col", "colgroup", "data", "datalist", "dd", "del", "details", "dfn", "dialog", "div", "dl", "dt", "em", "embed", "fieldset", "figcaption", "figure", "footer", "form", "h1", "head", "header", "hgroup", "hr", "html", "i", "iframe", "img", "input", "ins", "kbd", "label", "legend", "li", "link", "main", "map", "mark", "menu", "meta", "meter", "nav", "noscript", "object", "ol", "optgroup", "option", "output", "p", "picture", "pre", "progress", "q", "rp", "rt", "ruby", "s", "samp", "script", "section", "select", "slot", "small", "source", "span", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "time", "title", "tr", "track", "u", "ul", "var", "video", "wbr"];
|
|
1951
|
+
/**
|
|
1952
|
+
* @internal
|
|
1953
|
+
*/
|
|
1954
|
+
declare const DOM_SVG_COMPONENT_TYPES: readonly ["a", "animate", "animateMotion", "animateTransform", "circle", "clipPath", "defs", "desc", "discard", "ellipse", "feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feDropShadow", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence", "filter", "foreignObject", "g", "hatch", "hatchpath", "image", "line", "linearGradient", "marker", "mask", "metadata", "mpath", "path", "pattern", "polygon", "polyline", "radialGradient", "rect", "script", "set", "stop", "style", "svg", "switch", "symbol", "text", "textPath", "title", "tspan", "use", "view"];
|
|
1955
|
+
declare const REACT_BUILD_IN_HOOKS: readonly ["use", "useActionState", "useCallback", "useContext", "useDebugValue", "useDeferredValue", "useEffect", "useFormStatus", "useId", "useImperativeHandle", "useInsertionEffect", "useLayoutEffect", "useMemo", "useOptimistic", "useReducer", "useRef", "useState", "useSyncExternalStore", "useTransition"];
|
|
1956
|
+
|
|
1957
|
+
/**
|
|
1958
|
+
* Get the ESLint rule creator for a plugin.
|
|
1959
|
+
* @internal
|
|
1960
|
+
* @param pluginName The name of the plugin.
|
|
1961
|
+
* @returns The ESLint rule creator.
|
|
1962
|
+
*/
|
|
1963
|
+
declare const createRuleForPlugin: (pluginName: string) => <Options extends readonly unknown[], MessageIds extends string>({ meta, name, ...rule }: Readonly<ESLintUtils.RuleWithMetaAndName<Options, MessageIds, unknown>>) => ESLintUtils.RuleModule<MessageIds, Options, unknown, ESLintUtils.RuleListener>;
|
|
1964
|
+
|
|
1965
|
+
declare function getReactVersion(at?: string): E.Either<string, unknown>;
|
|
1966
|
+
|
|
1967
|
+
interface Dictionary<Type> {
|
|
1968
|
+
[key: string]: Type;
|
|
1969
|
+
[index: number]: Type;
|
|
1970
|
+
}
|
|
1971
|
+
|
|
1972
|
+
type AnyFn = (...args: any[]) => any;
|
|
1973
|
+
|
|
1974
|
+
type Key = any[];
|
|
1975
|
+
type RawKey = Key | IArguments;
|
|
1976
|
+
type Value = any;
|
|
1977
|
+
|
|
1978
|
+
interface CacheSnapshot {
|
|
1979
|
+
keys: Key[];
|
|
1980
|
+
size: number;
|
|
1981
|
+
values: Value[];
|
|
1982
|
+
}
|
|
1983
|
+
|
|
1984
|
+
declare class Cache<Fn extends AnyFn> {
|
|
1985
|
+
readonly canTransformKey: boolean;
|
|
1986
|
+
readonly getKeyIndex: KeyIndexGetter;
|
|
1987
|
+
readonly options: NormalizedOptions<Fn>;
|
|
1988
|
+
readonly shouldCloneArguments: boolean;
|
|
1989
|
+
readonly shouldUpdateOnAdd: boolean;
|
|
1990
|
+
readonly shouldUpdateOnChange: boolean;
|
|
1991
|
+
readonly shouldUpdateOnHit: boolean;
|
|
1992
|
+
|
|
1993
|
+
/**
|
|
1994
|
+
* The prevents call arguments which have cached results.
|
|
1995
|
+
*/
|
|
1996
|
+
keys: Key[];
|
|
1997
|
+
/**
|
|
1998
|
+
* The results of previous cached calls.
|
|
1999
|
+
*/
|
|
2000
|
+
values: Value[];
|
|
2001
|
+
|
|
2002
|
+
constructor(options: NormalizedOptions<Fn>);
|
|
2003
|
+
|
|
2004
|
+
/**
|
|
2005
|
+
* The number of cached [key,value] results.
|
|
2006
|
+
*/
|
|
2007
|
+
get size(): number;
|
|
2008
|
+
|
|
2009
|
+
/**
|
|
2010
|
+
* A copy of the cache at a moment in time. This is useful
|
|
2011
|
+
* to compare changes over time, since the cache mutates
|
|
2012
|
+
* internally for performance reasons.
|
|
2013
|
+
*/
|
|
2014
|
+
get snapshot(): CacheSnapshot;
|
|
2015
|
+
|
|
2016
|
+
/**
|
|
2017
|
+
* Order the array based on a Least-Recently-Used basis.
|
|
2018
|
+
*/
|
|
2019
|
+
orderByLru(key: Key, value: Value, startingIndex: number): void;
|
|
2020
|
+
|
|
2021
|
+
/**
|
|
2022
|
+
* Update the promise method to auto-remove from cache if rejected, and
|
|
2023
|
+
* if resolved then fire cache hit / changed.
|
|
2024
|
+
*/
|
|
2025
|
+
updateAsyncCache(memoized: Memoized<Fn>): void;
|
|
2026
|
+
}
|
|
2027
|
+
|
|
2028
|
+
type EqualityComparator = (object1: any, object2: any) => boolean;
|
|
2029
|
+
|
|
2030
|
+
type MatchingKeyComparator = (key1: Key, key2: RawKey) => boolean;
|
|
2031
|
+
|
|
2032
|
+
type CacheModifiedHandler<Fn extends AnyFn> = (
|
|
2033
|
+
cache: Cache<Fn>,
|
|
2034
|
+
options: NormalizedOptions<Fn>,
|
|
2035
|
+
memoized: Memoized<Fn>,
|
|
2036
|
+
) => void;
|
|
2037
|
+
|
|
2038
|
+
type KeyTransformer = (args: Key) => Key;
|
|
2039
|
+
|
|
2040
|
+
type KeyIndexGetter = (keyToMatch: RawKey) => number;
|
|
2041
|
+
|
|
2042
|
+
interface StandardOptions<Fn extends AnyFn> {
|
|
2043
|
+
isEqual?: EqualityComparator;
|
|
2044
|
+
isMatchingKey?: MatchingKeyComparator;
|
|
2045
|
+
isPromise?: boolean;
|
|
2046
|
+
maxSize?: number;
|
|
2047
|
+
onCacheAdd?: CacheModifiedHandler<Fn>;
|
|
2048
|
+
onCacheChange?: CacheModifiedHandler<Fn>;
|
|
2049
|
+
onCacheHit?: CacheModifiedHandler<Fn>;
|
|
2050
|
+
transformKey?: KeyTransformer;
|
|
2051
|
+
}
|
|
2052
|
+
|
|
2053
|
+
interface Options<Fn extends AnyFn>
|
|
2054
|
+
extends StandardOptions<Fn>,
|
|
2055
|
+
Dictionary<any> {}
|
|
2056
|
+
|
|
2057
|
+
interface NormalizedOptions<Fn extends AnyFn> extends Options<Fn> {
|
|
2058
|
+
isEqual: EqualityComparator;
|
|
2059
|
+
isPromise: boolean;
|
|
2060
|
+
maxSize: number;
|
|
2061
|
+
}
|
|
2062
|
+
|
|
2063
|
+
type Memoized<Fn extends AnyFn> = Fn &
|
|
2064
|
+
Dictionary<any> & {
|
|
2065
|
+
cache: Cache<Fn>;
|
|
2066
|
+
fn: Fn;
|
|
2067
|
+
isMemoized: true;
|
|
2068
|
+
options: NormalizedOptions<Fn>;
|
|
2069
|
+
};
|
|
2070
|
+
|
|
2071
|
+
/**
|
|
2072
|
+
Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
|
|
2073
|
+
|
|
2074
|
+
@category Type
|
|
2075
|
+
*/
|
|
2076
|
+
type Primitive =
|
|
2077
|
+
| null
|
|
2078
|
+
| undefined
|
|
2079
|
+
| string
|
|
2080
|
+
| number
|
|
2081
|
+
| boolean
|
|
2082
|
+
| symbol
|
|
2083
|
+
| bigint;
|
|
2084
|
+
|
|
2085
|
+
declare global {
|
|
2086
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
|
|
2087
|
+
interface SymbolConstructor {
|
|
2088
|
+
readonly observable: symbol;
|
|
2089
|
+
}
|
|
2090
|
+
}
|
|
2091
|
+
|
|
2092
|
+
/**
|
|
2093
|
+
Matches any primitive, `void`, `Date`, or `RegExp` value.
|
|
2094
|
+
*/
|
|
2095
|
+
type BuiltIns = Primitive | void | Date | RegExp;
|
|
2096
|
+
|
|
2097
|
+
/**
|
|
2098
|
+
@see PartialDeep
|
|
2099
|
+
*/
|
|
2100
|
+
type PartialDeepOptions = {
|
|
2101
|
+
/**
|
|
2102
|
+
Whether to affect the individual elements of arrays and tuples.
|
|
2103
|
+
|
|
2104
|
+
@default false
|
|
2105
|
+
*/
|
|
2106
|
+
readonly recurseIntoArrays?: boolean;
|
|
2107
|
+
};
|
|
2108
|
+
|
|
2109
|
+
/**
|
|
2110
|
+
Create a type from another type with all keys and nested keys set to optional.
|
|
2111
|
+
|
|
2112
|
+
Use-cases:
|
|
2113
|
+
- Merging a default settings/config object with another object, the second object would be a deep partial of the default object.
|
|
2114
|
+
- Mocking and testing complex entities, where populating an entire object with its keys would be redundant in terms of the mock or test.
|
|
2115
|
+
|
|
2116
|
+
@example
|
|
2117
|
+
```
|
|
2118
|
+
import type {PartialDeep} from 'type-fest';
|
|
2119
|
+
|
|
2120
|
+
const settings: Settings = {
|
|
2121
|
+
textEditor: {
|
|
2122
|
+
fontSize: 14;
|
|
2123
|
+
fontColor: '#000000';
|
|
2124
|
+
fontWeight: 400;
|
|
2125
|
+
}
|
|
2126
|
+
autocomplete: false;
|
|
2127
|
+
autosave: true;
|
|
2128
|
+
};
|
|
2129
|
+
|
|
2130
|
+
const applySavedSettings = (savedSettings: PartialDeep<Settings>) => {
|
|
2131
|
+
return {...settings, ...savedSettings};
|
|
2132
|
+
}
|
|
2133
|
+
|
|
2134
|
+
settings = applySavedSettings({textEditor: {fontWeight: 500}});
|
|
2135
|
+
```
|
|
2136
|
+
|
|
2137
|
+
By default, this does not affect elements in array and tuple types. You can change this by passing `{recurseIntoArrays: true}` as the second type argument:
|
|
2138
|
+
|
|
2139
|
+
```
|
|
2140
|
+
import type {PartialDeep} from 'type-fest';
|
|
2141
|
+
|
|
2142
|
+
interface Settings {
|
|
2143
|
+
languages: string[];
|
|
2144
|
+
}
|
|
2145
|
+
|
|
2146
|
+
const partialSettings: PartialDeep<Settings, {recurseIntoArrays: true}> = {
|
|
2147
|
+
languages: [undefined]
|
|
2148
|
+
};
|
|
2149
|
+
```
|
|
2150
|
+
|
|
2151
|
+
@category Object
|
|
2152
|
+
@category Array
|
|
2153
|
+
@category Set
|
|
2154
|
+
@category Map
|
|
2155
|
+
*/
|
|
2156
|
+
type PartialDeep<T, Options extends PartialDeepOptions = {}> = T extends BuiltIns | (((...arguments_: any[]) => unknown)) | (new (...arguments_: any[]) => unknown)
|
|
2157
|
+
? T
|
|
2158
|
+
: T extends Map<infer KeyType, infer ValueType>
|
|
2159
|
+
? PartialMapDeep<KeyType, ValueType, Options>
|
|
2160
|
+
: T extends Set<infer ItemType>
|
|
2161
|
+
? PartialSetDeep<ItemType, Options>
|
|
2162
|
+
: T extends ReadonlyMap<infer KeyType, infer ValueType>
|
|
2163
|
+
? PartialReadonlyMapDeep<KeyType, ValueType, Options>
|
|
2164
|
+
: T extends ReadonlySet<infer ItemType>
|
|
2165
|
+
? PartialReadonlySetDeep<ItemType, Options>
|
|
2166
|
+
: T extends object
|
|
2167
|
+
? T extends ReadonlyArray<infer ItemType> // Test for arrays/tuples, per https://github.com/microsoft/TypeScript/issues/35156
|
|
2168
|
+
? Options['recurseIntoArrays'] extends true
|
|
2169
|
+
? ItemType[] extends T // Test for arrays (non-tuples) specifically
|
|
2170
|
+
? readonly ItemType[] extends T // Differentiate readonly and mutable arrays
|
|
2171
|
+
? ReadonlyArray<PartialDeep<ItemType | undefined, Options>>
|
|
2172
|
+
: Array<PartialDeep<ItemType | undefined, Options>>
|
|
2173
|
+
: PartialObjectDeep<T, Options> // Tuples behave properly
|
|
2174
|
+
: T // If they don't opt into array testing, just use the original type
|
|
2175
|
+
: PartialObjectDeep<T, Options>
|
|
2176
|
+
: unknown;
|
|
2177
|
+
|
|
2178
|
+
/**
|
|
2179
|
+
Same as `PartialDeep`, but accepts only `Map`s and as inputs. Internal helper for `PartialDeep`.
|
|
2180
|
+
*/
|
|
2181
|
+
type PartialMapDeep<KeyType, ValueType, Options extends PartialDeepOptions> = {} & Map<PartialDeep<KeyType, Options>, PartialDeep<ValueType, Options>>;
|
|
2182
|
+
|
|
2183
|
+
/**
|
|
2184
|
+
Same as `PartialDeep`, but accepts only `Set`s as inputs. Internal helper for `PartialDeep`.
|
|
2185
|
+
*/
|
|
2186
|
+
type PartialSetDeep<T, Options extends PartialDeepOptions> = {} & Set<PartialDeep<T, Options>>;
|
|
2187
|
+
|
|
2188
|
+
/**
|
|
2189
|
+
Same as `PartialDeep`, but accepts only `ReadonlyMap`s as inputs. Internal helper for `PartialDeep`.
|
|
2190
|
+
*/
|
|
2191
|
+
type PartialReadonlyMapDeep<KeyType, ValueType, Options extends PartialDeepOptions> = {} & ReadonlyMap<PartialDeep<KeyType, Options>, PartialDeep<ValueType, Options>>;
|
|
2192
|
+
|
|
2193
|
+
/**
|
|
2194
|
+
Same as `PartialDeep`, but accepts only `ReadonlySet`s as inputs. Internal helper for `PartialDeep`.
|
|
2195
|
+
*/
|
|
2196
|
+
type PartialReadonlySetDeep<T, Options extends PartialDeepOptions> = {} & ReadonlySet<PartialDeep<T, Options>>;
|
|
2197
|
+
|
|
2198
|
+
/**
|
|
2199
|
+
Same as `PartialDeep`, but accepts only `object`s as inputs. Internal helper for `PartialDeep`.
|
|
2200
|
+
*/
|
|
2201
|
+
type PartialObjectDeep<ObjectType extends object, Options extends PartialDeepOptions> = {
|
|
2202
|
+
[KeyType in keyof ObjectType]?: PartialDeep<ObjectType[KeyType], Options>
|
|
2203
|
+
};
|
|
2204
|
+
|
|
586
2205
|
/**
|
|
587
2206
|
* The default ESLint settings for "react-x".
|
|
588
2207
|
*/
|
|
@@ -595,11 +2214,26 @@ declare const DEFAULT_ESLINT_REACT_SETTINGS: {
|
|
|
595
2214
|
readonly version: "detect";
|
|
596
2215
|
};
|
|
597
2216
|
/**
|
|
598
|
-
*
|
|
599
|
-
* @
|
|
600
|
-
* @param
|
|
601
|
-
* @returns The
|
|
2217
|
+
* Unsafely casts settings from a data object from `context.settings`.
|
|
2218
|
+
* @internal
|
|
2219
|
+
* @param data The data object.
|
|
2220
|
+
* @returns settings The settings.
|
|
2221
|
+
*/
|
|
2222
|
+
declare function unsafeDecodeSettings(data: unknown): PartialDeep<ESLintReactSettings>;
|
|
2223
|
+
/**
|
|
2224
|
+
* Decodes settings from a data object from `context.settings`.
|
|
2225
|
+
* @internal
|
|
2226
|
+
* @param data The data object.
|
|
2227
|
+
* @returns settings The settings.
|
|
2228
|
+
*/
|
|
2229
|
+
declare const decodeSettings: Memoized<(data: unknown) => ESLintReactSettings>;
|
|
2230
|
+
/**
|
|
2231
|
+
* Normalizes the settings by converting all shorthand properties to their full form.
|
|
2232
|
+
* @param settings The settings.
|
|
2233
|
+
* @returns The normalized settings.
|
|
2234
|
+
* @internal
|
|
602
2235
|
*/
|
|
2236
|
+
declare const normalizeSettings: Memoized<(settings: ESLintReactSettings) => ESLintReactSettingsNormalized>;
|
|
603
2237
|
declare function getSettingsFromContext(context: {
|
|
604
2238
|
settings: unknown;
|
|
605
2239
|
}): ESLintReactSettingsNormalized;
|
|
@@ -615,4 +2249,6 @@ declare module "@typescript-eslint/utils/ts-eslint" {
|
|
|
615
2249
|
}
|
|
616
2250
|
}
|
|
617
2251
|
|
|
618
|
-
|
|
2252
|
+
declare function tryRequire(id: string, at?: string): E.Either<unknown, Error>;
|
|
2253
|
+
|
|
2254
|
+
export { type CustomAttribute, CustomAttributeSchema, type CustomComponent, type CustomComponentNormalized, CustomComponentNormalizedSchema, CustomComponentSchema, type CustomHook, CustomHookSchema, DEFAULT_ESLINT_REACT_SETTINGS, DOM_HTML_COMPONENT_TYPES, DOM_SVG_COMPONENT_TYPES, type ESLintReactSettings, type ESLintReactSettingsNormalized, ESLintReactSettingsSchema, type ESLintSettings, ESLintSettingsSchema, GITHUB_URL, NPM_SCOPE, REACT_BUILD_IN_HOOKS, RE_CAMEL_CASE, RE_CONSTANT_CASE, RE_JAVASCRIPT_PROTOCOL, RE_KEBAB_CASE, RE_PASCAL_CASE, RE_SNAKE_CASE, WEBSITE_URL, createRuleForPlugin, decodeSettings, defineSettings, getReactVersion, getSettingsFromContext, normalizeSettings, normalizedSettingsCache, tryRequire, unsafeDecodeSettings };
|