@eslint-react/core 1.48.2 → 1.48.3-next.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.js CHANGED
@@ -34,909 +34,6 @@ var VAR3__namespace = /*#__PURE__*/_interopNamespace(VAR3);
34
34
  var birecord__default = /*#__PURE__*/_interopDefault(birecord);
35
35
 
36
36
  // src/component/component-collector.ts
37
-
38
- // ../../node_modules/.pnpm/@zod+core@0.1.0/node_modules/@zod/core/dist/esm/core.js
39
- // @__NO_SIDE_EFFECTS__
40
- function $constructor(name, initializer) {
41
- class _6 {
42
- constructor(def) {
43
- var _a;
44
- const th = this;
45
- _6.init(th, def);
46
- (_a = th._zod).deferred ?? (_a.deferred = []);
47
- for (const fn of th._zod.deferred) {
48
- fn();
49
- }
50
- }
51
- static init(inst, def) {
52
- var _a;
53
- inst._zod ?? (inst._zod = {});
54
- (_a = inst._zod).traits ?? (_a.traits = /* @__PURE__ */ new Set());
55
- inst._zod.traits.add(name);
56
- initializer(inst, def);
57
- for (const k in _6.prototype) {
58
- Object.defineProperty(inst, k, { value: _6.prototype[k].bind(inst) });
59
- }
60
- inst._zod.constr = _6;
61
- inst._zod.def = def;
62
- }
63
- static [Symbol.hasInstance](inst) {
64
- return inst?._zod?.traits?.has(name);
65
- }
66
- }
67
- Object.defineProperty(_6, "name", { value: name });
68
- return _6;
69
- }
70
- var $ZodAsyncError = class extends Error {
71
- constructor() {
72
- super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
73
- }
74
- };
75
- var globalConfig = {};
76
- function config(config2) {
77
- return globalConfig;
78
- }
79
- function jsonStringifyReplacer(_6, value) {
80
- if (typeof value === "bigint")
81
- return value.toString();
82
- return value;
83
- }
84
- function cached(getter) {
85
- return {
86
- get value() {
87
- {
88
- const value = getter();
89
- Object.defineProperty(this, "value", { value });
90
- return value;
91
- }
92
- }
93
- };
94
- }
95
- function cleanRegex(source) {
96
- const start = source.startsWith("^") ? 1 : 0;
97
- const end = source.endsWith("$") ? source.length - 1 : source.length;
98
- return source.slice(start, end);
99
- }
100
- function defineLazy(object2, key, getter) {
101
- Object.defineProperty(object2, key, {
102
- get() {
103
- {
104
- const value = getter();
105
- object2[key] = value;
106
- return value;
107
- }
108
- },
109
- set(v) {
110
- Object.defineProperty(object2, key, {
111
- value: v
112
- // configurable: true,
113
- });
114
- },
115
- configurable: true
116
- });
117
- }
118
- function randomString(length = 10) {
119
- const chars = "abcdefghijklmnopqrstuvwxyz";
120
- let str = "";
121
- for (let i = 0; i < length; i++) {
122
- str += chars[Math.floor(Math.random() * chars.length)];
123
- }
124
- return str;
125
- }
126
- function esc(str) {
127
- return JSON.stringify(str);
128
- }
129
- function isObject(data) {
130
- return typeof data === "object" && data !== null;
131
- }
132
- var allowsEval = cached(() => {
133
- try {
134
- new Function("");
135
- return true;
136
- } catch (_6) {
137
- return false;
138
- }
139
- });
140
- function clone(inst, def) {
141
- return new inst._zod.constr(def);
142
- }
143
- function normalizeParams(_params) {
144
- const params = _params;
145
- if (!params)
146
- return {};
147
- if (typeof params === "string")
148
- return { error: () => params };
149
- if (params?.message !== void 0) {
150
- if (params?.error !== void 0)
151
- throw new Error("Cannot specify both `message` and `error` params");
152
- params.error = params.message;
153
- }
154
- delete params.message;
155
- if (typeof params.error === "string")
156
- return { ...params, error: () => params.error };
157
- return params;
158
- }
159
- function optionalObjectKeys(shape) {
160
- return Object.keys(shape).filter((k) => {
161
- return shape[k]._zod.qout === "true";
162
- });
163
- }
164
- function aborted(x, startIndex = 0) {
165
- for (let i = startIndex; i < x.issues.length; i++) {
166
- if (x.issues[i].continue !== true)
167
- return true;
168
- }
169
- return false;
170
- }
171
- function prefixIssues(path, issues) {
172
- return issues.map((iss) => {
173
- var _a;
174
- (_a = iss).path ?? (_a.path = []);
175
- iss.path.unshift(path);
176
- return iss;
177
- });
178
- }
179
- function unwrapMessage(message) {
180
- return typeof message === "string" ? message : message?.message;
181
- }
182
- function finalizeIssue(iss, ctx, config2) {
183
- const full = { ...iss, path: iss.path ?? [] };
184
- if (!iss.message) {
185
- const message = unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(ctx?.error?.(iss)) ?? unwrapMessage(config2.customError?.(iss)) ?? unwrapMessage(config2.localeError?.(iss)) ?? "Invalid input";
186
- full.message = message;
187
- }
188
- delete full.inst;
189
- delete full.continue;
190
- if (!ctx?.reportInput) {
191
- delete full.input;
192
- }
193
- return full;
194
- }
195
-
196
- // ../../node_modules/.pnpm/@zod+core@0.1.0/node_modules/@zod/core/dist/esm/errors.js
197
- var ZOD_ERROR = Symbol.for("{{zod.error}}");
198
- var $ZodError = class {
199
- get message() {
200
- return JSON.stringify(this.issues, jsonStringifyReplacer, 2);
201
- }
202
- constructor(issues) {
203
- Object.defineProperty(this, "_tag", { value: ZOD_ERROR, enumerable: false });
204
- Object.defineProperty(this, "name", { value: "$ZodError", enumerable: false });
205
- this.issues = issues;
206
- }
207
- // @ts-ignore
208
- static [Symbol.hasInstance](inst) {
209
- return inst?._tag === ZOD_ERROR;
210
- }
211
- };
212
-
213
- // ../../node_modules/.pnpm/@zod+core@0.1.0/node_modules/@zod/core/dist/esm/parse.js
214
- function _parse(schema, value, _ctx) {
215
- const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
216
- const result = schema._zod.run({ value, issues: [] }, ctx);
217
- if (result instanceof Promise) {
218
- throw new $ZodAsyncError();
219
- }
220
- if (result.issues.length) {
221
- throw new (this?.Error ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
222
- }
223
- return result.value;
224
- }
225
- function _safeParse(schema, value, _ctx) {
226
- const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
227
- const result = schema._zod.run({ value, issues: [] }, ctx);
228
- if (result instanceof Promise) {
229
- throw new $ZodAsyncError();
230
- }
231
- return result.issues.length ? {
232
- success: false,
233
- error: new (this?.Error ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
234
- } : { success: true, data: result.value };
235
- }
236
- async function _parseAsync(schema, value, _ctx) {
237
- const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
238
- let result = schema._zod.run({ value, issues: [] }, ctx);
239
- if (result instanceof Promise)
240
- result = await result;
241
- if (result.issues.length) {
242
- throw new (this?.Error ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
243
- }
244
- return result.value;
245
- }
246
- async function _safeParseAsync(schema, value, _ctx) {
247
- const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
248
- let result = schema._zod.run({ value, issues: [] }, ctx);
249
- if (result instanceof Promise)
250
- result = await result;
251
- if (result.issues.length) {
252
- return {
253
- success: false,
254
- error: new (this?.Error ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
255
- };
256
- }
257
- return { success: true, data: result.value };
258
- }
259
- var string = (params) => {
260
- const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
261
- return new RegExp(`^${regex}$`);
262
- };
263
- var boolean = /true|false/i;
264
-
265
- // ../../node_modules/.pnpm/@zod+core@0.1.0/node_modules/@zod/core/dist/esm/doc.js
266
- var Doc = class {
267
- constructor(args) {
268
- this.content = [];
269
- this.indent = 0;
270
- this.args = args;
271
- }
272
- indented(fn) {
273
- this.indent += 1;
274
- fn(this);
275
- this.indent -= 1;
276
- }
277
- write(arg) {
278
- if (typeof arg === "function") {
279
- arg(this, { execution: "sync" });
280
- arg(this, { execution: "async" });
281
- return;
282
- }
283
- const content = arg;
284
- const lines = content.split("\n").filter((x) => x);
285
- const minIndent = Math.min(...lines.map((x) => x.length - x.trimStart().length));
286
- const dedented = lines.map((x) => x.slice(minIndent)).map((x) => " ".repeat(this.indent * 2) + x);
287
- for (const line of dedented) {
288
- this.content.push(line);
289
- }
290
- }
291
- compile() {
292
- const lines = [...this.content.map((x) => ` ${x}`)];
293
- return new Function(...this.args, lines.join("\n"));
294
- }
295
- };
296
-
297
- // ../../node_modules/.pnpm/@zod+core@0.1.0/node_modules/@zod/core/dist/esm/schemas.js
298
- var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
299
- var _a;
300
- inst ?? (inst = {});
301
- inst._zod.id = def.type + "_" + randomString(10);
302
- inst._zod.def = def;
303
- inst._zod.computed = inst._zod.computed || {};
304
- const checks = [...inst._zod.def.checks ?? []];
305
- def.type;
306
- if (inst._zod.traits.has("$ZodCheck")) {
307
- checks.unshift(inst);
308
- }
309
- for (const ch of checks) {
310
- ch._zod.onattach?.(inst);
311
- }
312
- if (checks.length === 0) {
313
- (_a = inst._zod).deferred ?? (_a.deferred = []);
314
- inst._zod.deferred?.push(() => {
315
- inst._zod.run = inst._zod.parse;
316
- });
317
- } else {
318
- const runChecks = (payload, checks2, ctx) => {
319
- let isAborted = aborted(payload);
320
- let asyncResult;
321
- for (const ch of checks2) {
322
- if (ch._zod.when) {
323
- const shouldRun = ch._zod.when(payload);
324
- if (!shouldRun)
325
- continue;
326
- } else {
327
- if (isAborted) {
328
- continue;
329
- }
330
- }
331
- const currLen = payload.issues.length;
332
- const _6 = ch._zod.check(payload);
333
- if (_6 instanceof Promise && ctx?.async === false) {
334
- throw new $ZodAsyncError();
335
- }
336
- if (asyncResult || _6 instanceof Promise) {
337
- asyncResult = asyncResult ?? Promise.resolve();
338
- asyncResult.then(async () => {
339
- await _6;
340
- const nextLen = payload.issues.length;
341
- if (nextLen === currLen)
342
- return;
343
- if (!isAborted)
344
- isAborted = aborted(payload, currLen);
345
- });
346
- } else {
347
- const nextLen = payload.issues.length;
348
- if (nextLen === currLen)
349
- continue;
350
- if (!isAborted)
351
- isAborted = aborted(payload, currLen);
352
- }
353
- }
354
- if (asyncResult) {
355
- return asyncResult.then(() => {
356
- return payload;
357
- });
358
- }
359
- return payload;
360
- };
361
- inst._zod.run = (payload, ctx) => {
362
- const result = inst._zod.parse(payload, ctx);
363
- if (result instanceof Promise) {
364
- if (ctx.async === false)
365
- throw new $ZodAsyncError();
366
- return result.then((result2) => runChecks(result2, checks, ctx));
367
- }
368
- return runChecks(result, checks, ctx);
369
- };
370
- }
371
- defineLazy(inst, "~standard", () => ({
372
- validate: (value) => {
373
- const result = inst._zod.run({ value, issues: [] }, {});
374
- if (result instanceof Promise) {
375
- return result.then(({ issues, value: value2 }) => {
376
- if (issues.length === 0)
377
- return { value: value2 };
378
- return { issues };
379
- });
380
- }
381
- if (result.issues.length === 0)
382
- return { value: result.value };
383
- return { issues: result.issues };
384
- },
385
- vendor: "zod",
386
- version: 1
387
- }));
388
- });
389
- var $ZodString = /* @__PURE__ */ $constructor("$ZodString", (inst, def) => {
390
- $ZodType.init(inst, def);
391
- inst._zod.pattern = inst?._zod.computed?.pattern ?? string(inst._zod.computed);
392
- inst._zod.parse = (payload, _6) => {
393
- if (def.coerce)
394
- try {
395
- payload.value = String(payload.value);
396
- } catch (_7) {
397
- }
398
- if (typeof payload.value === "string")
399
- return payload;
400
- payload.issues.push({
401
- expected: "string",
402
- code: "invalid_type",
403
- input: payload.value,
404
- inst
405
- });
406
- return payload;
407
- };
408
- });
409
- var $ZodBoolean = /* @__PURE__ */ $constructor("$ZodBoolean", (inst, def) => {
410
- $ZodType.init(inst, def);
411
- inst._zod.pattern = boolean;
412
- inst._zod.parse = (payload, _ctx) => {
413
- if (def.coerce)
414
- try {
415
- payload.value = Boolean(payload.value);
416
- } catch (_6) {
417
- }
418
- const input = payload.value;
419
- if (typeof input === "boolean")
420
- return payload;
421
- payload.issues.push({
422
- expected: "boolean",
423
- code: "invalid_type",
424
- input,
425
- inst
426
- });
427
- return payload;
428
- };
429
- });
430
- var $ZodUnknown = /* @__PURE__ */ $constructor("$ZodUnknown", (inst, def) => {
431
- $ZodType.init(inst, def);
432
- inst._zod.parse = (payload) => payload;
433
- });
434
- function handleArrayResult(result, final, index) {
435
- if (result.issues.length) {
436
- final.issues.push(...prefixIssues(index, result.issues));
437
- }
438
- final.value[index] = result.value;
439
- }
440
- var $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
441
- $ZodType.init(inst, def);
442
- inst._zod.parse = (payload, ctx) => {
443
- const input = payload.value;
444
- if (!Array.isArray(input)) {
445
- payload.issues.push({
446
- expected: "array",
447
- code: "invalid_type",
448
- input,
449
- inst
450
- });
451
- return payload;
452
- }
453
- payload.value = Array(input.length);
454
- const proms = [];
455
- for (let i = 0; i < input.length; i++) {
456
- const item = input[i];
457
- const result = def.element._zod.run({
458
- value: item,
459
- issues: []
460
- }, ctx);
461
- if (result instanceof Promise) {
462
- proms.push(result.then((result2) => handleArrayResult(result2, payload, i)));
463
- } else {
464
- handleArrayResult(result, payload, i);
465
- }
466
- }
467
- if (proms.length) {
468
- return Promise.all(proms).then(() => payload);
469
- }
470
- return payload;
471
- };
472
- });
473
- function handleObjectResult(result, final, key) {
474
- if (result.issues.length) {
475
- final.issues.push(...prefixIssues(key, result.issues));
476
- } else {
477
- final.value[key] = result.value;
478
- }
479
- }
480
- function handleOptionalObjectResult(result, final, key, input) {
481
- if (result.issues.length) {
482
- if (input[key] === void 0) {
483
- if (key in input) {
484
- final.value[key] = void 0;
485
- }
486
- } else {
487
- final.issues.push(...prefixIssues(key, result.issues));
488
- }
489
- } else if (result.value === void 0) {
490
- if (key in input)
491
- final.value[key] = void 0;
492
- } else {
493
- final.value[key] = result.value;
494
- }
495
- }
496
- var $ZodObjectLike = /* @__PURE__ */ $constructor("$ZodObjectLike", (inst, def) => {
497
- $ZodType.init(inst, def);
498
- defineLazy(inst._zod, "shape", () => def.shape);
499
- const _normalized = cached(() => {
500
- const keys = Object.keys(def.shape);
501
- return {
502
- shape: def.shape,
503
- keys,
504
- keySet: new Set(keys),
505
- numKeys: keys.length,
506
- optionalKeys: new Set(def.optional)
507
- };
508
- });
509
- defineLazy(inst._zod, "disc", () => {
510
- const shape = def.shape;
511
- const discMap = /* @__PURE__ */ new Map();
512
- let hasDisc = false;
513
- for (const key in shape) {
514
- const field = shape[key]._zod;
515
- if (field.values || field.disc) {
516
- hasDisc = true;
517
- const o = {
518
- values: new Set(field.values ?? []),
519
- maps: field.disc ? [field.disc] : []
520
- };
521
- discMap.set(key, o);
522
- }
523
- }
524
- if (!hasDisc)
525
- return void 0;
526
- return discMap;
527
- });
528
- const generateFastpass = (shape) => {
529
- const doc = new Doc(["shape", "payload", "ctx"]);
530
- const { keys, optionalKeys } = _normalized.value;
531
- const parseStr = (key) => {
532
- const k = esc(key);
533
- return `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
534
- };
535
- doc.write(`const input = payload.value;`);
536
- const ids = {};
537
- for (const key of keys) {
538
- ids[key] = randomString(15);
539
- }
540
- for (const key of keys) {
541
- if (optionalKeys.has(key))
542
- continue;
543
- const id = ids[key];
544
- doc.write(`const ${id} = ${parseStr(key)};`);
545
- doc.write(`
546
- if (${id}.issues.length) payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
547
- ...iss,
548
- path: iss.path ? [${esc(key)}, ...iss.path] : [${esc(key)}]
549
- })));`);
550
- }
551
- doc.write(`payload.value = {`);
552
- doc.indented(() => {
553
- for (const key of keys) {
554
- if (optionalKeys.has(key))
555
- continue;
556
- const id = ids[key];
557
- doc.write(` ${esc(key)}: ${id}.value,`);
558
- }
559
- });
560
- doc.write(`}`);
561
- for (const key of keys) {
562
- if (!optionalKeys.has(key))
563
- continue;
564
- const id = ids[key];
565
- doc.write(`const ${id} = ${parseStr(key)};`);
566
- const k = esc(key);
567
- doc.write(`
568
- if (${id}.issues.length) {
569
- if (input[${k}] === undefined) {
570
- if (${k} in input) {
571
- payload.value[${k}] = undefined;
572
- }
573
- } else {
574
- payload.issues = payload.issues.concat(
575
- ${id}.issues.map((iss) => ({
576
- ...iss,
577
- path: iss.path ? [${k}, ...iss.path] : [${k}],
578
- }))
579
- );
580
- }
581
- } else if (${id}.value === undefined) {
582
- if (${k} in input) payload.value[${k}] = undefined;
583
- } else {
584
- payload.value[${k}] = ${id}.value;
585
- }
586
- `);
587
- }
588
- doc.write(`return payload;`);
589
- const fn = doc.compile();
590
- return (payload, ctx) => fn(shape, payload, ctx);
591
- };
592
- let fastpass;
593
- const fastEnabled = allowsEval.value;
594
- const isObject2 = isObject;
595
- const { catchall } = def;
596
- inst._zod.parse = (payload, ctx) => {
597
- const input = payload.value;
598
- if (!isObject2(input)) {
599
- payload.issues.push({
600
- expected: "object",
601
- code: "invalid_type",
602
- input,
603
- inst
604
- });
605
- return payload;
606
- }
607
- const proms = [];
608
- if (fastEnabled && ctx?.async === false && ctx.noPrecompilation !== true) {
609
- if (!fastpass)
610
- fastpass = generateFastpass(def.shape);
611
- payload = fastpass(payload, ctx);
612
- } else {
613
- payload.value = {};
614
- const { keys, shape, optionalKeys } = _normalized.value;
615
- for (const key of keys) {
616
- const valueSchema = shape[key];
617
- const r = valueSchema._zod.run({ value: input[key], issues: [] }, ctx);
618
- const isOptional = optionalKeys.has(key);
619
- if (r instanceof Promise) {
620
- proms.push(r.then((r2) => isOptional ? handleOptionalObjectResult(r2, payload, key, input) : handleObjectResult(r2, payload, key)));
621
- } else {
622
- if (isOptional) {
623
- handleOptionalObjectResult(r, payload, key, input);
624
- } else {
625
- handleObjectResult(r, payload, key);
626
- }
627
- }
628
- }
629
- }
630
- if (!catchall) {
631
- return proms.length ? Promise.all(proms).then(() => payload) : payload;
632
- }
633
- const unrecognized = [];
634
- for (const key of Object.keys(input)) {
635
- if (_normalized.value.keySet.has(key))
636
- continue;
637
- if (catchall._zod.def.type === "never") {
638
- unrecognized.push(key);
639
- continue;
640
- }
641
- const r = catchall._zod.run({ value: input[key], issues: [] }, ctx);
642
- if (r instanceof Promise) {
643
- proms.push(r.then((r2) => handleObjectResult(r2, payload, key)));
644
- } else {
645
- handleObjectResult(r, payload, key);
646
- }
647
- }
648
- if (unrecognized.length) {
649
- payload.issues.push({
650
- code: "unrecognized_keys",
651
- keys: unrecognized,
652
- input,
653
- inst
654
- });
655
- }
656
- if (!proms.length)
657
- return payload;
658
- return Promise.all(proms).then(() => {
659
- return payload;
660
- });
661
- };
662
- });
663
- var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
664
- $ZodObjectLike.init(inst, def);
665
- });
666
- var $ZodOptional = /* @__PURE__ */ $constructor("$ZodOptional", (inst, def) => {
667
- $ZodType.init(inst, def);
668
- inst._zod.qout = "true";
669
- if (def.innerType._zod.values)
670
- inst._zod.values = /* @__PURE__ */ new Set([...def.innerType._zod.values, void 0]);
671
- const pattern = def.innerType._zod.pattern;
672
- if (pattern)
673
- inst._zod.pattern = new RegExp(`^(${cleanRegex(pattern.source)})?$`);
674
- inst._zod.parse = (payload, ctx) => {
675
- if (payload.value === void 0) {
676
- return payload;
677
- }
678
- return def.innerType._zod.run(payload, ctx);
679
- };
680
- });
681
-
682
- // ../../node_modules/.pnpm/@zod+core@0.1.0/node_modules/@zod/core/dist/esm/api.js
683
- function _string(Class, params) {
684
- return new Class({
685
- type: "string",
686
- ...normalizeParams(params)
687
- });
688
- }
689
- function _boolean(Class, params) {
690
- return new Class({
691
- type: "boolean",
692
- ...normalizeParams(params)
693
- });
694
- }
695
- function _unknown(Class, params) {
696
- return new Class({
697
- type: "unknown",
698
- ...normalizeParams(params)
699
- });
700
- }
701
-
702
- // ../../node_modules/.pnpm/@zod+mini@4.0.0-beta.0/node_modules/@zod/mini/dist/esm/parse.js
703
- var parse2 = /* @__PURE__ */ _parse.bind({ Error: $ZodError });
704
- var safeParse = /* @__PURE__ */ _safeParse.bind({ Error: $ZodError });
705
- var parseAsync2 = /* @__PURE__ */ _parseAsync.bind({ Error: $ZodError });
706
- var safeParseAsync = /* @__PURE__ */ _safeParseAsync.bind({
707
- Error: $ZodError
708
- });
709
-
710
- // ../../node_modules/.pnpm/@zod+mini@4.0.0-beta.0/node_modules/@zod/mini/dist/esm/schemas.js
711
- var ZodMiniType = /* @__PURE__ */ $constructor("ZodMiniType", (inst, def) => {
712
- if (!inst._zod)
713
- throw new Error("Uninitialized schema in mixin ZodMiniType.");
714
- $ZodType.init(inst, def);
715
- inst.def = def;
716
- inst.parse = (data, params) => parse2(inst, data, params);
717
- inst.safeParse = (data, params) => safeParse(inst, data, params);
718
- inst.parseAsync = async (data, params) => parseAsync2(inst, data, params);
719
- inst.safeParseAsync = async (data, params) => safeParseAsync(inst, data, params);
720
- inst.check = (...checks) => {
721
- return inst.clone({
722
- ...def,
723
- checks: [
724
- ...def.checks ?? [],
725
- ...checks.map((ch) => typeof ch === "function" ? { _zod: { check: ch, def: { check: "custom" } } } : ch)
726
- ]
727
- });
728
- };
729
- inst.clone = (_def) => clone(inst, _def ?? def);
730
- inst.brand = () => inst;
731
- inst.register = (reg, meta) => {
732
- reg.add(inst, meta);
733
- return inst;
734
- };
735
- });
736
- var ZodMiniString = /* @__PURE__ */ $constructor("ZodMiniString", (inst, def) => {
737
- $ZodString.init(inst, def);
738
- ZodMiniType.init(inst, def);
739
- });
740
- function string2(params) {
741
- return _string(ZodMiniString, params);
742
- }
743
- var ZodMiniBoolean = /* @__PURE__ */ $constructor("ZodMiniBoolean", (inst, def) => {
744
- $ZodBoolean.init(inst, def);
745
- ZodMiniType.init(inst, def);
746
- });
747
- function boolean2(params) {
748
- return _boolean(ZodMiniBoolean, params);
749
- }
750
- var ZodMiniUnknown = /* @__PURE__ */ $constructor("ZodMiniUnknown", (inst, def) => {
751
- $ZodUnknown.init(inst, def);
752
- ZodMiniType.init(inst, def);
753
- });
754
- function unknown(params) {
755
- return _unknown(ZodMiniUnknown, params);
756
- }
757
- var ZodMiniArray = /* @__PURE__ */ $constructor("ZodMiniArray", (inst, def) => {
758
- $ZodArray.init(inst, def);
759
- ZodMiniType.init(inst, def);
760
- });
761
- function array(element, params) {
762
- return new ZodMiniArray({
763
- type: "array",
764
- element,
765
- // get element() {
766
- // return element;
767
- // },
768
- ...normalizeParams(params)
769
- });
770
- }
771
- var ZodMiniObject = /* @__PURE__ */ $constructor("ZodMiniObject", (inst, def) => {
772
- $ZodObject.init(inst, def);
773
- ZodMiniType.init(inst, def);
774
- });
775
- function object(shape, params) {
776
- const def = {
777
- type: "object",
778
- shape: shape ?? {},
779
- get optional() {
780
- return optionalObjectKeys(shape ?? {});
781
- },
782
- ...normalizeParams(params)
783
- };
784
- return new ZodMiniObject(def);
785
- }
786
- var ZodMiniOptional = /* @__PURE__ */ $constructor("ZodMiniOptional", (inst, def) => {
787
- $ZodOptional.init(inst, def);
788
- ZodMiniType.init(inst, def);
789
- });
790
- function optional(innerType, params) {
791
- return new ZodMiniOptional({
792
- type: "optional",
793
- innerType,
794
- ...normalizeParams(params)
795
- });
796
- }
797
-
798
- // ../shared/src/schemas.ts
799
- var CustomComponentPropSchema = object({
800
- /**
801
- * The name of the prop in the user-defined component.
802
- * @example
803
- * "to"
804
- */
805
- name: string2(),
806
- /**
807
- * The name of the prop in the host component.
808
- * @example
809
- * "href"
810
- */
811
- as: optional(string2()),
812
- /**
813
- * Whether the prop is controlled or not in the user-defined component.
814
- * @internal
815
- * @example
816
- * `true`
817
- */
818
- controlled: optional(boolean2()),
819
- /**
820
- * The default value of the prop in the user-defined component.
821
- * @example
822
- * `"/"`
823
- */
824
- defaultValue: optional(string2())
825
- });
826
- var CustomComponentSchema = object({
827
- /**
828
- * The name of the user-defined component.
829
- * @example
830
- * "Link"
831
- */
832
- name: string2(),
833
- /**
834
- * The name of the host component that the user-defined component represents.
835
- * @example
836
- * "a"
837
- */
838
- as: optional(string2()),
839
- /**
840
- * Attributes mapping between the user-defined component and the host component.
841
- * @example
842
- * `Link` component has a `to` attribute that represents the `href` attribute in the built-in `a` element with a default value of `"/"`.
843
- */
844
- attributes: optional(array(CustomComponentPropSchema)),
845
- /**
846
- * The ESQuery selector to select the component precisely.
847
- * @internal
848
- * @example
849
- * `JSXElement:has(JSXAttribute[name.name='component'][value.value='a'])`
850
- */
851
- selector: optional(string2())
852
- });
853
- var CustomHooksSchema = object({
854
- use: optional(array(string2())),
855
- useActionState: optional(array(string2())),
856
- useCallback: optional(array(string2())),
857
- useContext: optional(array(string2())),
858
- useDebugValue: optional(array(string2())),
859
- useDeferredValue: optional(array(string2())),
860
- useEffect: optional(array(string2())),
861
- useFormStatus: optional(array(string2())),
862
- useId: optional(array(string2())),
863
- useImperativeHandle: optional(array(string2())),
864
- useInsertionEffect: optional(array(string2())),
865
- useLayoutEffect: optional(array(string2())),
866
- useMemo: optional(array(string2())),
867
- useOptimistic: optional(array(string2())),
868
- useReducer: optional(array(string2())),
869
- useRef: optional(array(string2())),
870
- useState: optional(array(string2())),
871
- useSyncExternalStore: optional(array(string2())),
872
- useTransition: optional(array(string2()))
873
- });
874
- object({
875
- /**
876
- * The source where React is imported from.
877
- * @description This allows to specify a custom import location for React when not using the official distribution.
878
- * @default `"react"`
879
- * @example `"@pika/react"`
880
- */
881
- importSource: optional(string2()),
882
- /**
883
- * The identifier that's used for JSX Element creation.
884
- * @default `"createElement"`
885
- * @deprecated
886
- */
887
- jsxPragma: optional(string2()),
888
- /**
889
- * The identifier that's used for JSX fragment elements.
890
- * @description This should not be a member expression (i.e. use "Fragment" instead of "React.Fragment").
891
- * @default `"Fragment"`
892
- * @deprecated
893
- */
894
- jsxPragmaFrag: optional(string2()),
895
- /**
896
- * The name of the prop that is used for polymorphic components.
897
- * @description This is used to determine the type of the component.
898
- * @example `"as"`
899
- */
900
- polymorphicPropName: optional(string2()),
901
- /**
902
- * @default `true`
903
- * @internal
904
- */
905
- strict: optional(boolean2()),
906
- /**
907
- * Check both the shape and the import to determine if an API is from React.
908
- * @default `true`
909
- * @internal
910
- */
911
- skipImportCheck: optional(boolean2()),
912
- /**
913
- * React version to use, "detect" means auto detect React version from the project's dependencies.
914
- * If `importSource` is specified, an equivalent version of React should be provided here.
915
- * @example `"18.3.1"`
916
- * @default `"detect"`
917
- */
918
- version: optional(string2()),
919
- /**
920
- * A object to define additional hooks that are equivalent to the built-in React Hooks.
921
- * @description ESLint React will recognize these aliases as equivalent to the built-in hooks in all its rules.
922
- * @example `{ useEffect: ["useIsomorphicLayoutEffect"] }`
923
- */
924
- additionalHooks: optional(CustomHooksSchema),
925
- /**
926
- * An array of user-defined components
927
- * @description This is used to inform the ESLint React plugins how to treat these components during checks.
928
- * @example `[{ name: "Link", as: "a", attributes: [{ name: "to", as: "href" }, { name: "rel", defaultValue: "noopener noreferrer" }] }]`
929
- */
930
- additionalComponents: optional(array(CustomComponentSchema))
931
- });
932
- optional(
933
- object({
934
- "react-x": optional(unknown())
935
- }),
936
- {}
937
- );
938
- var DEFAULT_ESLINT_REACT_SETTINGS = {
939
- importSource: "react"};
940
37
  function getInstanceId(node, prev) {
941
38
  switch (true) {
942
39
  case (node.type === types.AST_NODE_TYPES.VariableDeclarator && node.init === prev):
@@ -1055,7 +152,7 @@ function isReactHookCall(node) {
1055
152
  function isReactHookCallWithName(context, node) {
1056
153
  if (node == null || node.type !== types.AST_NODE_TYPES.CallExpression) return eff.constFalse;
1057
154
  const {
1058
- importSource = DEFAULT_ESLINT_REACT_SETTINGS.importSource,
155
+ importSource = shared.DEFAULT_ESLINT_REACT_SETTINGS.importSource,
1059
156
  skipImportCheck = true
1060
157
  } = shared.coerceSettings(context.settings);
1061
158
  const initialScope = context.sourceCode.getScope(node);
@@ -1085,7 +182,7 @@ function isReactHookCallWithNameLoose(node) {
1085
182
  }
1086
183
  function isReactHookCallWithNameAlias(context, name, alias = []) {
1087
184
  const {
1088
- importSource = DEFAULT_ESLINT_REACT_SETTINGS.importSource,
185
+ importSource = shared.DEFAULT_ESLINT_REACT_SETTINGS.importSource,
1089
186
  skipImportCheck = true
1090
187
  } = shared.coerceSettings(context.settings);
1091
188
  return (node) => {
@@ -1194,10 +291,10 @@ function isFunctionOfUseEffectSetup(node) {
1194
291
  function isFunctionOfUseEffectCleanup(node) {
1195
292
  if (node == null) return false;
1196
293
  const pReturn = AST9__namespace.findParentNode(node, AST9__namespace.is(types.AST_NODE_TYPES.ReturnStatement));
1197
- const pFaunction = AST9__namespace.findParentNode(node, AST9__namespace.isFunction);
294
+ const pFunction = AST9__namespace.findParentNode(node, AST9__namespace.isFunction);
1198
295
  const pFunctionOfReturn = AST9__namespace.findParentNode(pReturn, AST9__namespace.isFunction);
1199
- if (pFaunction !== pFunctionOfReturn) return false;
1200
- return isFunctionOfUseEffectSetup(pFaunction);
296
+ if (pFunction !== pFunctionOfReturn) return false;
297
+ return isFunctionOfUseEffectSetup(pFunction);
1201
298
  }
1202
299
  function stringifyJsx(node) {
1203
300
  switch (node.type) {