@eslint-react/shared 1.12.1 → 1.12.2-beta.1
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 +298 -168
- package/dist/index.d.ts +298 -168
- package/dist/index.js +60 -37
- package/dist/index.mjs +58 -36
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -165,6 +165,66 @@ declare function boolean(): BooleanSchema<undefined>;
|
|
|
165
165
|
*/
|
|
166
166
|
declare function boolean<const TMessage extends ErrorMessage<BooleanIssue> | undefined>(message: TMessage): BooleanSchema<TMessage>;
|
|
167
167
|
|
|
168
|
+
/**
|
|
169
|
+
* Class type.
|
|
170
|
+
*/
|
|
171
|
+
type Class = new (...args: any[]) => any;
|
|
172
|
+
/**
|
|
173
|
+
* Instance issue type.
|
|
174
|
+
*/
|
|
175
|
+
interface InstanceIssue extends BaseIssue<unknown> {
|
|
176
|
+
/**
|
|
177
|
+
* The issue kind.
|
|
178
|
+
*/
|
|
179
|
+
readonly kind: 'schema';
|
|
180
|
+
/**
|
|
181
|
+
* The issue type.
|
|
182
|
+
*/
|
|
183
|
+
readonly type: 'instance';
|
|
184
|
+
/**
|
|
185
|
+
* The expected property.
|
|
186
|
+
*/
|
|
187
|
+
readonly expected: string;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Instance schema type.
|
|
191
|
+
*/
|
|
192
|
+
interface InstanceSchema<TClass extends Class, TMessage extends ErrorMessage<InstanceIssue> | undefined> extends BaseSchema<InstanceType<TClass>, InstanceType<TClass>, InstanceIssue> {
|
|
193
|
+
/**
|
|
194
|
+
* The schema type.
|
|
195
|
+
*/
|
|
196
|
+
readonly type: 'instance';
|
|
197
|
+
/**
|
|
198
|
+
* The schema reference.
|
|
199
|
+
*/
|
|
200
|
+
readonly reference: typeof instance;
|
|
201
|
+
/**
|
|
202
|
+
* The class of the instance.
|
|
203
|
+
*/
|
|
204
|
+
readonly class: TClass;
|
|
205
|
+
/**
|
|
206
|
+
* The error message.
|
|
207
|
+
*/
|
|
208
|
+
readonly message: TMessage;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Creates an instance schema.
|
|
212
|
+
*
|
|
213
|
+
* @param class_ The class of the instance.
|
|
214
|
+
*
|
|
215
|
+
* @returns An instance schema.
|
|
216
|
+
*/
|
|
217
|
+
declare function instance<TClass extends Class>(class_: TClass): InstanceSchema<TClass, undefined>;
|
|
218
|
+
/**
|
|
219
|
+
* Creates an instance schema.
|
|
220
|
+
*
|
|
221
|
+
* @param class_ The class of the instance.
|
|
222
|
+
* @param message The error message.
|
|
223
|
+
*
|
|
224
|
+
* @returns An instance schema.
|
|
225
|
+
*/
|
|
226
|
+
declare function instance<TClass extends Class, const TMessage extends ErrorMessage<InstanceIssue> | undefined>(class_: TClass, message: TMessage): InstanceSchema<TClass, TMessage>;
|
|
227
|
+
|
|
168
228
|
/**
|
|
169
229
|
* Infer nullish output type.
|
|
170
230
|
*/
|
|
@@ -418,6 +478,59 @@ declare function optionalAsync<const TWrapped extends BaseSchema<unknown, unknow
|
|
|
418
478
|
*/
|
|
419
479
|
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>;
|
|
420
480
|
|
|
481
|
+
/**
|
|
482
|
+
* String issue type.
|
|
483
|
+
*/
|
|
484
|
+
interface StringIssue extends BaseIssue<unknown> {
|
|
485
|
+
/**
|
|
486
|
+
* The issue kind.
|
|
487
|
+
*/
|
|
488
|
+
readonly kind: 'schema';
|
|
489
|
+
/**
|
|
490
|
+
* The issue type.
|
|
491
|
+
*/
|
|
492
|
+
readonly type: 'string';
|
|
493
|
+
/**
|
|
494
|
+
* The expected property.
|
|
495
|
+
*/
|
|
496
|
+
readonly expected: 'string';
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* String schema type.
|
|
500
|
+
*/
|
|
501
|
+
interface StringSchema<TMessage extends ErrorMessage<StringIssue> | undefined> extends BaseSchema<string, string, StringIssue> {
|
|
502
|
+
/**
|
|
503
|
+
* The schema type.
|
|
504
|
+
*/
|
|
505
|
+
readonly type: 'string';
|
|
506
|
+
/**
|
|
507
|
+
* The schema reference.
|
|
508
|
+
*/
|
|
509
|
+
readonly reference: typeof string;
|
|
510
|
+
/**
|
|
511
|
+
* The expected property.
|
|
512
|
+
*/
|
|
513
|
+
readonly expects: 'string';
|
|
514
|
+
/**
|
|
515
|
+
* The error message.
|
|
516
|
+
*/
|
|
517
|
+
readonly message: TMessage;
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
520
|
+
* Creates a string schema.
|
|
521
|
+
*
|
|
522
|
+
* @returns A string schema.
|
|
523
|
+
*/
|
|
524
|
+
declare function string(): StringSchema<undefined>;
|
|
525
|
+
/**
|
|
526
|
+
* Creates a string schema.
|
|
527
|
+
*
|
|
528
|
+
* @param message The error message.
|
|
529
|
+
*
|
|
530
|
+
* @returns A string schema.
|
|
531
|
+
*/
|
|
532
|
+
declare function string<const TMessage extends ErrorMessage<StringIssue> | undefined>(message: TMessage): StringSchema<TMessage>;
|
|
533
|
+
|
|
421
534
|
/**
|
|
422
535
|
* Schema with pipe type.
|
|
423
536
|
*/
|
|
@@ -490,59 +603,6 @@ type SchemaWithPipeAsync<TPipe extends [
|
|
|
490
603
|
};
|
|
491
604
|
};
|
|
492
605
|
|
|
493
|
-
/**
|
|
494
|
-
* String issue type.
|
|
495
|
-
*/
|
|
496
|
-
interface StringIssue extends BaseIssue<unknown> {
|
|
497
|
-
/**
|
|
498
|
-
* The issue kind.
|
|
499
|
-
*/
|
|
500
|
-
readonly kind: 'schema';
|
|
501
|
-
/**
|
|
502
|
-
* The issue type.
|
|
503
|
-
*/
|
|
504
|
-
readonly type: 'string';
|
|
505
|
-
/**
|
|
506
|
-
* The expected property.
|
|
507
|
-
*/
|
|
508
|
-
readonly expected: 'string';
|
|
509
|
-
}
|
|
510
|
-
/**
|
|
511
|
-
* String schema type.
|
|
512
|
-
*/
|
|
513
|
-
interface StringSchema<TMessage extends ErrorMessage<StringIssue> | undefined> extends BaseSchema<string, string, StringIssue> {
|
|
514
|
-
/**
|
|
515
|
-
* The schema type.
|
|
516
|
-
*/
|
|
517
|
-
readonly type: 'string';
|
|
518
|
-
/**
|
|
519
|
-
* The schema reference.
|
|
520
|
-
*/
|
|
521
|
-
readonly reference: typeof string;
|
|
522
|
-
/**
|
|
523
|
-
* The expected property.
|
|
524
|
-
*/
|
|
525
|
-
readonly expects: 'string';
|
|
526
|
-
/**
|
|
527
|
-
* The error message.
|
|
528
|
-
*/
|
|
529
|
-
readonly message: TMessage;
|
|
530
|
-
}
|
|
531
|
-
/**
|
|
532
|
-
* Creates a string schema.
|
|
533
|
-
*
|
|
534
|
-
* @returns A string schema.
|
|
535
|
-
*/
|
|
536
|
-
declare function string(): StringSchema<undefined>;
|
|
537
|
-
/**
|
|
538
|
-
* Creates a string schema.
|
|
539
|
-
*
|
|
540
|
-
* @param message The error message.
|
|
541
|
-
*
|
|
542
|
-
* @returns A string schema.
|
|
543
|
-
*/
|
|
544
|
-
declare function string<const TMessage extends ErrorMessage<StringIssue> | undefined>(message: TMessage): StringSchema<TMessage>;
|
|
545
|
-
|
|
546
606
|
/**
|
|
547
607
|
* Base metadata type.
|
|
548
608
|
*/
|
|
@@ -886,23 +946,6 @@ type DefaultAsync<TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknow
|
|
|
886
946
|
*/
|
|
887
947
|
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?: Dataset<TInput, never>, config?: Config<InferIssue<TWrapped>>) => MaybePromise<InferInput<TWrapped> | TInput> ? Awaited<ReturnType<TDefault>> : TDefault : never;
|
|
888
948
|
|
|
889
|
-
/**
|
|
890
|
-
* Pipe action type.
|
|
891
|
-
*/
|
|
892
|
-
type PipeAction<TInput, TOutput, TIssue extends BaseIssue<unknown>> = BaseValidation<TInput, TOutput, TIssue> | BaseTransformation<TInput, TOutput, TIssue> | BaseMetadata<TInput>;
|
|
893
|
-
/**
|
|
894
|
-
* Pipe action async type.
|
|
895
|
-
*/
|
|
896
|
-
type PipeActionAsync<TInput, TOutput, TIssue extends BaseIssue<unknown>> = BaseValidationAsync<TInput, TOutput, TIssue> | BaseTransformationAsync<TInput, TOutput, TIssue>;
|
|
897
|
-
/**
|
|
898
|
-
* Pipe item type.
|
|
899
|
-
*/
|
|
900
|
-
type PipeItem<TInput, TOutput, TIssue extends BaseIssue<unknown>> = BaseSchema<TInput, TOutput, TIssue> | PipeAction<TInput, TOutput, TIssue>;
|
|
901
|
-
/**
|
|
902
|
-
* Pipe item async type.
|
|
903
|
-
*/
|
|
904
|
-
type PipeItemAsync<TInput, TOutput, TIssue extends BaseIssue<unknown>> = BaseSchemaAsync<TInput, TOutput, TIssue> | PipeActionAsync<TInput, TOutput, TIssue>;
|
|
905
|
-
|
|
906
949
|
/**
|
|
907
950
|
* Object entries type.
|
|
908
951
|
*/
|
|
@@ -915,26 +958,40 @@ interface ObjectEntries {
|
|
|
915
958
|
interface ObjectEntriesAsync {
|
|
916
959
|
[key: string]: BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>;
|
|
917
960
|
}
|
|
961
|
+
/**
|
|
962
|
+
* Question mark schema type.
|
|
963
|
+
*
|
|
964
|
+
* TODO: Document that for simplicity and bundle size, we currently do not
|
|
965
|
+
* distinguish between `undefined` and missing keys when using `optional` and
|
|
966
|
+
* `nullish`.
|
|
967
|
+
*/
|
|
968
|
+
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>;
|
|
969
|
+
/**
|
|
970
|
+
* Has default type.
|
|
971
|
+
*/
|
|
972
|
+
type HasDefault<TSchema extends QuestionMarkSchema> = [
|
|
973
|
+
TSchema['default']
|
|
974
|
+
] extends [never] ? false : true;
|
|
975
|
+
/**
|
|
976
|
+
* Exact optional input type.
|
|
977
|
+
*/
|
|
978
|
+
type ExactOptionalInput<TSchema extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>> = TSchema extends NullishSchema<infer TWrapped, never> | NullishSchemaAsync<infer TWrapped, never> ? ExactOptionalInput<TWrapped> | null : TSchema extends OptionalSchema<infer TWrapped, never> | OptionalSchemaAsync<infer TWrapped, never> ? ExactOptionalInput<TWrapped> : InferInput<TSchema>;
|
|
979
|
+
/**
|
|
980
|
+
* Exact optional output type.
|
|
981
|
+
*/
|
|
982
|
+
type ExactOptionalOutput<TSchema extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>> = TSchema extends NullishSchema<infer TWrapped, never> | NullishSchemaAsync<infer TWrapped, never> ? HasDefault<TSchema> extends true ? InferOutput<TSchema> : ExactOptionalOutput<TWrapped> | null : TSchema extends OptionalSchema<infer TWrapped, never> | OptionalSchemaAsync<infer TWrapped, never> ? HasDefault<TSchema> extends true ? InferOutput<TSchema> : ExactOptionalOutput<TWrapped> : InferOutput<TSchema>;
|
|
918
983
|
/**
|
|
919
984
|
* Infer entries input type.
|
|
920
985
|
*/
|
|
921
986
|
type InferEntriesInput<TEntries extends ObjectEntries | ObjectEntriesAsync> = {
|
|
922
|
-
-readonly [TKey in keyof TEntries]:
|
|
987
|
+
-readonly [TKey in keyof TEntries]: ExactOptionalInput<TEntries[TKey]>;
|
|
923
988
|
};
|
|
924
989
|
/**
|
|
925
990
|
* Infer entries output type.
|
|
926
991
|
*/
|
|
927
992
|
type InferEntriesOutput<TEntries extends ObjectEntries | ObjectEntriesAsync> = {
|
|
928
|
-
-readonly [TKey in keyof TEntries]:
|
|
993
|
+
-readonly [TKey in keyof TEntries]: ExactOptionalOutput<TEntries[TKey]>;
|
|
929
994
|
};
|
|
930
|
-
/**
|
|
931
|
-
* Question mark schema type.
|
|
932
|
-
*
|
|
933
|
-
* TODO: Document that for simplicity and bundle size, we currently do not
|
|
934
|
-
* distinguish between `undefined` and missing keys when using `optional` and
|
|
935
|
-
* `nullish`.
|
|
936
|
-
*/
|
|
937
|
-
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>;
|
|
938
995
|
/**
|
|
939
996
|
* Optional input keys type.
|
|
940
997
|
*/
|
|
@@ -945,7 +1002,7 @@ type OptionalInputKeys<TEntries extends ObjectEntries | ObjectEntriesAsync> = {
|
|
|
945
1002
|
* Optional output keys type.
|
|
946
1003
|
*/
|
|
947
1004
|
type OptionalOutputKeys<TEntries extends ObjectEntries | ObjectEntriesAsync> = {
|
|
948
|
-
[TKey in keyof TEntries]: TEntries[TKey] extends QuestionMarkSchema ?
|
|
1005
|
+
[TKey in keyof TEntries]: TEntries[TKey] extends QuestionMarkSchema ? HasDefault<TEntries[TKey]> extends true ? never : TKey : never;
|
|
949
1006
|
}[keyof TEntries];
|
|
950
1007
|
/**
|
|
951
1008
|
* Input with question marks type.
|
|
@@ -959,13 +1016,7 @@ type OutputWithQuestionMarks<TEntries extends ObjectEntries | ObjectEntriesAsync
|
|
|
959
1016
|
* Readonly output keys type.
|
|
960
1017
|
*/
|
|
961
1018
|
type ReadonlyOutputKeys<TEntries extends ObjectEntries | ObjectEntriesAsync> = {
|
|
962
|
-
[TKey in keyof TEntries]: TEntries[TKey] extends SchemaWithPipe<[
|
|
963
|
-
BaseSchema<unknown, unknown, BaseIssue<unknown>>,
|
|
964
|
-
...PipeItem<any, unknown, BaseIssue<unknown>>[]
|
|
965
|
-
]> | SchemaWithPipeAsync<[
|
|
966
|
-
(BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>),
|
|
967
|
-
...(PipeItem<any, unknown, BaseIssue<unknown>> | PipeItemAsync<any, unknown, BaseIssue<unknown>>)[]
|
|
968
|
-
]> ? 'readonly' extends TEntries[TKey]['pipe'][number]['type'] ? TKey : never : never;
|
|
1019
|
+
[TKey in keyof TEntries]: TEntries[TKey] extends SchemaWithPipe<infer TPipe> | SchemaWithPipeAsync<infer TPipe> ? ReadonlyAction<any> extends TPipe[number] ? TKey : never : never;
|
|
969
1020
|
}[keyof TEntries];
|
|
970
1021
|
/**
|
|
971
1022
|
* Output with readonly type.
|
|
@@ -1147,18 +1198,18 @@ interface BaseIssue<TInput> extends Config<BaseIssue<TInput>> {
|
|
|
1147
1198
|
/**
|
|
1148
1199
|
* The input requirement.
|
|
1149
1200
|
*/
|
|
1150
|
-
readonly requirement?: unknown;
|
|
1201
|
+
readonly requirement?: unknown | undefined;
|
|
1151
1202
|
/**
|
|
1152
1203
|
* The issue path.
|
|
1153
1204
|
*
|
|
1154
1205
|
* TODO: Investigate if it is possible to make the path type safe based on the
|
|
1155
1206
|
* input.
|
|
1156
1207
|
*/
|
|
1157
|
-
readonly path?: [IssuePathItem, ...IssuePathItem[]];
|
|
1208
|
+
readonly path?: [IssuePathItem, ...IssuePathItem[]] | undefined;
|
|
1158
1209
|
/**
|
|
1159
1210
|
* The sub issues.
|
|
1160
1211
|
*/
|
|
1161
|
-
readonly issues?: [BaseIssue<TInput>, ...BaseIssue<TInput>[]];
|
|
1212
|
+
readonly issues?: [BaseIssue<TInput>, ...BaseIssue<TInput>[]] | undefined;
|
|
1162
1213
|
}
|
|
1163
1214
|
|
|
1164
1215
|
/**
|
|
@@ -1168,20 +1219,57 @@ interface Config<TIssue extends BaseIssue<unknown>> {
|
|
|
1168
1219
|
/**
|
|
1169
1220
|
* The selected language.
|
|
1170
1221
|
*/
|
|
1171
|
-
readonly lang?: string;
|
|
1222
|
+
readonly lang?: string | undefined;
|
|
1172
1223
|
/**
|
|
1173
1224
|
* The error message.
|
|
1174
1225
|
*/
|
|
1175
|
-
readonly message?: ErrorMessage<TIssue
|
|
1226
|
+
readonly message?: ErrorMessage<TIssue> | undefined;
|
|
1176
1227
|
/**
|
|
1177
1228
|
* Whether it was abort early.
|
|
1178
1229
|
*/
|
|
1179
|
-
readonly abortEarly?: boolean;
|
|
1230
|
+
readonly abortEarly?: boolean | undefined;
|
|
1180
1231
|
/**
|
|
1181
1232
|
* Whether the pipe was abort early.
|
|
1182
1233
|
*/
|
|
1183
|
-
readonly abortPipeEarly?: boolean;
|
|
1234
|
+
readonly abortPipeEarly?: boolean | undefined;
|
|
1235
|
+
}
|
|
1236
|
+
|
|
1237
|
+
/**
|
|
1238
|
+
* Pipe action type.
|
|
1239
|
+
*/
|
|
1240
|
+
type PipeAction<TInput, TOutput, TIssue extends BaseIssue<unknown>> = BaseValidation<TInput, TOutput, TIssue> | BaseTransformation<TInput, TOutput, TIssue> | BaseMetadata<TInput>;
|
|
1241
|
+
/**
|
|
1242
|
+
* Pipe action async type.
|
|
1243
|
+
*/
|
|
1244
|
+
type PipeActionAsync<TInput, TOutput, TIssue extends BaseIssue<unknown>> = BaseValidationAsync<TInput, TOutput, TIssue> | BaseTransformationAsync<TInput, TOutput, TIssue>;
|
|
1245
|
+
/**
|
|
1246
|
+
* Pipe item type.
|
|
1247
|
+
*/
|
|
1248
|
+
type PipeItem<TInput, TOutput, TIssue extends BaseIssue<unknown>> = BaseSchema<TInput, TOutput, TIssue> | PipeAction<TInput, TOutput, TIssue>;
|
|
1249
|
+
/**
|
|
1250
|
+
* Pipe item async type.
|
|
1251
|
+
*/
|
|
1252
|
+
type PipeItemAsync<TInput, TOutput, TIssue extends BaseIssue<unknown>> = BaseSchemaAsync<TInput, TOutput, TIssue> | PipeActionAsync<TInput, TOutput, TIssue>;
|
|
1253
|
+
|
|
1254
|
+
/**
|
|
1255
|
+
* Readonly action type.
|
|
1256
|
+
*/
|
|
1257
|
+
interface ReadonlyAction<TInput> extends BaseTransformation<TInput, Readonly<TInput>, never> {
|
|
1258
|
+
/**
|
|
1259
|
+
* The action type.
|
|
1260
|
+
*/
|
|
1261
|
+
readonly type: 'readonly';
|
|
1262
|
+
/**
|
|
1263
|
+
* The action reference.
|
|
1264
|
+
*/
|
|
1265
|
+
readonly reference: typeof readonly;
|
|
1184
1266
|
}
|
|
1267
|
+
/**
|
|
1268
|
+
* Creates a readonly transformation action.
|
|
1269
|
+
*
|
|
1270
|
+
* @returns A readonly action.
|
|
1271
|
+
*/
|
|
1272
|
+
declare function readonly<TInput>(): ReadonlyAction<TInput>;
|
|
1185
1273
|
|
|
1186
1274
|
/**
|
|
1187
1275
|
* @internal
|
|
@@ -1278,6 +1366,38 @@ declare const CustomComponentSchema: ObjectSchema<{
|
|
|
1278
1366
|
readonly defaultValue: OptionalSchema<StringSchema<undefined>, never>;
|
|
1279
1367
|
}, undefined>, undefined>, readonly []>;
|
|
1280
1368
|
}, undefined>;
|
|
1369
|
+
declare const CustomComponentNormalizedSchema: ObjectSchema<{
|
|
1370
|
+
readonly name: StringSchema<undefined>;
|
|
1371
|
+
readonly as: OptionalSchema<StringSchema<undefined>, never>;
|
|
1372
|
+
readonly attributes: OptionalSchema<ArraySchema<ObjectSchema<{
|
|
1373
|
+
/**
|
|
1374
|
+
* The name of the attribute in the user-defined component.
|
|
1375
|
+
* @example
|
|
1376
|
+
* "to"
|
|
1377
|
+
*/
|
|
1378
|
+
readonly name: StringSchema<undefined>;
|
|
1379
|
+
/**
|
|
1380
|
+
* The name of the attribute in the built-in component.
|
|
1381
|
+
* @example
|
|
1382
|
+
* "href"
|
|
1383
|
+
*/
|
|
1384
|
+
readonly as: OptionalSchema<StringSchema<undefined>, never>;
|
|
1385
|
+
/**
|
|
1386
|
+
* Whether the attribute is controlled or not in the user-defined component.
|
|
1387
|
+
* @example
|
|
1388
|
+
* `true`
|
|
1389
|
+
*/
|
|
1390
|
+
readonly controlled: OptionalSchema<BooleanSchema<undefined>, never>;
|
|
1391
|
+
/**
|
|
1392
|
+
* The default value of the attribute in the user-defined component.
|
|
1393
|
+
* @example
|
|
1394
|
+
* `"/"`
|
|
1395
|
+
*/
|
|
1396
|
+
readonly defaultValue: OptionalSchema<StringSchema<undefined>, never>;
|
|
1397
|
+
}, undefined>, undefined>, readonly []>;
|
|
1398
|
+
readonly re: InstanceSchema<RegExpConstructor, undefined>;
|
|
1399
|
+
readonly selector: OptionalSchema<StringSchema<undefined>, never>;
|
|
1400
|
+
}, undefined>;
|
|
1281
1401
|
/**
|
|
1282
1402
|
* @internal
|
|
1283
1403
|
*/
|
|
@@ -1656,8 +1776,17 @@ declare const ESLintSettingsSchema: OptionalSchema<ObjectSchema<{
|
|
|
1656
1776
|
type CustomHook = InferOutput<typeof CustomHookSchema>;
|
|
1657
1777
|
type CustomAttribute = InferOutput<typeof CustomAttributeSchema>;
|
|
1658
1778
|
type CustomComponent = InferOutput<typeof CustomComponentSchema>;
|
|
1779
|
+
type CustomComponentNormalized = InferOutput<typeof CustomComponentNormalizedSchema>;
|
|
1659
1780
|
type ESLintReactSettings = InferOutput<typeof ESLintReactSettingsSchema>;
|
|
1660
1781
|
type ESLintSettings = InferOutput<typeof ESLintSettingsSchema>;
|
|
1782
|
+
/**
|
|
1783
|
+
* This is an expanded version of `ESLintReactSettings` with all shorthand properties expanded.
|
|
1784
|
+
* @internal
|
|
1785
|
+
*/
|
|
1786
|
+
interface ESLintReactSettingsNormalized extends ESLintReactSettings {
|
|
1787
|
+
additionalComponents: CustomComponentNormalized[];
|
|
1788
|
+
components: Map<string, string>;
|
|
1789
|
+
}
|
|
1661
1790
|
|
|
1662
1791
|
interface Dictionary<Type> {
|
|
1663
1792
|
[key: string]: Type;
|
|
@@ -1904,41 +2033,12 @@ declare const INITIAL_ESLINT_REACT_SETTINGS: {
|
|
|
1904
2033
|
readonly skipImportCheck: false;
|
|
1905
2034
|
};
|
|
1906
2035
|
/**
|
|
1907
|
-
*
|
|
1908
|
-
*/
|
|
1909
|
-
declare const DEFAULT_ESLINT_REACT_SETTINGS: {
|
|
1910
|
-
readonly additionalHooks: {
|
|
1911
|
-
readonly useLayoutEffect: ["useIsomorphicLayoutEffect"];
|
|
1912
|
-
};
|
|
1913
|
-
readonly polymorphicPropName: "as";
|
|
1914
|
-
readonly skipImportCheck: false;
|
|
1915
|
-
readonly version: "detect";
|
|
1916
|
-
};
|
|
1917
|
-
/**
|
|
1918
|
-
* This is an expanded version of `CustomComponent` with all shorthand properties expanded.
|
|
1919
|
-
* @internal
|
|
1920
|
-
*/
|
|
1921
|
-
interface CustomComponentExpanded extends CustomComponent {
|
|
1922
|
-
attributes: {
|
|
1923
|
-
name: string;
|
|
1924
|
-
as: string;
|
|
1925
|
-
}[];
|
|
1926
|
-
re: RegExp;
|
|
1927
|
-
}
|
|
1928
|
-
/**
|
|
1929
|
-
* This is an expanded version of `ESLintReactSettings` with all shorthand properties expanded.
|
|
2036
|
+
* Unsafely casts settings from a data object from `context.settings`.
|
|
1930
2037
|
* @internal
|
|
2038
|
+
* @param data The data object.
|
|
2039
|
+
* @returns settings The settings.
|
|
1931
2040
|
*/
|
|
1932
|
-
|
|
1933
|
-
additionalComponents: CustomComponentExpanded[];
|
|
1934
|
-
components: Map<string, string>;
|
|
1935
|
-
}
|
|
1936
|
-
/**
|
|
1937
|
-
* A helper function to define settings for "react-x" with type checking in JavaScript files.
|
|
1938
|
-
* @param settings The settings.
|
|
1939
|
-
* @returns The settings.
|
|
1940
|
-
*/
|
|
1941
|
-
declare const defineSettings: (settings: ESLintReactSettings) => ESLintReactSettings;
|
|
2041
|
+
declare function unsafeReadSettings(data: unknown): PartialDeep<ESLintReactSettings>;
|
|
1942
2042
|
/**
|
|
1943
2043
|
* Decodes settings from a data object from `context.settings`.
|
|
1944
2044
|
* @internal
|
|
@@ -1947,57 +2047,87 @@ declare const defineSettings: (settings: ESLintReactSettings) => ESLintReactSett
|
|
|
1947
2047
|
*/
|
|
1948
2048
|
declare const decodeSettings: Memoized<(data: unknown) => {
|
|
1949
2049
|
readonly skipImportCheck: boolean;
|
|
1950
|
-
readonly importSource?: string
|
|
1951
|
-
readonly jsxPragma?: string
|
|
1952
|
-
readonly jsxPragmaFrag?: string
|
|
1953
|
-
readonly polymorphicPropName?: string
|
|
1954
|
-
readonly strict?: boolean
|
|
1955
|
-
readonly version?: string
|
|
2050
|
+
readonly importSource?: string;
|
|
2051
|
+
readonly jsxPragma?: string;
|
|
2052
|
+
readonly jsxPragmaFrag?: string;
|
|
2053
|
+
readonly polymorphicPropName?: string;
|
|
2054
|
+
readonly strict?: boolean;
|
|
2055
|
+
readonly version?: string;
|
|
1956
2056
|
readonly additionalComponents?: {
|
|
1957
2057
|
name: string;
|
|
1958
2058
|
attributes: {
|
|
1959
2059
|
name: string;
|
|
1960
|
-
as?: string
|
|
1961
|
-
controlled?: boolean
|
|
1962
|
-
defaultValue?: string
|
|
2060
|
+
as?: string;
|
|
2061
|
+
controlled?: boolean;
|
|
2062
|
+
defaultValue?: string;
|
|
1963
2063
|
}[];
|
|
1964
|
-
as?: string
|
|
1965
|
-
selector?: string
|
|
1966
|
-
}[]
|
|
2064
|
+
as?: string;
|
|
2065
|
+
selector?: string;
|
|
2066
|
+
}[];
|
|
1967
2067
|
readonly additionalHooks?: {
|
|
1968
|
-
use?: string[]
|
|
1969
|
-
useActionState?: string[]
|
|
1970
|
-
useCallback?: string[]
|
|
1971
|
-
useContext?: string[]
|
|
1972
|
-
useDebugValue?: string[]
|
|
1973
|
-
useDeferredValue?: string[]
|
|
1974
|
-
useEffect?: string[]
|
|
1975
|
-
useId?: string[]
|
|
1976
|
-
useImperativeHandle?: string[]
|
|
1977
|
-
useInsertionEffect?: string[]
|
|
1978
|
-
useLayoutEffect?: string[]
|
|
1979
|
-
useMemo?: string[]
|
|
1980
|
-
useOptimistic?: string[]
|
|
1981
|
-
useReducer?: string[]
|
|
1982
|
-
useRef?: string[]
|
|
1983
|
-
useState?: string[]
|
|
1984
|
-
useSyncExternalStore?: string[]
|
|
1985
|
-
useTransition?: string[]
|
|
1986
|
-
}
|
|
2068
|
+
use?: string[];
|
|
2069
|
+
useActionState?: string[];
|
|
2070
|
+
useCallback?: string[];
|
|
2071
|
+
useContext?: string[];
|
|
2072
|
+
useDebugValue?: string[];
|
|
2073
|
+
useDeferredValue?: string[];
|
|
2074
|
+
useEffect?: string[];
|
|
2075
|
+
useId?: string[];
|
|
2076
|
+
useImperativeHandle?: string[];
|
|
2077
|
+
useInsertionEffect?: string[];
|
|
2078
|
+
useLayoutEffect?: string[];
|
|
2079
|
+
useMemo?: string[];
|
|
2080
|
+
useOptimistic?: string[];
|
|
2081
|
+
useReducer?: string[];
|
|
2082
|
+
useRef?: string[];
|
|
2083
|
+
useState?: string[];
|
|
2084
|
+
useSyncExternalStore?: string[];
|
|
2085
|
+
useTransition?: string[];
|
|
2086
|
+
};
|
|
1987
2087
|
}>;
|
|
1988
2088
|
/**
|
|
1989
|
-
*
|
|
2089
|
+
* Normalizes the settings by converting all shorthand properties to their full form.
|
|
2090
|
+
* @param settings The settings.
|
|
2091
|
+
* @returns The normalized settings.
|
|
1990
2092
|
* @internal
|
|
1991
|
-
* @param data The data object.
|
|
1992
|
-
* @returns settings The settings.
|
|
1993
2093
|
*/
|
|
1994
|
-
declare
|
|
2094
|
+
declare const normalizeSettings: Memoized<(settings: ESLintReactSettings) => {
|
|
2095
|
+
readonly additionalComponents: CustomComponentNormalized[];
|
|
2096
|
+
readonly components: Map<string, string>;
|
|
2097
|
+
readonly skipImportCheck: boolean;
|
|
2098
|
+
readonly importSource?: string;
|
|
2099
|
+
readonly jsxPragma?: string;
|
|
2100
|
+
readonly jsxPragmaFrag?: string;
|
|
2101
|
+
readonly polymorphicPropName?: string;
|
|
2102
|
+
readonly strict?: boolean;
|
|
2103
|
+
readonly version?: string;
|
|
2104
|
+
readonly additionalHooks?: {
|
|
2105
|
+
use?: string[];
|
|
2106
|
+
useActionState?: string[];
|
|
2107
|
+
useCallback?: string[];
|
|
2108
|
+
useContext?: string[];
|
|
2109
|
+
useDebugValue?: string[];
|
|
2110
|
+
useDeferredValue?: string[];
|
|
2111
|
+
useEffect?: string[];
|
|
2112
|
+
useId?: string[];
|
|
2113
|
+
useImperativeHandle?: string[];
|
|
2114
|
+
useInsertionEffect?: string[];
|
|
2115
|
+
useLayoutEffect?: string[];
|
|
2116
|
+
useMemo?: string[];
|
|
2117
|
+
useOptimistic?: string[];
|
|
2118
|
+
useReducer?: string[];
|
|
2119
|
+
useRef?: string[];
|
|
2120
|
+
useState?: string[];
|
|
2121
|
+
useSyncExternalStore?: string[];
|
|
2122
|
+
useTransition?: string[];
|
|
2123
|
+
};
|
|
2124
|
+
}>;
|
|
2125
|
+
declare function findAttrInCustomAttributes(name: string, attributes: CustomAttribute[]): readonly [string, string | undefined] | readonly [string];
|
|
1995
2126
|
/**
|
|
1996
|
-
*
|
|
2127
|
+
* A helper function to define settings for "react-x" with type checking in JavaScript files.
|
|
1997
2128
|
* @param settings The settings.
|
|
1998
|
-
* @returns The
|
|
1999
|
-
* @internal
|
|
2129
|
+
* @returns The settings.
|
|
2000
2130
|
*/
|
|
2001
|
-
declare const
|
|
2131
|
+
declare const defineSettings: (settings: ESLintReactSettings) => ESLintReactSettings;
|
|
2002
2132
|
|
|
2003
|
-
export { type CustomAttribute, CustomAttributeSchema, type CustomComponent, type
|
|
2133
|
+
export { type CustomAttribute, CustomAttributeSchema, type CustomComponent, type CustomComponentNormalized, CustomComponentNormalizedSchema, CustomComponentSchema, type CustomHook, CustomHookSchema, type ESLintReactSettings, type ESLintReactSettingsNormalized, ESLintReactSettingsSchema, type ESLintSettings, ESLintSettingsSchema, GITHUB_URL, HOST_HTML_COMPONENT_TYPES, HOST_SVG_COMPONENT_TYPES, INITIAL_ESLINT_REACT_SETTINGS, 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, findAttrInCustomAttributes, normalizeSettings, unsafeReadSettings };
|