@jandragsbaek/oxlint-plugin 0.0.0-stage → 0.2.0

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.mjs ADDED
@@ -0,0 +1,3318 @@
1
+ // node_modules/.pnpm/@oxlint+plugins@1.94.0/node_modules/@oxlint/plugins/index.js
2
+ /**
3
+ * Define a plugin.
4
+ *
5
+ * No-op function, just to provide type safety. Input is passed through unchanged.
6
+ *
7
+ * @param plugin - Plugin to define
8
+ * @returns Same plugin as passed in
9
+ */
10
+ function definePlugin(plugin) {
11
+ return plugin;
12
+ }
13
+ /**
14
+ * Define a rule.
15
+ *
16
+ * No-op function, just to provide type safety. Input is passed through unchanged.
17
+ *
18
+ * @param rule - Rule to define
19
+ * @returns Same rule as passed in
20
+ */
21
+ function defineRule(rule) {
22
+ return rule;
23
+ }
24
+ Object.freeze({
25
+ get filename() {
26
+ throw Error("Cannot access `context.filename` in `createOnce`");
27
+ },
28
+ getFilename() {
29
+ throw Error("Cannot call `context.getFilename` in `createOnce`");
30
+ },
31
+ get physicalFilename() {
32
+ throw Error("Cannot access `context.physicalFilename` in `createOnce`");
33
+ },
34
+ getPhysicalFilename() {
35
+ throw Error("Cannot call `context.getPhysicalFilename` in `createOnce`");
36
+ },
37
+ get cwd() {
38
+ throw Error("Cannot access `context.cwd` in `createOnce`");
39
+ },
40
+ getCwd() {
41
+ throw Error("Cannot call `context.getCwd` in `createOnce`");
42
+ },
43
+ get sourceCode() {
44
+ throw Error("Cannot access `context.sourceCode` in `createOnce`");
45
+ },
46
+ getSourceCode() {
47
+ throw Error("Cannot call `context.getSourceCode` in `createOnce`");
48
+ },
49
+ get languageOptions() {
50
+ throw Error("Cannot access `context.languageOptions` in `createOnce`");
51
+ },
52
+ get settings() {
53
+ throw Error("Cannot access `context.settings` in `createOnce`");
54
+ },
55
+ extend(extension) {
56
+ return Object.freeze(Object.assign(Object.create(this), extension));
57
+ },
58
+ get parserOptions() {
59
+ throw Error("Cannot access `context.parserOptions` in `createOnce`");
60
+ },
61
+ get parserPath() {
62
+ throw Error("Cannot access `context.parserPath` in `createOnce`");
63
+ }
64
+ });
65
+ // node_modules/.pnpm/effect@4.1.2/node_modules/effect/dist/Pipeable.js
66
+ /**
67
+ * The `Pipeable` module defines the shared interface and implementation helpers
68
+ * for values that support Effect-style method chaining with `.pipe(...)`.
69
+ *
70
+ * A `Pipeable` value can pass itself through a sequence of unary functions from
71
+ * left to right, so code can be written as `value.pipe(f, g, h)` instead of
72
+ * deeply nesting calls. This is the method form used by many Effect data types
73
+ * to compose transformations, validations, and effectful operations while
74
+ * keeping the original value as the starting point of the pipeline.
75
+ *
76
+ * @stability stable
77
+ * @since 2.0.0
78
+ */
79
+ /**
80
+ * Applies a `pipe` method's variadic arguments to an initial value from left
81
+ * to right.
82
+ *
83
+ * **When to use**
84
+ *
85
+ * Use to implement a custom `.pipe(...)` method from JavaScript's `arguments`
86
+ * object.
87
+ *
88
+ * **Details**
89
+ *
90
+ * This helper is intended for implementing `Pipeable.pipe` methods that
91
+ * receive JavaScript's `arguments` object. With no functions it returns the
92
+ * original value; otherwise it feeds each result into the next function.
93
+ *
94
+ * **Example** (Implementing a pipe method)
95
+ *
96
+ * ```ts import.meta.vitest
97
+ * import { Pipeable } from "effect"
98
+ *
99
+ * class NumberBox {
100
+ * constructor(readonly value: number) {}
101
+ *
102
+ * pipe(..._fns: ReadonlyArray<(value: number) => number>): number {
103
+ * return Pipeable.pipeArguments(this.value, arguments) as number
104
+ * }
105
+ * }
106
+ *
107
+ * const result = new NumberBox(5).pipe(
108
+ * (n) => n + 2,
109
+ * (n) => n * 3
110
+ * )
111
+ * result // => 21
112
+ * ```
113
+ *
114
+ * @stability stable
115
+ * @category combinators
116
+ * @since 2.0.0
117
+ */
118
+ const pipeArguments = (self, args) => {
119
+ switch (args.length) {
120
+ case 0: return self;
121
+ case 1: return args[0](self);
122
+ case 2: return args[1](args[0](self));
123
+ case 3: return args[2](args[1](args[0](self)));
124
+ case 4: return args[3](args[2](args[1](args[0](self))));
125
+ case 5: return args[4](args[3](args[2](args[1](args[0](self)))));
126
+ case 6: return args[5](args[4](args[3](args[2](args[1](args[0](self))))));
127
+ case 7: return args[6](args[5](args[4](args[3](args[2](args[1](args[0](self)))))));
128
+ case 8: return args[7](args[6](args[5](args[4](args[3](args[2](args[1](args[0](self))))))));
129
+ case 9: return args[8](args[7](args[6](args[5](args[4](args[3](args[2](args[1](args[0](self)))))))));
130
+ default: {
131
+ let ret = self;
132
+ for (let i = 0, len = args.length; i < len; i++) ret = args[i](ret);
133
+ return ret;
134
+ }
135
+ }
136
+ };
137
+ // node_modules/.pnpm/effect@4.1.2/node_modules/effect/dist/Function.js
138
+ /**
139
+ * Creates a function that can be called in data-first style or data-last
140
+ * (`pipe`-friendly) style.
141
+ *
142
+ * **When to use**
143
+ *
144
+ * Use to expose one implementation through both direct and `pipe`-friendly
145
+ * call styles.
146
+ *
147
+ * **Details**
148
+ *
149
+ * Pass either the arity of the uncurried function or a predicate that decides
150
+ * whether the current call is data-first. Arity is the common case. Use a
151
+ * predicate when optional arguments make arity ambiguous.
152
+ *
153
+ * **Example** (Selecting data-first or data-last style by arity)
154
+ *
155
+ * ```ts import.meta.vitest
156
+ * import { Function, pipe } from "effect"
157
+ *
158
+ * const sum = Function.dual<
159
+ * (that: number) => (self: number) => number,
160
+ * (self: number, that: number) => number
161
+ * >(2, (self, that) => self + that)
162
+ *
163
+ * sum(2, 3) // => 5
164
+ * pipe(2, sum(3)) // => 5
165
+ * ```
166
+ *
167
+ * **Example** (Defining overloads with call signatures)
168
+ *
169
+ * ```ts import.meta.vitest
170
+ * import { Function, pipe } from "effect"
171
+ *
172
+ * const sum: {
173
+ * (that: number): (self: number) => number
174
+ * (self: number, that: number): number
175
+ * } = Function.dual(2, (self: number, that: number): number => self + that)
176
+ *
177
+ * sum(2, 3) // => 5
178
+ * pipe(2, sum(3)) // => 5
179
+ * ```
180
+ *
181
+ * **Example** (Selecting data-first or data-last style with a predicate)
182
+ *
183
+ * ```ts import.meta.vitest
184
+ * import { Function, pipe } from "effect"
185
+ *
186
+ * const sum = Function.dual<
187
+ * (that: number) => (self: number) => number,
188
+ * (self: number, that: number) => number
189
+ * >(
190
+ * (args) => args.length === 2,
191
+ * (self, that) => self + that
192
+ * )
193
+ *
194
+ * sum(2, 3) // => 5
195
+ * pipe(2, sum(3)) // => 5
196
+ * ```
197
+ *
198
+ * @stability stable
199
+ * @category combinators
200
+ * @since 2.0.0
201
+ */
202
+ const dual = function(arity, body) {
203
+ if (typeof arity === "function") return function() {
204
+ return arity(arguments) ? body.apply(this, arguments) : (self) => body(self, ...arguments);
205
+ };
206
+ switch (arity) {
207
+ case 0:
208
+ case 1: throw new RangeError(`Invalid arity ${arity}`);
209
+ case 2: return function(a, b) {
210
+ if (arguments.length >= 2) return body(a, b);
211
+ return function(self) {
212
+ return body(self, a);
213
+ };
214
+ };
215
+ case 3: return function(a, b, c) {
216
+ if (arguments.length >= 3) return body(a, b, c);
217
+ return function(self) {
218
+ return body(self, a, b);
219
+ };
220
+ };
221
+ default: return function() {
222
+ if (arguments.length >= arity) return body.apply(this, arguments);
223
+ const args = arguments;
224
+ return function(self) {
225
+ return body(self, ...args);
226
+ };
227
+ };
228
+ }
229
+ };
230
+ // node_modules/.pnpm/effect@4.1.2/node_modules/effect/dist/internal/equal.js
231
+ /** @internal */
232
+ const getAllObjectKeys = (obj) => {
233
+ const keys = new Set(Reflect.ownKeys(obj));
234
+ if (obj.constructor === Object) return keys;
235
+ if (obj instanceof Error) keys.delete("stack");
236
+ const proto = Object.getPrototypeOf(obj);
237
+ let current = proto;
238
+ while (current !== null && current !== Object.prototype) {
239
+ const ownKeys = Reflect.ownKeys(current);
240
+ for (let i = 0; i < ownKeys.length; i++) keys.add(ownKeys[i]);
241
+ current = Object.getPrototypeOf(current);
242
+ }
243
+ if (keys.has("constructor") && typeof obj.constructor === "function" && proto === obj.constructor.prototype) keys.delete("constructor");
244
+ return keys;
245
+ };
246
+ /** @internal */
247
+ const byReferenceInstances = /*#__PURE__*/ new WeakSet();
248
+ /** @internal */
249
+ const viewBytes = (view) => new Uint8Array(view.buffer, view.byteOffset, view.byteLength);
250
+ /** @internal */
251
+ const isArrayBufferLike = (u) => u instanceof ArrayBuffer || typeof SharedArrayBuffer !== "undefined" && u instanceof SharedArrayBuffer;
252
+ /**
253
+ * Returns `undefined` for detached buffers, which can no longer be read.
254
+ *
255
+ * @internal
256
+ */
257
+ const bufferBytes = (buffer) => {
258
+ try {
259
+ return new Uint8Array(buffer);
260
+ } catch {
261
+ return;
262
+ }
263
+ };
264
+ // node_modules/.pnpm/effect@4.1.2/node_modules/effect/dist/internal/hash.js
265
+ /**
266
+ * Back-edge count used to avoid caching entry-point-dependent hashes.
267
+ *
268
+ * @internal
269
+ */
270
+ let backEdges = 0;
271
+ /** @internal */
272
+ const addBackEdge = () => {
273
+ backEdges++;
274
+ };
275
+ // node_modules/.pnpm/effect@4.1.2/node_modules/effect/dist/Predicate.js
276
+ /**
277
+ * Defines runtime checks for values.
278
+ *
279
+ * A `Predicate<A>` returns `true` or `false` for an `A`. A
280
+ * `Refinement<A, B>` is a predicate that also narrows the TypeScript type when
281
+ * it succeeds. This module includes guards for common JavaScript values,
282
+ * property and tag checks, tuple and struct checks, boolean combinators, and
283
+ * helpers for composing predicates and refinements.
284
+ *
285
+ * @stability stable
286
+ * @since 2.0.0
287
+ */
288
+ /**
289
+ * Checks whether a value is a `function`.
290
+ *
291
+ * **When to use**
292
+ *
293
+ * Use when you need a `Predicate` guard to narrow an `unknown` value to a
294
+ * callable function.
295
+ *
296
+ * **Details**
297
+ *
298
+ * Uses `typeof input === "function"`.
299
+ *
300
+ * **Example** (Guarding functions)
301
+ *
302
+ * ```ts import.meta.vitest
303
+ * import { Predicate } from "effect"
304
+ *
305
+ * const data: unknown = () => 1
306
+ *
307
+ * if (Predicate.isFunction(data)) {
308
+ * data() // => 1
309
+ * }
310
+ * ```
311
+ *
312
+ * @see {@link isObjectKeyword}
313
+ * @stability stable
314
+ * @category guards
315
+ * @since 2.0.0
316
+ */
317
+ function isFunction(input) {
318
+ return typeof input === "function";
319
+ }
320
+ /**
321
+ * Checks whether a value is an `object` in the JavaScript sense (objects, arrays, functions).
322
+ *
323
+ * **When to use**
324
+ *
325
+ * Use when you need a `Predicate` guard that accepts arrays and functions as
326
+ * well as objects.
327
+ *
328
+ * **Details**
329
+ *
330
+ * Returns `true` for arrays and functions, and `false` for `null`.
331
+ *
332
+ * **Example** (Checking object keywords)
333
+ *
334
+ * ```ts import.meta.vitest
335
+ * import { Predicate } from "effect"
336
+ *
337
+ * Predicate.isObjectKeyword(() => 1) // => true
338
+ * Predicate.isObjectKeyword(null) // => false
339
+ * ```
340
+ *
341
+ * @see {@link isObject}
342
+ * @see {@link isObjectOrArray}
343
+ * @stability stable
344
+ * @category guards
345
+ * @since 4.0.0
346
+ */
347
+ function isObjectKeyword(input) {
348
+ return typeof input === "object" && input !== null || isFunction(input);
349
+ }
350
+ /**
351
+ * Checks whether a value has a given property key.
352
+ *
353
+ * **When to use**
354
+ *
355
+ * Use when you need a `Predicate` guard for property access on `unknown`
356
+ * values with a simple structural object check.
357
+ *
358
+ * **Details**
359
+ *
360
+ * Uses the `in` operator and `isObjectKeyword`. This does not check property
361
+ * value types.
362
+ *
363
+ * **Example** (Guarding object properties)
364
+ *
365
+ * ```ts import.meta.vitest
366
+ * import { Predicate } from "effect"
367
+ *
368
+ * const hasName = Predicate.hasProperty("name")
369
+ * const data: unknown = { name: "Ada" }
370
+ *
371
+ * if (hasName(data)) {
372
+ * data.name // => "Ada"
373
+ * }
374
+ * ```
375
+ *
376
+ * @see {@link isTagged}
377
+ * @see {@link isObjectKeyword}
378
+ * @stability stable
379
+ * @category guards
380
+ * @since 2.0.0
381
+ */
382
+ const hasProperty = /*#__PURE__*/ dual(2, (self, property) => isObjectKeyword(self) && property in self);
383
+ // node_modules/.pnpm/effect@4.1.2/node_modules/effect/dist/Hash.js
384
+ /**
385
+ * Computes Effect hash values and defines the interface for objects that want
386
+ * to provide their own hash implementation. Hashes are small numeric
387
+ * fingerprints used by Effect data structures to bucket values quickly; they
388
+ * are not cryptographic digests and they are not proof that two values are
389
+ * equal. The module also includes helpers for primitive, structure, array, and
390
+ * reference-based hashes, plus functions for combining and optimizing numeric
391
+ * hash values.
392
+ *
393
+ * @stability stable
394
+ * @since 2.0.0
395
+ */
396
+ /**
397
+ * Defines the unique identifier used to identify objects that implement the Hash interface.
398
+ *
399
+ * **When to use**
400
+ *
401
+ * Use as the computed property key for the method that supplies a custom hash
402
+ * value on a `Hash` implementor.
403
+ *
404
+ * @see {@link Hash} for the interface implemented with this symbol
405
+ * @see {@link isHash} for checking whether a value implements `Hash`
406
+ * @see {@link hash} for computing hash values
407
+ *
408
+ * @stability stable
409
+ * @category symbols
410
+ * @since 2.0.0
411
+ */
412
+ const symbol$1 = "~effect/Hash";
413
+ /**
414
+ * Computes a hash value for any given value.
415
+ *
416
+ * **When to use**
417
+ *
418
+ * Use to compute an Effect hash for primitives, collections, and hashable
419
+ * objects.
420
+ *
421
+ * **Details**
422
+ *
423
+ * This function can hash primitives (numbers, strings, booleans, etc.) as well as
424
+ * objects, arrays, and other complex data structures. It automatically handles
425
+ * different types and provides a consistent hash value for equivalent inputs.
426
+ *
427
+ * **Gotchas**
428
+ *
429
+ * Objects being hashed must be treated as immutable after their first hash
430
+ * computation. Hash results are cached, so mutating an object after hashing will
431
+ * lead to stale cached values and broken hash-based operations. For mutable
432
+ * objects, implement a custom `Hash` interface that hashes the object reference
433
+ * rather than its content.
434
+ *
435
+ * **Example** (Hashing different values)
436
+ *
437
+ * ```ts import.meta.vitest
438
+ * import { Hash } from "effect"
439
+ *
440
+ * Hash.hash(42) === Hash.hash(42) // => true
441
+ * Hash.hash("hello") === Hash.hash("hello") // => true
442
+ * Hash.hash([1, 2, 3]) === Hash.hash([1, 2, 3]) // => true
443
+ * ```
444
+ *
445
+ * @stability stable
446
+ * @category hashing
447
+ * @since 2.0.0
448
+ */
449
+ const hash = (self) => {
450
+ switch (typeof self) {
451
+ case "number": return number(self);
452
+ case "bigint": return string(self.toString(10));
453
+ case "string": return string(self);
454
+ case "function":
455
+ case "object": if (self === null) break;
456
+ else if (self instanceof Date) {
457
+ if (Number.isNaN(self.getTime())) return string("Invalid Date");
458
+ return string(self.toISOString());
459
+ } else if (self instanceof RegExp) return string(self.toString());
460
+ else {
461
+ if (byReferenceInstances.has(self)) return random(self);
462
+ const cached = hashCache.get(self);
463
+ if (cached !== void 0) return cached;
464
+ if (visitedObjects.has(self)) {
465
+ addBackEdge();
466
+ return string("[Circular]");
467
+ }
468
+ visitedObjects.add(self);
469
+ const seen = backEdges;
470
+ let h;
471
+ try {
472
+ if (isHash(self)) h = self[symbol$1]();
473
+ else if (typeof self === "function") h = random(self);
474
+ else if (isArrayBufferLike(self)) {
475
+ const bytes = bufferBytes(self);
476
+ h = bytes === void 0 ? random(self) : array(bytes);
477
+ } else if (self instanceof DataView) h = array(viewBytes(self));
478
+ else if (Array.isArray(self) || ArrayBuffer.isView(self)) h = array(self);
479
+ else if (self instanceof Map) h = hashMap(self);
480
+ else if (self instanceof Set) h = hashSet(self);
481
+ else h = structure(self);
482
+ } finally {
483
+ visitedObjects.delete(self);
484
+ }
485
+ if (seen === backEdges) hashCache.set(self, h);
486
+ return h;
487
+ }
488
+ }
489
+ return optimize(mix(string(String(self))));
490
+ };
491
+ /**
492
+ * Generates a random hash value for an object and caches it.
493
+ *
494
+ * **When to use**
495
+ *
496
+ * Use to hash an object by reference identity instead of structural content.
497
+ *
498
+ * **Details**
499
+ *
500
+ * This function creates a random hash value for objects that don't have their own
501
+ * hash implementation. The hash value is cached using a WeakMap, so the same object
502
+ * will always return the same hash value during its lifetime.
503
+ *
504
+ * **Example** (Hashing objects by reference)
505
+ *
506
+ * ```ts import.meta.vitest
507
+ * import { Hash } from "effect"
508
+ *
509
+ * const obj1 = { a: 1 }
510
+ * const obj2 = { a: 1 }
511
+ *
512
+ * Hash.random(obj1) === Hash.random(obj1) // => true
513
+ *
514
+ * typeof Hash.random(obj2) // => "number"
515
+ * ```
516
+ *
517
+ * @stability stable
518
+ * @category hashing
519
+ * @since 2.0.0
520
+ */
521
+ const random = (self) => {
522
+ if (!randomHashCache.has(self)) randomHashCache.set(self, optimize(Math.random() * 4294967296 | 0));
523
+ return randomHashCache.get(self);
524
+ };
525
+ const mix = (h) => {
526
+ h ^= h >>> 16;
527
+ h = Math.imul(h, 2246822507);
528
+ h ^= h >>> 13;
529
+ h = Math.imul(h, 3266489909);
530
+ return h ^ h >>> 16;
531
+ };
532
+ /**
533
+ * Combines two hash values into a single hash value.
534
+ *
535
+ * **When to use**
536
+ *
537
+ * Use to build a hash for a composite value by folding together hash values for
538
+ * its parts.
539
+ *
540
+ * **Details**
541
+ *
542
+ * Supports direct and pipeable usage. Argument order affects the result.
543
+ *
544
+ * **Example** (Combining hash values)
545
+ *
546
+ * ```ts import.meta.vitest
547
+ * import { Hash, pipe } from "effect"
548
+ *
549
+ * const hash1 = Hash.hash("hello")
550
+ * const hash2 = Hash.hash("world")
551
+ *
552
+ * const combined = Hash.combine(hash2)(hash1)
553
+ * combined === pipe(hash1, Hash.combine(hash2)) // => true
554
+ * ```
555
+ *
556
+ * @see {@link hash} for computing hash values from arbitrary inputs
557
+ * @see {@link structureKeys} for hashing selected object fields without manual combination
558
+ *
559
+ * @stability stable
560
+ * @category hashing
561
+ * @since 2.0.0
562
+ */
563
+ const combine = /*#__PURE__*/ dual(2, (self, b) => mix(Math.imul(self, 2654435761) + Math.imul(b, 2246822507)));
564
+ /**
565
+ * Applies bit manipulation techniques to optimize a hash value.
566
+ *
567
+ * **When to use**
568
+ *
569
+ * Use to improve the bit distribution of a raw numeric hash value.
570
+ *
571
+ * **Details**
572
+ *
573
+ * This function takes a hash value and applies bitwise operations to improve
574
+ * the distribution of hash values, reducing the likelihood of collisions.
575
+ *
576
+ * **Example** (Optimizing a hash value)
577
+ *
578
+ * ```ts import.meta.vitest
579
+ * import { Hash } from "effect"
580
+ *
581
+ * Hash.optimize(1234567890) // => 160826066
582
+ * ```
583
+ *
584
+ * @stability stable
585
+ * @category hashing
586
+ * @since 2.0.0
587
+ */
588
+ const optimize = (n) => n & 3221225471 | n >>> 1 & 1073741824;
589
+ /**
590
+ * Checks whether a value implements the Hash interface.
591
+ *
592
+ * **When to use**
593
+ *
594
+ * Use to detect whether an unknown value provides a custom hash implementation.
595
+ *
596
+ * **Details**
597
+ *
598
+ * This function determines whether a given value has a function under the Hash
599
+ * symbol, indicating that it can provide its own hash value implementation.
600
+ * Data that merely carries the key, such as parsed JSON, is hashed as data.
601
+ *
602
+ * **Example** (Checking for Hash support)
603
+ *
604
+ * ```ts import.meta.vitest
605
+ * import { Hash } from "effect"
606
+ *
607
+ * class MyHashable implements Hash.Hash {
608
+ * [Hash.symbol]() {
609
+ * return 42
610
+ * }
611
+ * }
612
+ *
613
+ * Hash.isHash(new MyHashable()) // => true
614
+ * Hash.isHash({}) // => false
615
+ * Hash.isHash("string") // => false
616
+ * ```
617
+ *
618
+ * @stability stable
619
+ * @category guards
620
+ * @since 2.0.0
621
+ */
622
+ const isHash = (u) => hasProperty(u, "~effect/Hash") && typeof u["~effect/Hash"] === "function";
623
+ const float64 = /*#__PURE__*/ new DataView(/*#__PURE__*/ new ArrayBuffer(8));
624
+ /**
625
+ * Computes a hash value for a number.
626
+ *
627
+ * **When to use**
628
+ *
629
+ * Use to hash a JavaScript number with Effect's numeric hash semantics.
630
+ *
631
+ * **Details**
632
+ *
633
+ * Int32 values hash to themselves. Other numbers hash from their IEEE-754 bits,
634
+ * with a canonical representation for `NaN`.
635
+ *
636
+ * **Example** (Hashing numbers)
637
+ *
638
+ * ```ts import.meta.vitest
639
+ * import { Hash } from "effect"
640
+ *
641
+ * Number.isInteger(Hash.number(42)) // => true
642
+ * Number.isInteger(Hash.number(3.14)) // => true
643
+ * Hash.number(NaN) === Hash.number(NaN) // => true
644
+ * Hash.number(Infinity) === Hash.number(Infinity) // => true
645
+ * Hash.number(100) === Hash.number(100) // => true
646
+ * ```
647
+ *
648
+ * @stability stable
649
+ * @category hashing
650
+ * @since 2.0.0
651
+ */
652
+ const number = (n) => {
653
+ const h = n | 0;
654
+ if (h === n) return optimize(h);
655
+ float64.setFloat64(0, n !== n ? NaN : n);
656
+ return optimize(combine(float64.getInt32(0), float64.getInt32(4)));
657
+ };
658
+ /**
659
+ * Computes a hash value for a string using the djb2 algorithm.
660
+ *
661
+ * **When to use**
662
+ *
663
+ * Use when you need a string field to contribute to a custom structural hash
664
+ * implementation.
665
+ *
666
+ * **Details**
667
+ *
668
+ * This function implements a variation of the djb2 hash algorithm, which is
669
+ * known for its good distribution properties and speed. It processes each
670
+ * character of the string to produce a consistent hash value.
671
+ *
672
+ * **Example** (Hashing strings)
673
+ *
674
+ * ```ts import.meta.vitest
675
+ * import { Hash } from "effect"
676
+ *
677
+ * Hash.string("hello") // => 181380007
678
+ * Hash.string("world") // => 164394279
679
+ * Hash.string("") // => 5381
680
+ * Hash.string("test") === Hash.string("test") // => true
681
+ * ```
682
+ *
683
+ * @stability stable
684
+ * @category hashing
685
+ * @since 2.0.0
686
+ */
687
+ const string = (str) => {
688
+ let h = 5381, i = str.length;
689
+ while (i) h = h * 33 ^ str.charCodeAt(--i);
690
+ return optimize(h);
691
+ };
692
+ /**
693
+ * Computes a hash value for an object using only the specified keys.
694
+ *
695
+ * **When to use**
696
+ *
697
+ * Use to hash an object by a selected set of property keys.
698
+ *
699
+ * **Details**
700
+ *
701
+ * This function allows you to hash an object by considering only specific keys,
702
+ * which is useful when you want to create a hash based on a subset of an object's
703
+ * properties.
704
+ *
705
+ * **Example** (Hashing selected object keys)
706
+ *
707
+ * ```ts import.meta.vitest
708
+ * import { Hash } from "effect"
709
+ *
710
+ * const person = { name: "John", age: 30, city: "New York" }
711
+ *
712
+ * const hash1 = Hash.structureKeys(person, ["name", "age"])
713
+ * const hash2 = Hash.structureKeys(person, ["name", "city"])
714
+ *
715
+ * hash1 // => -731887653
716
+ * hash2 // => 148523102
717
+ *
718
+ * const person2 = { name: "John", age: 30, city: "Boston" }
719
+ * const hash3 = Hash.structureKeys(person2, ["name", "age"])
720
+ * hash1 === hash3 // => true
721
+ * ```
722
+ *
723
+ * @stability stable
724
+ * @category hashing
725
+ * @since 2.0.0
726
+ */
727
+ const structureKeys = (o, keys) => {
728
+ let h = 12289;
729
+ for (const key of keys) h ^= combine(hash(key), hash(o[key]));
730
+ return optimize(h);
731
+ };
732
+ /**
733
+ * Computes a structural hash for an object using Effect's object key collection.
734
+ *
735
+ * **When to use**
736
+ *
737
+ * Use to hash an object from all structural keys collected by Effect.
738
+ *
739
+ * **Details**
740
+ *
741
+ * The hash is based on the object's structural keys and their values, including
742
+ * symbol keys and relevant prototype keys for non-plain objects.
743
+ *
744
+ * **Example** (Hashing object structures)
745
+ *
746
+ * ```ts import.meta.vitest
747
+ * import { Hash } from "effect"
748
+ *
749
+ * const obj1 = { name: "John", age: 30 }
750
+ * const obj2 = { name: "Jane", age: 25 }
751
+ * const obj3 = { name: "John", age: 30 }
752
+ *
753
+ * Hash.structure(obj1) // => -731887653
754
+ * Hash.structure(obj2) // => -222100417
755
+ * Hash.structure(obj3) // => -731887653
756
+ * Hash.structure(obj1) === Hash.structure(obj3) // => true
757
+ * ```
758
+ *
759
+ * @stability stable
760
+ * @category hashing
761
+ * @since 2.0.0
762
+ */
763
+ const structure = (o) => structureKeys(o, getAllObjectKeys(o));
764
+ const unordered = (seed, f) => (iter) => {
765
+ let h = seed;
766
+ for (const element of iter) h ^= f(element);
767
+ return optimize(h);
768
+ };
769
+ /**
770
+ * Computes a hash value for an iterable by hashing all of its elements.
771
+ *
772
+ * **When to use**
773
+ *
774
+ * Use to hash the values yielded by an iterable with Effect hash semantics.
775
+ *
776
+ * **Details**
777
+ *
778
+ * Folds element hashes with {@link combine}, so order and length affect the
779
+ * result.
780
+ *
781
+ * **Gotchas**
782
+ *
783
+ * A hash is not an equality proof. Distinct inputs can still share a hash.
784
+ *
785
+ * **Example** (Hashing arrays)
786
+ *
787
+ * ```ts import.meta.vitest
788
+ * import { Hash } from "effect"
789
+ *
790
+ * const arr1 = [1, 2, 3]
791
+ * const arr2 = [1, 2, 3]
792
+ * const arr3 = [3, 2, 1]
793
+ *
794
+ * Hash.array(arr1) === Hash.array(arr2) // => true
795
+ * Hash.array(arr1) === Hash.array(arr3) // => false
796
+ * ```
797
+ *
798
+ * @see {@link hash} for the general-purpose hash dispatcher
799
+ *
800
+ * @stability stable
801
+ * @category hashing
802
+ * @since 2.0.0
803
+ */
804
+ const array = (arr) => {
805
+ let h = 6151;
806
+ for (const element of arr) h = combine(h, hash(element));
807
+ return optimize(h);
808
+ };
809
+ const hashMap = /*#__PURE__*/ unordered(/*#__PURE__*/ string("Map"), ([k, v]) => combine(hash(k), hash(v)));
810
+ const setSeed = /*#__PURE__*/ string("Set");
811
+ const hashSet = /*#__PURE__*/ unordered(setSeed, (element) => combine(setSeed, hash(element)));
812
+ const randomHashCache = /*#__PURE__*/ new WeakMap();
813
+ const hashCache = /*#__PURE__*/ new WeakMap();
814
+ const visitedObjects = /*#__PURE__*/ new WeakSet();
815
+ // node_modules/.pnpm/effect@4.1.2/node_modules/effect/dist/Equal.js
816
+ /**
817
+ * Defines the unique string identifier for the `Equal` interface.
818
+ *
819
+ * **When to use**
820
+ *
821
+ * Use when you implement custom equality and need the computed property key for
822
+ * the equality method.
823
+ *
824
+ * **Details**
825
+ *
826
+ * This is a pure constant with no allocation or side effects.
827
+ *
828
+ * **Example** (Implementing Equal on a class)
829
+ *
830
+ * ```ts import.meta.vitest
831
+ * import { Equal, Hash } from "effect"
832
+ *
833
+ * class UserId implements Equal.Equal {
834
+ * constructor(readonly id: string) {}
835
+ *
836
+ * [Equal.symbol](that: Equal.Equal): boolean {
837
+ * return that instanceof UserId && this.id === that.id
838
+ * }
839
+ *
840
+ * [Hash.symbol](): number {
841
+ * return Hash.string(this.id)
842
+ * }
843
+ * }
844
+ *
845
+ * Equal.equals(new UserId("1"), new UserId("1")) // => true
846
+ * Equal.equals(new UserId("1"), new UserId("2")) // => false
847
+ * ```
848
+ *
849
+ * @see {@link Equal} — the interface that uses this symbol
850
+ * @see {@link isEqual} — type guard for `Equal` implementors
851
+ * @stability stable
852
+ * @category symbols
853
+ * @since 2.0.0
854
+ */
855
+ const symbol = "~effect/Equal";
856
+ function equals() {
857
+ if (arguments.length === 1) return (self) => compareBoth(self, arguments[0]);
858
+ return compareBoth(arguments[0], arguments[1]);
859
+ }
860
+ function compareBoth(self, that) {
861
+ if (self === that) return true;
862
+ if (self == null || that == null) return false;
863
+ const selfType = typeof self;
864
+ if (selfType !== typeof that) return false;
865
+ if (selfType === "number" && self !== self && that !== that) return true;
866
+ if (selfType !== "object" && selfType !== "function") return false;
867
+ if (byReferenceInstances.has(self) || byReferenceInstances.has(that)) return false;
868
+ return compareObjects(self, that);
869
+ }
870
+ function compareObjects(self, that) {
871
+ const depth = pathLeft.length;
872
+ for (let i = depth; i-- > 0;) if (pathLeft[i] === self && pathRight[i] === that) return true;
873
+ if (depth) return compareOnPath(self, that);
874
+ let known = results.get(self);
875
+ if (!known) results.set(self, known = /* @__PURE__ */ new WeakMap());
876
+ let result = known.get(that);
877
+ if (result === void 0) known.set(that, result = compareOnPath(self, that));
878
+ return result;
879
+ }
880
+ function compareOnPath(self, that) {
881
+ pathLeft.push(self);
882
+ pathRight.push(that);
883
+ try {
884
+ return compareStructure(self, that);
885
+ } finally {
886
+ pathLeft.pop();
887
+ pathRight.pop();
888
+ }
889
+ }
890
+ const pathLeft = [];
891
+ const pathRight = [];
892
+ const results = /*#__PURE__*/ new WeakMap();
893
+ function compareStructure(self, that) {
894
+ if (hash(self) !== hash(that)) return false;
895
+ else if (self instanceof Date) {
896
+ if (!(that instanceof Date)) return false;
897
+ const selfTime = self.getTime();
898
+ const thatTime = that.getTime();
899
+ return selfTime === thatTime || Number.isNaN(selfTime) && Number.isNaN(thatTime);
900
+ } else if (self instanceof RegExp) return that instanceof RegExp && self.toString() === that.toString();
901
+ const bothEquals = isEqual(self);
902
+ if (bothEquals !== isEqual(that) || typeof self === "function" && !bothEquals) return false;
903
+ else if (bothEquals) return self[symbol](that);
904
+ else if (Array.isArray(self)) {
905
+ if (!Array.isArray(that) || self.length !== that.length) return false;
906
+ return compareArrays(self, that);
907
+ } else if (isArrayBufferLike(self)) {
908
+ if (!isArrayBufferLike(that) || self instanceof ArrayBuffer !== that instanceof ArrayBuffer) return false;
909
+ const selfBytes = bufferBytes(self);
910
+ const thatBytes = bufferBytes(that);
911
+ return selfBytes !== void 0 && thatBytes !== void 0 && compareTypedArrays(selfBytes, thatBytes);
912
+ } else if (ArrayBuffer.isView(self)) {
913
+ const selfIsDataView = self instanceof DataView;
914
+ if (!ArrayBuffer.isView(that) || self.byteLength !== that.byteLength || selfIsDataView !== that instanceof DataView) return false;
915
+ if (selfIsDataView) return compareTypedArrays(viewBytes(self), viewBytes(that));
916
+ return compareTypedArrays(self, that);
917
+ } else if (self instanceof Map) {
918
+ if (!(that instanceof Map) || self.size !== that.size) return false;
919
+ return compareHashed(self, that, entryHash, equalEntries);
920
+ } else if (self instanceof Set) {
921
+ if (!(that instanceof Set) || self.size !== that.size) return false;
922
+ return compareHashed(self, that, hash, compareBoth);
923
+ }
924
+ return compareRecords(self, that);
925
+ }
926
+ function compareArrays(self, that) {
927
+ for (let i = 0; i < self.length; i++) if (!compareBoth(self[i], that[i])) return false;
928
+ return true;
929
+ }
930
+ function compareTypedArrays(self, that) {
931
+ if (self.length !== that.length) return false;
932
+ for (let i = 0; i < self.length; i++) if (self[i] !== that[i]) return false;
933
+ return true;
934
+ }
935
+ function compareRecords(self, that) {
936
+ const selfKeys = getAllObjectKeys(self);
937
+ const thatKeys = getAllObjectKeys(that);
938
+ if (selfKeys.size !== thatKeys.size) return false;
939
+ for (const key of selfKeys) if (!thatKeys.has(key) || !compareBoth(self[key], that[key])) return false;
940
+ return true;
941
+ }
942
+ function compareHashed(self, that, hashOf, equivalent) {
943
+ const groups = /* @__PURE__ */ new Map();
944
+ let remaining = 0;
945
+ for (const item of that) {
946
+ const h = hashOf(item);
947
+ const group = groups.get(h);
948
+ if (group) group.push(item);
949
+ else groups.set(h, [item]);
950
+ remaining++;
951
+ }
952
+ outer: for (const item of self) {
953
+ const group = groups.get(hashOf(item));
954
+ if (group) {
955
+ for (let i = 0; i < group.length; i++) if (equivalent(item, group[i])) {
956
+ group[i] = group[group.length - 1];
957
+ group.pop();
958
+ remaining--;
959
+ continue outer;
960
+ }
961
+ }
962
+ return false;
963
+ }
964
+ return remaining === 0;
965
+ }
966
+ const entryHash = (entry) => hash(entry[0]);
967
+ const equalEntries = (self, that) => compareBoth(self[0], that[0]) && compareBoth(self[1], that[1]);
968
+ /**
969
+ * Checks whether a value implements the {@link Equal} interface.
970
+ *
971
+ * **When to use**
972
+ *
973
+ * Use when you need generic utility code to distinguish `Equal` implementors
974
+ * from plain values before calling `[Equal.symbol]` directly.
975
+ *
976
+ * **Details**
977
+ *
978
+ * - Pure function, no side effects.
979
+ * - Returns `true` if and only if `u` has a function keyed by {@link symbol}.
980
+ * Data that merely carries the key, such as parsed JSON, is not `Equal`.
981
+ * - Acts as a TypeScript type guard, narrowing the input to {@link Equal}.
982
+ *
983
+ * **Example** (Checking Equal values)
984
+ *
985
+ * ```ts import.meta.vitest
986
+ * import { Equal, Hash } from "effect"
987
+ *
988
+ * class Token implements Equal.Equal {
989
+ * constructor(readonly value: string) {}
990
+ * [Equal.symbol](that: Equal.Equal): boolean {
991
+ * return that instanceof Token && this.value === that.value
992
+ * }
993
+ * [Hash.symbol](): number {
994
+ * return Hash.string(this.value)
995
+ * }
996
+ * }
997
+ *
998
+ * Equal.isEqual(new Token("abc")) // => true
999
+ * Equal.isEqual({ x: 1 }) // => false
1000
+ * Equal.isEqual(42) // => false
1001
+ * ```
1002
+ *
1003
+ * @see {@link Equal} — the interface being checked
1004
+ * @see {@link symbol} — the property key that signals `Equal` support
1005
+ * @stability stable
1006
+ * @category guards
1007
+ * @since 2.0.0
1008
+ */
1009
+ const isEqual = (u) => hasProperty(u, "~effect/Equal") && typeof u["~effect/Equal"] === "function";
1010
+ // node_modules/.pnpm/effect@4.1.2/node_modules/effect/dist/Redactable.js
1011
+ /**
1012
+ * Defines the symbol used to identify objects that implement the {@link Redactable}
1013
+ * protocol.
1014
+ *
1015
+ * **When to use**
1016
+ *
1017
+ * Use as the property key when implementing the `Redactable` protocol.
1018
+ *
1019
+ * **Details**
1020
+ *
1021
+ * Add a method under this key to make an object redactable. The method receives
1022
+ * the current `Context` and must return the replacement value. The symbol is
1023
+ * registered globally via `Symbol.for("~effect/Redactable")`, so it is
1024
+ * identical across multiple copies of the library at runtime.
1025
+ *
1026
+ * **Example** (Masking an API key)
1027
+ *
1028
+ * ```ts import.meta.vitest
1029
+ * import { Context, Redactable } from "effect"
1030
+ *
1031
+ * class ApiKey {
1032
+ * constructor(readonly raw: string) {}
1033
+ *
1034
+ * [Redactable.symbolRedactable](_ctx: Context.Context<never>) {
1035
+ * return this.raw.slice(0, 4) + "..."
1036
+ * }
1037
+ * }
1038
+ *
1039
+ * Redactable.redact(new ApiKey("secret-key")) // => "secr..."
1040
+ * ```
1041
+ *
1042
+ * @see {@link Redactable} for the interface this symbol belongs to
1043
+ * @see {@link isRedactable} to check whether a value has this symbol
1044
+ * @stability stable
1045
+ * @category symbols
1046
+ * @since 3.10.0
1047
+ */
1048
+ const symbolRedactable = /*#__PURE__*/ Symbol.for("~effect/Redactable");
1049
+ /**
1050
+ * Type guard that checks whether a value implements the {@link Redactable}
1051
+ * interface.
1052
+ *
1053
+ * **When to use**
1054
+ *
1055
+ * Use to narrow an unknown value before calling redaction-specific helpers.
1056
+ *
1057
+ * @see {@link Redactable} for the interface being checked
1058
+ * @see {@link redact} to apply redaction if the value is redactable
1059
+ * @stability stable
1060
+ * @category guards
1061
+ * @since 3.10.0
1062
+ */
1063
+ const isRedactable = (u) => hasProperty(u, symbolRedactable);
1064
+ /**
1065
+ * Returns a redacted value if it implements {@link Redactable}, otherwise returns it
1066
+ * unchanged.
1067
+ *
1068
+ * **When to use**
1069
+ *
1070
+ * Use as the general-purpose entry point for redaction when the input may
1071
+ * or may not implement the redaction protocol.
1072
+ *
1073
+ * **Details**
1074
+ *
1075
+ * This function calls {@link isRedactable} and, when it returns `true`,
1076
+ * delegates to {@link getRedacted}.
1077
+ *
1078
+ * **Gotchas**
1079
+ *
1080
+ * Redaction is not recursive. Nested redactable values inside the returned
1081
+ * object are not automatically redacted.
1082
+ *
1083
+ * @see {@link isRedactable} to check before redacting
1084
+ * @see {@link getRedacted} for the lower-level variant for known redactables
1085
+ * @stability stable
1086
+ * @category destructors
1087
+ * @since 3.10.0
1088
+ */
1089
+ function redact(u) {
1090
+ if (isRedactable(u)) return getRedacted(u);
1091
+ return u;
1092
+ }
1093
+ /**
1094
+ * Returns the result of calling `[symbolRedactable]` on a value that is
1095
+ * already known to be {@link Redactable}.
1096
+ *
1097
+ * **When to use**
1098
+ *
1099
+ * Use when you need to read the redacted representation from a value already
1100
+ * verified as `Redactable`.
1101
+ *
1102
+ * **Details**
1103
+ *
1104
+ * This function reads the current fiber's `Context` from the global fiber
1105
+ * reference and passes it to the redaction method.
1106
+ *
1107
+ * **Gotchas**
1108
+ *
1109
+ * If no fiber is active, an empty `Context` is passed to the redaction method.
1110
+ *
1111
+ * @see {@link redact} for the higher-level variant that handles non-redactable values
1112
+ * @see {@link isRedactable} for the type guard to verify before calling this
1113
+ * @stability stable
1114
+ * @category destructors
1115
+ * @since 4.0.0
1116
+ */
1117
+ function getRedacted(redactable) {
1118
+ return redactable[symbolRedactable](globalThis["~effect/Fiber/currentFiber"]?.context ?? emptyContext);
1119
+ }
1120
+ const emptyMap = /*#__PURE__*/ new Map();
1121
+ const emptyContext = {
1122
+ "~effect/Context": {},
1123
+ base: emptyMap,
1124
+ depth: 0,
1125
+ mapUnsafe: emptyMap,
1126
+ pipe() {
1127
+ return pipeArguments(this, arguments);
1128
+ }
1129
+ };
1130
+ // node_modules/.pnpm/effect@4.1.2/node_modules/effect/dist/Formatter.js
1131
+ /**
1132
+ * Formats JavaScript values into readable strings.
1133
+ *
1134
+ * `format` is intended for logs, diagnostics, and error messages. It handles
1135
+ * primitives, objects, arrays, dates, regular expressions, maps, sets, class
1136
+ * instances, errors, circular references, and redactable values. `formatJson`
1137
+ * wraps JSON formatting with redaction and circular-reference handling, and the
1138
+ * module also includes helpers for property keys, paths, and dates.
1139
+ *
1140
+ * @stability stable
1141
+ * @since 4.0.0
1142
+ */
1143
+ /**
1144
+ * Converts any JavaScript value into a human-readable string.
1145
+ *
1146
+ * **When to use**
1147
+ *
1148
+ * Use when you need to format arbitrary JavaScript values for debugging,
1149
+ * logging, or error messages.
1150
+ *
1151
+ * **Details**
1152
+ *
1153
+ * - Output is **not** valid JSON; use {@link formatJson} when you need
1154
+ * parseable JSON.
1155
+ * - Handles `BigInt`, `Symbol`, `Set`, `Map`, `Date`, `RegExp`, and class
1156
+ * instances that `JSON.stringify` cannot represent.
1157
+ * - Circular references are shown as `"[Circular]"` instead of throwing.
1158
+ * - Failures while inspecting a value are rendered as diagnostic placeholders instead of throwing.
1159
+ * - Primitives: stringified naturally (`null`, `undefined`, `123`, `true`).
1160
+ * Strings are JSON-quoted.
1161
+ * - Objects with a custom `toString` (not `Object.prototype.toString`):
1162
+ * `toString()` is called unless `ignoreToString` is `true`.
1163
+ * - Errors with a `cause`: formatted as `"<message> (cause: <cause>)"`.
1164
+ * - Iterables (`Set`, `Map`, etc.): formatted as
1165
+ * `ClassName([...elements])`.
1166
+ * - Class instances: wrapped as `ClassName({...})`.
1167
+ * - `Redactable` values are automatically redacted.
1168
+ * - Arrays/objects with 0–1 entries are inline; larger ones are
1169
+ * pretty-printed when `space` is set.
1170
+ * - `space` — indentation unit (number of spaces, or a string like
1171
+ * `"\t"`). Defaults to `0` (compact).
1172
+ * - `ignoreToString` — skip calling `toString()`. Defaults to `false`.
1173
+ *
1174
+ * **Example** (Formatting compact output)
1175
+ *
1176
+ * ```ts import.meta.vitest
1177
+ * import { Formatter } from "effect"
1178
+ *
1179
+ * Formatter.format({ a: 1, b: [2, 3] }) // => "{\"a\":1,\"b\":[2,3]}"
1180
+ * ```
1181
+ *
1182
+ * **Example** (Pretty-printed output)
1183
+ *
1184
+ * ```ts import.meta.vitest
1185
+ * import { Formatter } from "effect"
1186
+ *
1187
+ * const output = Formatter.format({ a: 1, b: [2, 3] }, { space: 2 })
1188
+ * output // => "{\n \"a\": 1,\n \"b\": [\n 2,\n 3\n ]\n}"
1189
+ * ```
1190
+ *
1191
+ * **Example** (Handling circular references)
1192
+ *
1193
+ * ```ts import.meta.vitest
1194
+ * import { Formatter } from "effect"
1195
+ *
1196
+ * const obj: any = { name: "loop" }
1197
+ * obj.self = obj
1198
+ * Formatter.format(obj) // => "{\"name\":\"loop\",\"self\":[Circular]}"
1199
+ * ```
1200
+ *
1201
+ * @see {@link formatJson}
1202
+ * @see {@link Formatter}
1203
+ * @stability stable
1204
+ * @category formatting
1205
+ * @since 2.0.0
1206
+ */
1207
+ function format(input, options) {
1208
+ const space = options?.space ?? 0;
1209
+ const ancestors = /* @__PURE__ */ new WeakSet();
1210
+ const gap = !space ? "" : typeof space === "number" ? " ".repeat(space) : space;
1211
+ const ind = (d) => gap.repeat(d);
1212
+ const wrap = (v, body) => {
1213
+ const ctor = v?.constructor;
1214
+ return ctor && ctor !== Object.prototype.constructor && ctor.name ? `${ctor.name}(${body})` : body;
1215
+ };
1216
+ const ownKeys = (o) => {
1217
+ try {
1218
+ return Reflect.ownKeys(o);
1219
+ } catch {
1220
+ return ["[ownKeys threw]"];
1221
+ }
1222
+ };
1223
+ function recur(v, d = 0) {
1224
+ try {
1225
+ return recurUnsafe(v, d);
1226
+ } catch {
1227
+ if (typeof v === "object" && v !== null || typeof v === "function") ancestors.delete(v);
1228
+ return "[inspection threw]";
1229
+ }
1230
+ }
1231
+ function recurUnsafe(v, d = 0) {
1232
+ if (typeof v === "string") return JSON.stringify(v);
1233
+ if (typeof v === "number" || v == null || typeof v === "boolean" || typeof v === "symbol") return String(v);
1234
+ if (typeof v === "bigint") return String(v) + "n";
1235
+ if (typeof v === "object" || typeof v === "function") {
1236
+ if (ancestors.has(v)) return CIRCULAR;
1237
+ ancestors.add(v);
1238
+ let output;
1239
+ if (symbolRedactable in v) output = recur(getRedacted(v), d);
1240
+ else if (Array.isArray(v)) output = !gap || v.length <= 1 ? `[${v.map((x) => recur(x, d)).join(",")}]` : `[\n${ind(d + 1)}${v.map((x) => recur(x, d + 1)).join(",\n" + ind(d + 1))}\n${ind(d)}]`;
1241
+ else if (v instanceof Date) output = formatDate(v);
1242
+ else if (!options?.ignoreToString && hasProperty(v, "toString") && typeof v["toString"] === "function" && v["toString"] !== Object.prototype.toString && v["toString"] !== Array.prototype.toString) {
1243
+ const s = safeToString(v);
1244
+ output = v instanceof Error && v.cause !== void 0 ? `${s} (cause: ${recur(v.cause, d)})` : s;
1245
+ } else if (Symbol.iterator in v) output = `${v.constructor.name}(${recur(Array.from(v), d)})`;
1246
+ else {
1247
+ const keys = ownKeys(v);
1248
+ if (!gap || keys.length <= 1) {
1249
+ const body = `{${keys.map((k) => `${formatPropertyKey(k)}:${recur(safeGet(v, k), d)}`).join(",")}}`;
1250
+ output = wrap(v, body);
1251
+ } else {
1252
+ const body = `{\n${keys.map((k) => `${ind(d + 1)}${formatPropertyKey(k)}: ${recur(safeGet(v, k), d + 1)}`).join(",\n")}\n${ind(d)}}`;
1253
+ output = wrap(v, body);
1254
+ }
1255
+ }
1256
+ ancestors.delete(v);
1257
+ return output;
1258
+ }
1259
+ return String(v);
1260
+ }
1261
+ return recur(input, 0);
1262
+ }
1263
+ const CIRCULAR = "[Circular]";
1264
+ /**
1265
+ * @internal
1266
+ */
1267
+ function formatPropertyKey(name) {
1268
+ return typeof name === "string" ? JSON.stringify(name) : String(name);
1269
+ }
1270
+ /**
1271
+ * Formats a `Date` as an ISO 8601 string, returning `"Invalid Date"` for
1272
+ * invalid dates instead of throwing.
1273
+ *
1274
+ * @internal
1275
+ */
1276
+ function formatDate(date) {
1277
+ try {
1278
+ return date.toISOString();
1279
+ } catch {
1280
+ return "Invalid Date";
1281
+ }
1282
+ }
1283
+ function safeToString(input) {
1284
+ try {
1285
+ const s = input.toString();
1286
+ return typeof s === "string" ? s : String(s);
1287
+ } catch {
1288
+ return "[toString threw]";
1289
+ }
1290
+ }
1291
+ function safeGet(input, key) {
1292
+ try {
1293
+ return input[key];
1294
+ } catch {
1295
+ return "[property access threw]";
1296
+ }
1297
+ }
1298
+ // node_modules/.pnpm/effect@4.1.2/node_modules/effect/dist/Inspectable.js
1299
+ /**
1300
+ * Defines the symbol used by Node.js for custom object inspection.
1301
+ *
1302
+ * **When to use**
1303
+ *
1304
+ * Use to implement Node.js custom inspection for a value.
1305
+ *
1306
+ * **Details**
1307
+ *
1308
+ * This symbol is recognized by Node.js's `util.inspect()` function and the REPL
1309
+ * for custom object representation. When an object has a method with this symbol,
1310
+ * it will be called to determine how the object should be displayed.
1311
+ *
1312
+ * **Example** (Defining custom Node inspection)
1313
+ *
1314
+ * ```ts import.meta.vitest
1315
+ * import { Inspectable } from "effect"
1316
+ *
1317
+ * class CustomObject {
1318
+ * constructor(private value: string) {}
1319
+ *
1320
+ * [Inspectable.NodeInspectSymbol]() {
1321
+ * return `CustomObject(${this.value})`
1322
+ * }
1323
+ * }
1324
+ *
1325
+ * const obj = new CustomObject("hello")
1326
+ * obj[Inspectable.NodeInspectSymbol]() // => "CustomObject(hello)"
1327
+ * ```
1328
+ *
1329
+ * @stability stable
1330
+ * @category symbols
1331
+ * @since 2.0.0
1332
+ */
1333
+ const NodeInspectSymbol = /*#__PURE__*/ Symbol.for("nodejs.util.inspect.custom");
1334
+ /**
1335
+ * Converts a value to its structured inspection representation.
1336
+ *
1337
+ * **When to use**
1338
+ *
1339
+ * Use when you need the structured representation of an inspectable value
1340
+ * without risking unhandled errors.
1341
+ *
1342
+ * **Details**
1343
+ *
1344
+ * This function applies redaction before extracting data from objects that
1345
+ * implement `toJSON`, recursively processes arrays, and handles errors
1346
+ * gracefully. Plain objects are returned unchanged, so the result is not
1347
+ * guaranteed to be accepted by `JSON.stringify`; it may still contain values
1348
+ * such as `BigInt`, functions, or circular references.
1349
+ *
1350
+ * @see {@link toStringUnknown} for converting unknown values to strings
1351
+ *
1352
+ * @stability stable
1353
+ * @category converting
1354
+ * @since 4.0.0
1355
+ */
1356
+ const toJson = (input) => {
1357
+ try {
1358
+ input = redact(input);
1359
+ if (hasProperty(input, "toJSON") && isFunction(input["toJSON"]) && input["toJSON"].length === 0) return input.toJSON();
1360
+ else if (Array.isArray(input)) return input.map(toJson);
1361
+ return input;
1362
+ } catch {
1363
+ return "[toJSON threw]";
1364
+ }
1365
+ };
1366
+ // node_modules/.pnpm/effect@4.1.2/node_modules/effect/dist/Utils.js
1367
+ /**
1368
+ * Yields its wrapped value exactly once, then completes with the value sent
1369
+ * back in.
1370
+ *
1371
+ * **When to use**
1372
+ *
1373
+ * Use to implement `[Symbol.iterator]()` on Effect-like types so they can be
1374
+ * `yield*`-ed inside generator functions, such as `Effect.gen` and
1375
+ * `Option.gen`.
1376
+ *
1377
+ * **Details**
1378
+ *
1379
+ * The first call to `next()` returns a fresh `{ value: self, done: false }`.
1380
+ * Every subsequent call returns `{ value: a, done: true }` where `a` is the
1381
+ * argument passed to `next()`. To keep `yield*` cheap, the completion result
1382
+ * is the iterator itself rather than a new object, so only the iterator and
1383
+ * the single yielded result are allocated per `yield*`.
1384
+ *
1385
+ * **Example** (Yielding a wrapped value in a generator)
1386
+ *
1387
+ * ```ts import.meta.vitest
1388
+ * import { Utils } from "effect"
1389
+ *
1390
+ * const gen = new Utils.SingleShotGen<string, number>("hello")
1391
+ *
1392
+ * gen.next(0).value // => "hello"
1393
+ *
1394
+ * gen.next(42).value // => 42
1395
+ * ```
1396
+ *
1397
+ * @see {@link Gen} for the type-level signature that relies on `SingleShotGen`
1398
+ * @stability stable
1399
+ * @category constructors
1400
+ * @since 2.0.0
1401
+ */
1402
+ var SingleShotGen = class {
1403
+ constructor(self) {
1404
+ this.value = self;
1405
+ this.done = false;
1406
+ }
1407
+ /**
1408
+ * Yields the stored value once, then completes with the value sent back in.
1409
+ *
1410
+ * **When to use**
1411
+ *
1412
+ * Use to advance a `SingleShotGen` through its single yield and completion
1413
+ * step.
1414
+ *
1415
+ * @since 2.0.0
1416
+ */
1417
+ next(a) {
1418
+ if (this.done) {
1419
+ this.value = a;
1420
+ return this;
1421
+ }
1422
+ this.done = true;
1423
+ return {
1424
+ value: this.value,
1425
+ done: false
1426
+ };
1427
+ }
1428
+ };
1429
+ // node_modules/.pnpm/effect@4.1.2/node_modules/effect/dist/internal/core.js
1430
+ /** @internal */
1431
+ const EffectTypeId = `~effect/Effect`;
1432
+ `${EffectTypeId}`;
1433
+ `${EffectTypeId}`;
1434
+ /** @internal */
1435
+ const PipeInspectableProto = {
1436
+ pipe() {
1437
+ return pipeArguments(this, arguments);
1438
+ },
1439
+ toJSON() {
1440
+ return { ...this };
1441
+ },
1442
+ toString() {
1443
+ return format(this.toJSON(), {
1444
+ ignoreToString: true,
1445
+ space: 2
1446
+ });
1447
+ },
1448
+ [NodeInspectSymbol]() {
1449
+ return this.toJSON();
1450
+ }
1451
+ };
1452
+ ({ ...PipeInspectableProto });
1453
+ // node_modules/.pnpm/effect@4.1.2/node_modules/effect/dist/internal/option.js
1454
+ /**
1455
+ * @since 2.0.0
1456
+ */
1457
+ const TypeId = "~effect/Option";
1458
+ const CommonProto = {
1459
+ [TypeId]: { _A: (_) => _ },
1460
+ ...PipeInspectableProto,
1461
+ [Symbol.iterator]() {
1462
+ return new SingleShotGen(this);
1463
+ }
1464
+ };
1465
+ const SomeProto = /*#__PURE__*/ Object.defineProperty(/*#__PURE__*/ Object.assign(/*#__PURE__*/ Object.create(CommonProto), {
1466
+ _tag: "Some",
1467
+ _op: "Some",
1468
+ [symbol](that) {
1469
+ return isOption(that) && isSome$1(that) && equals(this.value, that.value);
1470
+ },
1471
+ [symbol$1]() {
1472
+ return combine(hash(this._tag))(hash(this.value));
1473
+ },
1474
+ toString() {
1475
+ return `some(${format(this.value)})`;
1476
+ },
1477
+ toJSON() {
1478
+ return {
1479
+ _id: "Option",
1480
+ _tag: this._tag,
1481
+ value: toJson(this.value)
1482
+ };
1483
+ }
1484
+ }), "valueOrUndefined", { get() {
1485
+ return this.value;
1486
+ } });
1487
+ const NoneHash = /*#__PURE__*/ hash("None");
1488
+ const NoneProto = /*#__PURE__*/ Object.assign(/*#__PURE__*/ Object.create(CommonProto), {
1489
+ _tag: "None",
1490
+ _op: "None",
1491
+ valueOrUndefined: void 0,
1492
+ [symbol](that) {
1493
+ return isOption(that) && isNone$1(that);
1494
+ },
1495
+ [symbol$1]() {
1496
+ return NoneHash;
1497
+ },
1498
+ toString() {
1499
+ return `none()`;
1500
+ },
1501
+ toJSON() {
1502
+ return {
1503
+ _id: "Option",
1504
+ _tag: this._tag
1505
+ };
1506
+ }
1507
+ });
1508
+ /** @internal */
1509
+ const isOption = (input) => hasProperty(input, TypeId);
1510
+ /** @internal */
1511
+ const isNone$1 = (fa) => fa._tag === "None";
1512
+ /** @internal */
1513
+ const isSome$1 = (fa) => fa._tag === "Some";
1514
+ /** @internal */
1515
+ const none$1 = /*#__PURE__*/ Object.create(NoneProto);
1516
+ /** @internal */
1517
+ const SomeImpl = function(value) {
1518
+ this.value = value;
1519
+ };
1520
+ SomeImpl.prototype = SomeProto;
1521
+ /** @internal */
1522
+ const some$1 = (value) => new SomeImpl(value);
1523
+ // node_modules/.pnpm/effect@4.1.2/node_modules/effect/dist/Option.js
1524
+ /**
1525
+ * Creates an `Option` representing the absence of a value.
1526
+ *
1527
+ * **When to use**
1528
+ *
1529
+ * Use to represent a missing or uninitialized value, such as returning "no
1530
+ * result" from a function.
1531
+ *
1532
+ * **Details**
1533
+ *
1534
+ * - Returns `Option<never>`, which is a subtype of `Option<A>` for any `A`
1535
+ * - Always returns the same singleton instance
1536
+ *
1537
+ * **Example** (Creating an empty Option)
1538
+ *
1539
+ * ```ts import.meta.vitest
1540
+ * import { Option } from "effect"
1541
+ *
1542
+ * // ┌─── Option<never>
1543
+ * // ▼
1544
+ * const noValue = Option.none() // => Option.none()
1545
+ * ```
1546
+ *
1547
+ * @see {@link some} for the opposite operation.
1548
+ *
1549
+ * @stability stable
1550
+ * @category constructors
1551
+ * @since 2.0.0
1552
+ */
1553
+ const none = () => none$1;
1554
+ /**
1555
+ * Wraps the given value into an `Option` to represent its presence.
1556
+ *
1557
+ * **When to use**
1558
+ *
1559
+ * Use to wrap a known present value as `Option`
1560
+ * - Returning a successful result from a partial function
1561
+ *
1562
+ * **Details**
1563
+ *
1564
+ * - Always returns `Some<A>`
1565
+ * - Does not filter `null` or `undefined`; use {@link fromNullishOr} for that
1566
+ *
1567
+ * **Example** (Wrapping a value)
1568
+ *
1569
+ * ```ts import.meta.vitest
1570
+ * import { Option } from "effect"
1571
+ *
1572
+ * // ┌─── Option<number>
1573
+ * // ▼
1574
+ * const value = Option.some(1) // => Option.some(1)
1575
+ * ```
1576
+ *
1577
+ * @see {@link none} for the opposite operation.
1578
+ *
1579
+ * @stability stable
1580
+ * @category constructors
1581
+ * @since 2.0.0
1582
+ */
1583
+ const some = some$1;
1584
+ /**
1585
+ * Checks whether an `Option` is `None` (absent).
1586
+ *
1587
+ * **When to use**
1588
+ *
1589
+ * Use when you need to branch on an absent `Option` before accessing `.value`.
1590
+ *
1591
+ * **Details**
1592
+ *
1593
+ * - Acts as a type guard, narrowing to `None<A>`
1594
+ *
1595
+ * **Example** (Checking for None)
1596
+ *
1597
+ * ```ts import.meta.vitest
1598
+ * import { Option } from "effect"
1599
+ *
1600
+ * Option.isNone(Option.some(1)) // => false
1601
+ * Option.isNone(Option.none()) // => true
1602
+ * ```
1603
+ *
1604
+ * @see {@link isSome} for the opposite check.
1605
+ *
1606
+ * @stability stable
1607
+ * @category guards
1608
+ * @since 2.0.0
1609
+ */
1610
+ const isNone = isNone$1;
1611
+ /**
1612
+ * Checks whether an `Option` contains a value (`Some`).
1613
+ *
1614
+ * **When to use**
1615
+ *
1616
+ * Use when you need to branch on a present `Option` before accessing `.value`.
1617
+ *
1618
+ * **Details**
1619
+ *
1620
+ * - Acts as a type guard, narrowing to `Some<A>`
1621
+ *
1622
+ * **Example** (Checking for Some)
1623
+ *
1624
+ * ```ts import.meta.vitest
1625
+ * import { Option } from "effect"
1626
+ *
1627
+ * Option.isSome(Option.some(1)) // => true
1628
+ * Option.isSome(Option.none()) // => false
1629
+ * ```
1630
+ *
1631
+ * @see {@link isNone} for the opposite check.
1632
+ *
1633
+ * @stability stable
1634
+ * @category guards
1635
+ * @since 2.0.0
1636
+ */
1637
+ const isSome = isSome$1;
1638
+ /**
1639
+ * Pattern-matches on an `Option`, handling both `None` and `Some` cases.
1640
+ *
1641
+ * **When to use**
1642
+ *
1643
+ * Use when you need to handle both `Some` and `None` in one expression and
1644
+ * transform an `Option` into a plain value.
1645
+ *
1646
+ * **Details**
1647
+ *
1648
+ * - If `None`, calls `onNone` and returns its result
1649
+ * - If `Some`, calls `onSome` with the value and returns its result
1650
+ * - Supports the `dual` API (data-last and data-first)
1651
+ *
1652
+ * **Example** (Matching on an Option)
1653
+ *
1654
+ * ```ts import.meta.vitest
1655
+ * import { Option } from "effect"
1656
+ *
1657
+ * Option.match(Option.some(1), {
1658
+ * onNone: () => "Option is empty",
1659
+ * onSome: (value) => `Option has a value: ${value}`
1660
+ * }) // => "Option has a value: 1"
1661
+ * ```
1662
+ *
1663
+ * @see {@link getOrElse} for unwrapping with a default
1664
+ *
1665
+ * @stability stable
1666
+ * @category pattern matching
1667
+ * @since 2.0.0
1668
+ */
1669
+ const match = /*#__PURE__*/ dual(2, (self, { onNone, onSome }) => isNone(self) ? onNone() : onSome(self.value));
1670
+ /**
1671
+ * Transforms the value inside a `Some` using the provided function, leaving
1672
+ * `None` unchanged.
1673
+ *
1674
+ * **When to use**
1675
+ *
1676
+ * Use to apply a pure transformation to an `Option`'s present value, especially
1677
+ * when chaining transformations in a pipeline.
1678
+ *
1679
+ * **Details**
1680
+ *
1681
+ * - `Some` → applies `f` and wraps the result in a new `Some`
1682
+ * - `None` → returns `None` unchanged
1683
+ *
1684
+ * **Example** (Mapping over an Option)
1685
+ *
1686
+ * ```ts import.meta.vitest
1687
+ * import { Option } from "effect"
1688
+ *
1689
+ * Option.map(Option.some(2), (n) => n * 2) // => Option.some(4)
1690
+ * Option.map(Option.none(), (n: number) => n * 2) // => Option.none()
1691
+ * ```
1692
+ *
1693
+ * @see {@link flatMap} when `f` returns an `Option`
1694
+ * @see {@link as} to replace the value with a constant
1695
+ *
1696
+ * @stability stable
1697
+ * @category mapping
1698
+ * @since 2.0.0
1699
+ */
1700
+ const map = /*#__PURE__*/ dual(2, (self, f) => isNone(self) ? none() : some(f(self.value)));
1701
+ /**
1702
+ * Applies a function that returns an `Option` to the value of a `Some`,
1703
+ * flattening the result. Returns `None` if the input is `None`.
1704
+ *
1705
+ * **When to use**
1706
+ *
1707
+ * Use when you need to chain dependent `Option` computations where each step
1708
+ * may return `None`.
1709
+ *
1710
+ * **Details**
1711
+ *
1712
+ * - `Some` → applies `f` to the value and returns its `Option` result
1713
+ * - `None` → returns `None` without calling `f`
1714
+ * - Equivalent to `map` followed by {@link flatten}
1715
+ *
1716
+ * **Example** (Chaining optional lookups)
1717
+ *
1718
+ * ```ts import.meta.vitest
1719
+ * import { Option } from "effect"
1720
+ *
1721
+ * interface User {
1722
+ * readonly name: string
1723
+ * readonly address: Option.Option<{ readonly street: Option.Option<string> }>
1724
+ * }
1725
+ *
1726
+ * const user: User = {
1727
+ * name: "John",
1728
+ * address: Option.some({ street: Option.some("123 Main St") })
1729
+ * }
1730
+ *
1731
+ * user.address.pipe(
1732
+ * Option.flatMap((addr) => addr.street)
1733
+ * ) // => Option.some("123 Main St")
1734
+ * ```
1735
+ *
1736
+ * @see {@link map} when `f` returns a plain value
1737
+ * @see {@link andThen} for a more flexible variant
1738
+ * @see {@link flatten} to unwrap a nested `Option<Option<A>>`
1739
+ *
1740
+ * @stability stable
1741
+ * @category sequencing
1742
+ * @since 2.0.0
1743
+ */
1744
+ const flatMap = /*#__PURE__*/ dual(2, (self, f) => isNone(self) ? none() : f(self.value));
1745
+ /**
1746
+ * Filters an `Option` using a predicate. Returns `None` if the predicate is
1747
+ * not satisfied or the input is `None`.
1748
+ *
1749
+ * **When to use**
1750
+ *
1751
+ * Use when you need to discard an `Option`'s present value when it does not
1752
+ * meet a condition, while narrowing the type via a refinement predicate.
1753
+ *
1754
+ * **Details**
1755
+ *
1756
+ * - `None` → `None`
1757
+ * - `Some` where `predicate(value)` is `true` → `Some(value)`
1758
+ * - `Some` where `predicate(value)` is `false` → `None`
1759
+ * - Supports refinements for type narrowing
1760
+ *
1761
+ * **Example** (Filtering with a predicate)
1762
+ *
1763
+ * ```ts import.meta.vitest
1764
+ * import { Option } from "effect"
1765
+ *
1766
+ * const removeEmpty = (input: Option.Option<string>) =>
1767
+ * Option.filter(input, (value) => value !== "")
1768
+ *
1769
+ * removeEmpty(Option.some("hello")) // => Option.some("hello")
1770
+ * removeEmpty(Option.some("")) // => Option.none()
1771
+ * removeEmpty(Option.none()) // => Option.none()
1772
+ * ```
1773
+ *
1774
+ * @see {@link filterMap} to transform and filter simultaneously
1775
+ * @see {@link exists} to test without filtering
1776
+ *
1777
+ * @stability stable
1778
+ * @category filtering
1779
+ * @since 2.0.0
1780
+ */
1781
+ const filter = /*#__PURE__*/ dual(2, (self, predicate) => isNone(self) ? none() : predicate(self.value) ? some(self.value) : none());
1782
+ /**
1783
+ * Checks whether the value in a `Some` satisfies a predicate or refinement.
1784
+ *
1785
+ * **When to use**
1786
+ *
1787
+ * Use to check a condition on an optional value without unwrapping
1788
+ *
1789
+ * **Details**
1790
+ *
1791
+ * - `None` → `false`
1792
+ * - `Some` where `predicate(value)` is `true` → `true`
1793
+ * - `Some` where `predicate(value)` is `false` → `false`
1794
+ * - With a refinement, narrows the `Option` type on `true`
1795
+ *
1796
+ * **Example** (Testing a condition)
1797
+ *
1798
+ * ```ts import.meta.vitest
1799
+ * import { Option } from "effect"
1800
+ *
1801
+ * const isEven = (n: number) => n % 2 === 0
1802
+ *
1803
+ * Option.some(2).pipe(Option.exists(isEven)) // => true
1804
+ * Option.some(1).pipe(Option.exists(isEven)) // => false
1805
+ * Option.none().pipe(Option.exists(isEven)) // => false
1806
+ * ```
1807
+ *
1808
+ * @see {@link filter} to keep or discard based on a predicate
1809
+ * @see {@link contains} to test for a specific value
1810
+ *
1811
+ * @stability stable
1812
+ * @category predicates
1813
+ * @since 2.0.0
1814
+ */
1815
+ const exists = /*#__PURE__*/ dual(2, (self, refinement) => isNone(self) ? false : refinement(self.value));
1816
+ // src/utils.ts
1817
+ const asAstNode = (node) => typeof node === "object" && node !== null && "type" in node && typeof node.type === "string" ? some(node) : none();
1818
+ const isExpressionWrapper = (node) => node.type === "ChainExpression" || node.type === "ParenthesizedExpression" || node.type === "TSNonNullExpression" || node.type === "TSAsExpression" || node.type === "TSTypeAssertion";
1819
+ function unwrapExpression(node) {
1820
+ let current = asAstNode(node);
1821
+ while (isSome(current) && isExpressionWrapper(current.value)) current = asAstNode(current.value.expression);
1822
+ return current;
1823
+ }
1824
+ function getPropertyName(node) {
1825
+ return flatMap(asAstNode(node), (expression) => {
1826
+ if (expression.type === "Identifier" && typeof expression.name === "string") return some(expression.name);
1827
+ if (expression.type === "PrivateIdentifier" && typeof expression.name === "string") return some(expression.name);
1828
+ if (expression.type === "Literal" && typeof expression.value === "string") return some(expression.value);
1829
+ return none();
1830
+ });
1831
+ }
1832
+ function isIdentifier(node, name) {
1833
+ if (isNone(node)) return false;
1834
+ const expression = node.value;
1835
+ return expression.type === "Identifier" && typeof expression.name === "string" && (name === void 0 || expression.name === name);
1836
+ }
1837
+ function countFileLines(lines) {
1838
+ return lines.at(-1) === "" ? lines.length - 1 : lines.length;
1839
+ }
1840
+ function readMaxLines(options, defaultMax) {
1841
+ const [first] = options;
1842
+ return typeof first === "object" && first !== null && "max" in first && typeof first.max === "number" && Number.isInteger(first.max) && first.max > 0 ? first.max : defaultMax;
1843
+ }
1844
+ const maxLinesSchema = (defaultMax) => [{
1845
+ type: "object",
1846
+ properties: { max: {
1847
+ type: "integer",
1848
+ minimum: 1,
1849
+ default: defaultMax
1850
+ } },
1851
+ additionalProperties: false
1852
+ }];
1853
+ var max_file_lines_default = defineRule({
1854
+ meta: {
1855
+ type: "suggestion",
1856
+ docs: { description: "Report a file longer than `max` lines (default 500); a reasoned disable can keep it." },
1857
+ schema: maxLinesSchema(500)
1858
+ },
1859
+ create(context) {
1860
+ const max = readMaxLines(context.options, 500);
1861
+ const { lines } = context.sourceCode;
1862
+ const count = countFileLines(lines);
1863
+ if (count <= max) return {};
1864
+ return { Program() {
1865
+ context.report({
1866
+ loc: {
1867
+ start: {
1868
+ line: max + 1,
1869
+ column: 0
1870
+ },
1871
+ end: {
1872
+ line: lines.length,
1873
+ column: lines.at(-1).length
1874
+ }
1875
+ },
1876
+ message: `This file has ${count} lines; the cap is ${max}. Split it by responsibility. If this file must stay long, say why at its top: \`/* oxlint-disable jandragsbaek/max-file-lines -- <why this file is long> */\`.`
1877
+ });
1878
+ } };
1879
+ }
1880
+ });
1881
+ const BEFORE_EVERY_DIRECTIVE = {
1882
+ line: 1,
1883
+ column: 0
1884
+ };
1885
+ var max_file_lines_hard_default = defineRule({
1886
+ meta: {
1887
+ type: "problem",
1888
+ docs: { description: "Report a file longer than `max` lines (default 750); no disable directive can silence it." },
1889
+ schema: maxLinesSchema(750)
1890
+ },
1891
+ create(context) {
1892
+ const max = readMaxLines(context.options, 750);
1893
+ const count = countFileLines(context.sourceCode.lines);
1894
+ if (count <= max) return {};
1895
+ return { Program() {
1896
+ context.report({
1897
+ loc: {
1898
+ start: BEFORE_EVERY_DIRECTIVE,
1899
+ end: BEFORE_EVERY_DIRECTIVE
1900
+ },
1901
+ message: `This file has ${count} lines; the hard cap is ${max}, and no directive silences it. Split the file by responsibility.`
1902
+ });
1903
+ } };
1904
+ }
1905
+ });
1906
+ // src/rules/namespace-node-imports.ts
1907
+ const NODE_MODULE_ALIASES = /* @__PURE__ */ new Map([["assert/strict", "Assert"], ["fs/promises", "FSP"]]);
1908
+ const NODE_SEGMENT_ALIASES = /* @__PURE__ */ new Map([
1909
+ ["fs", "FS"],
1910
+ ["os", "OS"],
1911
+ ["url", "URL"],
1912
+ ["vm", "VM"]
1913
+ ]);
1914
+ const toPascalCase = (value) => value.split(/[_-]/u).filter((segment) => segment.length > 0).map((segment) => segment[0]?.toUpperCase() + segment.slice(1)).join("");
1915
+ const expectedNamespaceAlias = (source) => {
1916
+ const moduleName = source.slice(5);
1917
+ const knownAlias = NODE_MODULE_ALIASES.get(moduleName);
1918
+ if (knownAlias !== void 0) return `Node${knownAlias}`;
1919
+ return `Node${moduleName.split("/").map((segment) => NODE_SEGMENT_ALIASES.get(segment) ?? toPascalCase(segment)).join("")}`;
1920
+ };
1921
+ const literalStringValue = (node) => {
1922
+ if (typeof node !== "object" || node === null) return void 0;
1923
+ if (!("type" in node) || node.type !== "Literal") return void 0;
1924
+ if (!("value" in node) || typeof node.value !== "string") return void 0;
1925
+ return node.value;
1926
+ };
1927
+ const identifierName = (node) => {
1928
+ if (typeof node !== "object" || node === null) return void 0;
1929
+ if (!("type" in node) || node.type !== "Identifier") return void 0;
1930
+ if (!("name" in node) || typeof node.name !== "string") return void 0;
1931
+ return node.name;
1932
+ };
1933
+ var namespace_node_imports_default = defineRule({
1934
+ meta: {
1935
+ type: "problem",
1936
+ docs: { description: "Require canonical namespace imports for Node.js built-in modules." }
1937
+ },
1938
+ create(context) {
1939
+ return { ImportDeclaration(node) {
1940
+ const source = literalStringValue(node.source);
1941
+ if (source === void 0 || !source.startsWith("node:")) return;
1942
+ const expectedAlias = expectedNamespaceAlias(source);
1943
+ const namespaceImport = node.specifiers.length === 1 && node.specifiers[0]?.type === "ImportNamespaceSpecifier" ? node.specifiers[0] : void 0;
1944
+ if (identifierName(namespaceImport?.local) === expectedAlias) return;
1945
+ context.report({
1946
+ node,
1947
+ message: `Import ${source} as a namespace named ${expectedAlias}.`
1948
+ });
1949
+ } };
1950
+ }
1951
+ });
1952
+ // src/rules/no-dom-test-environment.ts
1953
+ const DOM_ENVIRONMENT_PACKAGE = /^(?:jsdom|happy-dom)(?:\/|$)/u;
1954
+ const PRAGMA_SPLIT_TO_HIDE_IT_FROM_THIS_RULE = ["@vitest", "environment"].join("-");
1955
+ const MESSAGE$5 = "Select test environments in Vitest project configuration instead of a per-file pragma or a DOM emulator import. Web DOM tests belong in *.browser.test.{ts,tsx}.";
1956
+ var no_dom_test_environment_default = defineRule({
1957
+ meta: {
1958
+ type: "problem",
1959
+ docs: { description: "Reject per-file Vitest environments and DOM emulator imports." }
1960
+ },
1961
+ create(context) {
1962
+ const checkImport = (source) => {
1963
+ if (source === null) return;
1964
+ const value = source.type === "Literal" ? source.value : source.type === "TemplateLiteral" && source.expressions.length === 0 ? source.quasis[0]?.value.cooked : void 0;
1965
+ if (typeof value === "string" && DOM_ENVIRONMENT_PACKAGE.test(value)) context.report({
1966
+ node: source,
1967
+ message: MESSAGE$5
1968
+ });
1969
+ };
1970
+ return {
1971
+ Program() {
1972
+ const index = context.sourceCode.text.indexOf(PRAGMA_SPLIT_TO_HIDE_IT_FROM_THIS_RULE);
1973
+ if (index !== -1) context.report({
1974
+ loc: context.sourceCode.getLocFromIndex(index),
1975
+ message: MESSAGE$5
1976
+ });
1977
+ },
1978
+ ImportDeclaration: (node) => checkImport(node.source),
1979
+ ImportExpression: (node) => checkImport(node.source),
1980
+ ExportNamedDeclaration: (node) => checkImport(node.source),
1981
+ ExportAllDeclaration: (node) => checkImport(node.source),
1982
+ TSExternalModuleReference: (node) => checkImport(node.expression),
1983
+ CallExpression(node) {
1984
+ if (node.callee.type === "Identifier" && node.callee.name === "require") checkImport(node.arguments[0] ?? null);
1985
+ }
1986
+ };
1987
+ }
1988
+ });
1989
+ // src/rules/no-em-dash-copy.ts
1990
+ const EM_DASH = "—";
1991
+ const MESSAGE$4 = "No em dashes in product copy. Use a period, comma, colon, or parentheses instead.";
1992
+ var no_em_dash_copy_default = defineRule({
1993
+ meta: {
1994
+ type: "suggestion",
1995
+ docs: { description: "Disallow em dashes in strings and JSX text that users or agents read." }
1996
+ },
1997
+ create(context) {
1998
+ const check = (node, text) => {
1999
+ if (text?.includes(EM_DASH)) context.report({
2000
+ node,
2001
+ message: MESSAGE$4
2002
+ });
2003
+ };
2004
+ return {
2005
+ Literal(node) {
2006
+ if (typeof node.value === "string") check(node, node.value);
2007
+ },
2008
+ TemplateElement(node) {
2009
+ check(node, node.value.cooked);
2010
+ },
2011
+ JSXText(node) {
2012
+ check(node, node.value);
2013
+ }
2014
+ };
2015
+ }
2016
+ });
2017
+ // src/rules/no-explanatory-comments.ts
2018
+ const END = String.raw`(?![\w-])`;
2019
+ const TOOL_DIRECTIVES = [
2020
+ new RegExp(String.raw`^(?:oxlint|eslint)-(?:disable(?:-next-line|-line)?|enable)${END}`, "u"),
2021
+ new RegExp(String.raw`^@ts-(?:expect-error|ignore|nocheck|check)${END}`, "u"),
2022
+ /^\/\s*<(?:reference|amd-module|amd-dependency)\s/u,
2023
+ new RegExp(String.raw`^[@#]__(?:PURE|NO_SIDE_EFFECTS)__${END}`, "u"),
2024
+ new RegExp(String.raw`^@jsx(?:Frag|ImportSource|Runtime)?${END}`, "u"),
2025
+ new RegExp(String.raw`^(?:oxfmt|prettier|biome|dprint)-ignore(?:-start|-end)?${END}`, "u"),
2026
+ new RegExp(String.raw`^(?:v8|c8|istanbul)\s+ignore${END}`, "u"),
2027
+ new RegExp(String.raw`^node:coverage\s+(?:ignore|disable|enable)${END}`, "u"),
2028
+ new RegExp(String.raw`^@vite-ignore${END}`, "u"),
2029
+ /^(?:webpack|turbopack)[A-Z]\w*\s*:/u,
2030
+ new RegExp(String.raw`^@effect-diagnostics(?:-next-line)?${END}`, "u"),
2031
+ new RegExp(String.raw`^@(?:vitest|jest)-environment${END}`, "u"),
2032
+ /^[#@]\s*source(?:Mapping)?URL=/u,
2033
+ new RegExp(String.raw`^@refresh\s+reset${END}`, "u"),
2034
+ new RegExp(String.raw`^cspell:\s*(?:words|ignore|ignoreRegExp|includeRegExp|flagWords|dictionaries|language|locale|enable|disable(?:-next-line|-line)?)${END}`, "u"),
2035
+ /^quarantine:\s*#\d+(?!\w)/u
2036
+ ];
2037
+ const LICENSE_NOTICE_LINE = /^[\s*]*(?:copyright\b|©|\(c\)\s|SPDX-License-Identifier:|@license\b|Permission is hereby granted\b|Licensed under\b)/imu;
2038
+ const isLicenseNotice = (comment) => comment.type === "Block" && comment.value.startsWith("!") || LICENSE_NOTICE_LINE.test(comment.value);
2039
+ const LEADING_COMMENT_DECORATION = /^[\s*]*/u;
2040
+ const MESSAGE$3 = "Delete this comment. Make the code say it: a name, a type, a smaller function or a test. Only a license header at the top of the file and tool directives (lint, type-checker, formatter, coverage and bundler comments) stay.";
2041
+ const isToolDirective = (comment) => {
2042
+ const text = comment.value.replace(LEADING_COMMENT_DECORATION, "");
2043
+ return TOOL_DIRECTIVES.some((directive) => directive.test(text));
2044
+ };
2045
+ const continuesLineComment = (previous, comment) => comment.type === "Line" && previous?.type === "Line" && previous.loc.end.line === comment.loc.start.line - 1 && previous.loc.start.column === comment.loc.start.column;
2046
+ var no_explanatory_comments_default = defineRule({
2047
+ meta: {
2048
+ type: "suggestion",
2049
+ docs: { description: "Reject every comment except a license header at the top of the file and tool directives." }
2050
+ },
2051
+ create(context) {
2052
+ const { sourceCode } = context;
2053
+ return { Program(program) {
2054
+ const firstCodeStart = program.body[0]?.range[0] ?? Number.POSITIVE_INFINITY;
2055
+ const comments = sourceCode.getAllComments().filter((comment) => comment.type !== "Shebang");
2056
+ const licenseHeader = /* @__PURE__ */ new Set();
2057
+ const headerBlocks = [];
2058
+ for (const comment of comments) {
2059
+ if (comment.range[0] >= firstCodeStart) break;
2060
+ const block = headerBlocks.at(-1);
2061
+ if (block !== void 0 && continuesLineComment(block.at(-1), comment)) block.push(comment);
2062
+ else headerBlocks.push([comment]);
2063
+ }
2064
+ for (const block of headerBlocks) if (block.some(isLicenseNotice)) for (const comment of block) licenseHeader.add(comment);
2065
+ const reported = [];
2066
+ for (const comment of comments) {
2067
+ if (licenseHeader.has(comment) || isToolDirective(comment)) continue;
2068
+ const group = reported.at(-1);
2069
+ if (group !== void 0 && continuesLineComment(group.at(-1), comment)) group.push(comment);
2070
+ else reported.push([comment]);
2071
+ }
2072
+ for (const group of reported) context.report({
2073
+ loc: {
2074
+ start: group[0].loc.start,
2075
+ end: group.at(-1).loc.end
2076
+ },
2077
+ message: MESSAGE$3
2078
+ });
2079
+ } };
2080
+ }
2081
+ });
2082
+ // src/rules/no-hookless-use-function.ts
2083
+ const HOOK_NAME = /^use[A-Z]/;
2084
+ const HOOK_CALLEE_OR_REACT_19_USE = /^use([A-Z]|$)/;
2085
+ function isFunctionNode(node) {
2086
+ return node.type === "FunctionDeclaration" || node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression";
2087
+ }
2088
+ function isHookCallee(callee) {
2089
+ if (callee.type === "Identifier") return HOOK_CALLEE_OR_REACT_19_USE.test(callee.name);
2090
+ if (callee.type === "MemberExpression" && !callee.computed) return callee.property.type === "Identifier" && HOOK_CALLEE_OR_REACT_19_USE.test(callee.property.name);
2091
+ return false;
2092
+ }
2093
+ function callsHookOutsideNestedFunctions(node, root) {
2094
+ if (typeof node !== "object" || node === null) return false;
2095
+ if (Array.isArray(node)) return node.some((child) => callsHookOutsideNestedFunctions(child, root));
2096
+ if (!("type" in node) || typeof node.type !== "string") return false;
2097
+ const typed = node;
2098
+ if (typed !== root && isFunctionNode(typed)) return false;
2099
+ if (typed.type === "CallExpression" && isHookCallee(typed.callee)) return true;
2100
+ for (const [key, value] of Object.entries(typed)) {
2101
+ if (key === "parent") continue;
2102
+ if (callsHookOutsideNestedFunctions(value, root)) return true;
2103
+ }
2104
+ return false;
2105
+ }
2106
+ var no_hookless_use_function_default = defineRule({
2107
+ meta: {
2108
+ type: "problem",
2109
+ docs: { description: "Disallow use* functions that call no hooks; the React Compiler only compiles functions that do. Mirrors eslint-react's no-unnecessary-use-prefix, which oxlint does not ship." },
2110
+ schema: []
2111
+ },
2112
+ create(context) {
2113
+ const check = (name, fn, reportNode) => {
2114
+ if (!HOOK_NAME.test(name)) return;
2115
+ if (callsHookOutsideNestedFunctions(fn.body, fn)) return;
2116
+ context.report({
2117
+ node: reportNode,
2118
+ message: `"${name}" calls no hooks, so the React Compiler skips it and whatever it returns is rebuilt on every render. Rename it to a plain function, or read the hook it depends on inside it.`
2119
+ });
2120
+ };
2121
+ return {
2122
+ FunctionDeclaration(node) {
2123
+ if (node.id) check(node.id.name, node, node.id);
2124
+ },
2125
+ VariableDeclarator(node) {
2126
+ if (node.id.type !== "Identifier" || node.init == null) return;
2127
+ if (node.init.type !== "ArrowFunctionExpression" && node.init.type !== "FunctionExpression") return;
2128
+ check(node.id.name, node.init, node.id);
2129
+ }
2130
+ };
2131
+ }
2132
+ });
2133
+ // src/rules/no-inline-schema-compile.ts
2134
+ const COMPILER_METHODS = /* @__PURE__ */ new Set([
2135
+ "is",
2136
+ "asserts",
2137
+ "decodeEffect",
2138
+ "decodeExit",
2139
+ "decodeOption",
2140
+ "decodePromise",
2141
+ "decodeResult",
2142
+ "decodeSync",
2143
+ "decodeUnknownExit",
2144
+ "decodeUnknownEffect",
2145
+ "decodeUnknownOption",
2146
+ "decodeUnknownPromise",
2147
+ "decodeUnknownResult",
2148
+ "decodeUnknownSync",
2149
+ "encodeExit",
2150
+ "encodeEffect",
2151
+ "encodeOption",
2152
+ "encodePromise",
2153
+ "encodeResult",
2154
+ "encodeSync",
2155
+ "encodeUnknownExit",
2156
+ "encodeUnknownEffect",
2157
+ "encodeUnknownOption",
2158
+ "encodeUnknownPromise",
2159
+ "encodeUnknownResult",
2160
+ "encodeUnknownSync"
2161
+ ]);
2162
+ const getSchemaCompilerMethod = (callee) => {
2163
+ const expression = unwrapExpression(callee);
2164
+ if (isNone(expression) || expression.value.type !== "MemberExpression") return none();
2165
+ if (!isIdentifier(unwrapExpression(expression.value.object), "Schema")) return none();
2166
+ return filter(getPropertyName(expression.value.property), (method) => COMPILER_METHODS.has(method));
2167
+ };
2168
+ const isStaticSchemaReference = (node) => {
2169
+ const expression = unwrapExpression(node);
2170
+ if (isNone(expression)) return false;
2171
+ if (expression.value.type === "Identifier") {
2172
+ const [firstChar] = expression.value.name;
2173
+ return firstChar !== void 0 && firstChar.toUpperCase() === firstChar;
2174
+ }
2175
+ return expression.value.type === "MemberExpression";
2176
+ };
2177
+ const isNestedStaticSchemaCall = (node) => {
2178
+ const expression = unwrapExpression(node);
2179
+ if (isNone(expression) || expression.value.type !== "CallExpression") return false;
2180
+ const callee = unwrapExpression(expression.value.callee);
2181
+ if (isNone(callee) || callee.value.type !== "MemberExpression") return false;
2182
+ if (!isIdentifier(unwrapExpression(callee.value.object), "Schema")) return false;
2183
+ const method = getPropertyName(callee.value.property);
2184
+ if (isSome(method) && method.value === "fromJsonString") {
2185
+ const firstArg = expression.value.arguments[0];
2186
+ return isStaticSchemaReference(firstArg) || isNestedStaticSchemaCall(firstArg);
2187
+ }
2188
+ return true;
2189
+ };
2190
+ const isImmediatelyInvoked = (node) => {
2191
+ const expression = unwrapExpression(node);
2192
+ if (isNone(expression)) return false;
2193
+ const parent = "parent" in expression.value ? unwrapExpression(expression.value.parent) : none();
2194
+ return isSome(parent) && parent.value.type === "CallExpression" && unwrapExpression(parent.value.callee).pipe(exists((callee) => callee === expression.value));
2195
+ };
2196
+ const messageHigh = (method) => `Hoist Schema.${method}(...) to module scope: both the inline schema literal and the compiled function are rebuilt on every call. Move the compiled function to a module-level const.`;
2197
+ const messageMedium = (method) => `Hoist Schema.${method}(...) to module scope: the compiled function is rebuilt on every call. Move it to a module-level const.`;
2198
+ var no_inline_schema_compile_default = defineRule({
2199
+ meta: {
2200
+ type: "problem",
2201
+ docs: { description: "Disallow Schema decoder/encoder compiler calls inside function bodies; hoist them to module scope." }
2202
+ },
2203
+ createOnce(context) {
2204
+ let functionDepth = 0;
2205
+ const resetFunctionDepth = () => {
2206
+ functionDepth = 0;
2207
+ };
2208
+ const enterFunction = () => {
2209
+ functionDepth++;
2210
+ };
2211
+ const exitFunction = () => {
2212
+ functionDepth--;
2213
+ };
2214
+ return {
2215
+ before: resetFunctionDepth,
2216
+ FunctionDeclaration: enterFunction,
2217
+ "FunctionDeclaration:exit": exitFunction,
2218
+ FunctionExpression: enterFunction,
2219
+ "FunctionExpression:exit": exitFunction,
2220
+ ArrowFunctionExpression: enterFunction,
2221
+ "ArrowFunctionExpression:exit": exitFunction,
2222
+ CallExpression(node) {
2223
+ if (functionDepth === 0) return;
2224
+ const method = getSchemaCompilerMethod(node.callee);
2225
+ if (isNone(method)) return;
2226
+ if (!isImmediatelyInvoked(node)) return;
2227
+ const firstArg = node.arguments[0];
2228
+ const high = firstArg && isNestedStaticSchemaCall(firstArg);
2229
+ if (!high && !isStaticSchemaReference(firstArg)) return;
2230
+ context.report({
2231
+ node: node.callee,
2232
+ message: high ? messageHigh(method.value) : messageMedium(method.value)
2233
+ });
2234
+ }
2235
+ };
2236
+ }
2237
+ });
2238
+ // src/rules/no-manual-effect-runtime-in-tests.ts
2239
+ const TEST_FILE_PATTERN$5 = /\.(?:test|spec)\.[cm]?[jt]sx?$/u;
2240
+ const EFFECT_RUNTIME_METHODS = /* @__PURE__ */ new Set([
2241
+ "runCallback",
2242
+ "runCallbackWith",
2243
+ "runFork",
2244
+ "runForkWith",
2245
+ "runPromise",
2246
+ "runPromiseExit",
2247
+ "runPromiseExitWith",
2248
+ "runPromiseWith",
2249
+ "runSync",
2250
+ "runSyncExit",
2251
+ "runSyncExitWith",
2252
+ "runSyncWith"
2253
+ ]);
2254
+ const readMaxOccurrences = (options) => {
2255
+ const [first] = options;
2256
+ return typeof first === "object" && first !== null && "maxOccurrences" in first && typeof first.maxOccurrences === "number" ? first.maxOccurrences : 0;
2257
+ };
2258
+ const manualRunnerName = (callee) => {
2259
+ const expression = unwrapExpression(callee);
2260
+ if (isNone(expression) || expression.value.type !== "MemberExpression") return none();
2261
+ const object = unwrapExpression(expression.value.object);
2262
+ const property = getPropertyName(expression.value.property);
2263
+ if (isNone(property)) return none();
2264
+ if (isIdentifier(object, "Effect") && EFFECT_RUNTIME_METHODS.has(property.value)) return some(`Effect.${property.value}`);
2265
+ if (isIdentifier(object, "ManagedRuntime") && property.value === "make") return some("ManagedRuntime.make");
2266
+ return none();
2267
+ };
2268
+ var no_manual_effect_runtime_in_tests_default = defineRule({
2269
+ meta: {
2270
+ type: "problem",
2271
+ docs: { description: "Disallow manually creating or running Effect runtimes in tests; use @effect/vitest." },
2272
+ schema: [{
2273
+ type: "object",
2274
+ properties: { maxOccurrences: {
2275
+ type: "integer",
2276
+ minimum: 0,
2277
+ description: "Legacy debt ceiling for this file: occurrences beyond this count are reported."
2278
+ } },
2279
+ additionalProperties: false
2280
+ }],
2281
+ defaultOptions: [{ maxOccurrences: 0 }]
2282
+ },
2283
+ create(context) {
2284
+ if (!TEST_FILE_PATTERN$5.test(context.filename)) return {};
2285
+ const allowedCount = readMaxOccurrences(context.options);
2286
+ let occurrenceCount = 0;
2287
+ return { CallExpression(node) {
2288
+ const runner = manualRunnerName(node.callee);
2289
+ if (isNone(runner)) return;
2290
+ occurrenceCount++;
2291
+ if (occurrenceCount <= allowedCount) return;
2292
+ context.report({
2293
+ node: node.callee,
2294
+ message: `Do not use ${runner.value} in tests. Use @effect/vitest with it.effect(...) and test layers instead.`
2295
+ });
2296
+ } };
2297
+ }
2298
+ });
2299
+ // src/rules/no-manual-memo.ts
2300
+ const MANUAL_MEMO_HOOKS = /* @__PURE__ */ new Set(["useCallback", "useMemo"]);
2301
+ const DIRECTIVES_THAT_HIDE_COMPILER_BAILOUTS = /* @__PURE__ */ new Set([
2302
+ "use memo",
2303
+ "use no memo",
2304
+ "use no forget"
2305
+ ]);
2306
+ const readAllowMemoHooks = (options) => {
2307
+ const [first] = options;
2308
+ return typeof first === "object" && first !== null && "allowMemoHooks" in first && first.allowMemoHooks === true;
2309
+ };
2310
+ function manualMemoHookName(callee) {
2311
+ if (callee.type === "Identifier") return MANUAL_MEMO_HOOKS.has(callee.name) ? callee.name : null;
2312
+ if (callee.type === "MemberExpression" && !callee.computed && callee.object.type === "Identifier" && callee.object.name === "React" && callee.property.type === "Identifier" && MANUAL_MEMO_HOOKS.has(callee.property.name)) return callee.property.name;
2313
+ return null;
2314
+ }
2315
+ var no_manual_memo_default = defineRule({
2316
+ meta: {
2317
+ type: "suggestion",
2318
+ docs: { description: "Disallow useCallback, useMemo and memo directives in files the React Compiler must compile; it memoizes them." },
2319
+ schema: [{
2320
+ type: "object",
2321
+ properties: { allowMemoHooks: {
2322
+ type: "boolean",
2323
+ description: "Still permit useMemo and useCallback while a codebase ratchets toward full compiler coverage; directives stay banned."
2324
+ } },
2325
+ additionalProperties: false
2326
+ }],
2327
+ defaultOptions: [{ allowMemoHooks: false }]
2328
+ },
2329
+ create(context) {
2330
+ const allowMemoHooks = readAllowMemoHooks(context.options);
2331
+ return {
2332
+ ExpressionStatement(node) {
2333
+ if (typeof node.directive !== "string" || !DIRECTIVES_THAT_HIDE_COMPILER_BAILOUTS.has(node.directive)) return;
2334
+ context.report({
2335
+ node,
2336
+ message: node.directive === "use memo" ? "Drop \"use memo\": restructure so the compiler caches this on its own, e.g. move plain uses of a value before the hook call that splits its scope, or inline the helper." : `Drop "${node.directive}": fix the code the compiler cannot prove safe instead of skipping it.`
2337
+ });
2338
+ },
2339
+ CallExpression(node) {
2340
+ if (allowMemoHooks) return;
2341
+ const name = manualMemoHookName(node.callee);
2342
+ if (name === null) return;
2343
+ context.report({
2344
+ node: node.callee,
2345
+ message: `Drop ${name}: the React Compiler memoizes this file. Write the plain value or function.`
2346
+ });
2347
+ }
2348
+ };
2349
+ }
2350
+ });
2351
+ // src/rules/no-polling-loop-in-tests.ts
2352
+ const TEST_FILE_PATTERN$4 = /\.(?:test|spec)\.[cm]?[jt]sx?$/u;
2353
+ const FUNCTIONS$2 = /* @__PURE__ */ new Set([
2354
+ "ArrowFunctionExpression",
2355
+ "FunctionExpression",
2356
+ "FunctionDeclaration"
2357
+ ]);
2358
+ const COUNTER_OPERATORS = /* @__PURE__ */ new Set([
2359
+ "<",
2360
+ "<=",
2361
+ ">",
2362
+ ">="
2363
+ ]);
2364
+ const TIMERS = /* @__PURE__ */ new Set(["setImmediate", "setTimeout"]);
2365
+ const MESSAGE$2 = "Polling loop in a test. Spinning on `yieldNow`/`sleep` is scheduler- and load-dependent. Await the `Deferred`, `Queue.take`, `Stream` element, `drain()`, or `expect.poll` that marks the milestone.";
2366
+ const isNode = (value) => typeof value === "object" && value !== null && "type" in value && typeof value.type === "string";
2367
+ const someDescendantOutsideNestedFunctions = (node, match) => {
2368
+ if (Array.isArray(node)) return node.some((child) => someDescendantOutsideNestedFunctions(child, match));
2369
+ if (!isNode(node)) return false;
2370
+ if (match(node)) return true;
2371
+ if (FUNCTIONS$2.has(node.type)) return false;
2372
+ for (const [key, value] of Object.entries(node)) {
2373
+ if (key === "parent") continue;
2374
+ if (someDescendantOutsideNestedFunctions(value, match)) return true;
2375
+ }
2376
+ return false;
2377
+ };
2378
+ const memberName = (node) => {
2379
+ const expression = unwrapExpression(node);
2380
+ if (isNone(expression) || expression.value.type !== "MemberExpression") return none();
2381
+ const object = unwrapExpression(expression.value.object);
2382
+ const property = getPropertyName(expression.value.property);
2383
+ if (isNone(object) || object.value.type !== "Identifier" || isNone(property)) return none();
2384
+ return some([object.value.name, property.value]);
2385
+ };
2386
+ const isMember = (node, object, property) => match(memberName(node), {
2387
+ onNone: () => false,
2388
+ onSome: ([name, key]) => name === object && key === property
2389
+ });
2390
+ const isTimerReference = (node) => {
2391
+ const expression = unwrapExpression(node);
2392
+ return isSome(expression) && expression.value.type === "Identifier" && TIMERS.has(expression.value.name);
2393
+ };
2394
+ const isPromiseResolveOrTimerPromise = (node) => {
2395
+ const expression = unwrapExpression(node);
2396
+ if (isNone(expression)) return false;
2397
+ const value = expression.value;
2398
+ if (value.type === "CallExpression") return isMember(value.callee, "Promise", "resolve");
2399
+ if (value.type !== "NewExpression" || !isIdentifier(some(value.callee), "Promise")) return false;
2400
+ const [executor] = value.arguments;
2401
+ if (isTimerReference(executor)) return true;
2402
+ if (!isNode(executor) || !FUNCTIONS$2.has(executor.type)) return false;
2403
+ return someDescendantOutsideNestedFunctions(executor.body, (child) => child.type === "CallExpression" && isTimerReference(child.callee));
2404
+ };
2405
+ const thunkReturnsTick = (node) => {
2406
+ if (!isNode(node) || node.type !== "ArrowFunctionExpression") return false;
2407
+ const body = node.body;
2408
+ if (body.type !== "BlockStatement") return isPromiseResolveOrTimerPromise(body);
2409
+ const last = body.body.at(-1);
2410
+ return last?.type === "ReturnStatement" && isPromiseResolveOrTimerPromise(last.argument);
2411
+ };
2412
+ const isWait = (node) => {
2413
+ if (node.type === "MemberExpression") return isMember(node, "Effect", "yieldNow");
2414
+ if (node.type === "AwaitExpression") return isPromiseResolveOrTimerPromise(node.argument);
2415
+ if (node.type === "NewExpression") return isPromiseResolveOrTimerPromise(node);
2416
+ if (node.type !== "CallExpression") return false;
2417
+ if (isMember(node.callee, "Effect", "sleep")) return true;
2418
+ if (isIdentifier(unwrapExpression(node.callee), "setImmediate")) return true;
2419
+ if (isMember(node.callee, "Effect", "promise")) return thunkReturnsTick(node.arguments[0]);
2420
+ return false;
2421
+ };
2422
+ const hasConditionalExit = (body) => someDescendantOutsideNestedFunctions(body, (node) => node.type === "IfStatement" && someDescendantOutsideNestedFunctions([node.consequent, node.alternate], (child) => child.type === "ReturnStatement" || child.type === "BreakStatement" || child.type === "ThrowStatement"));
2423
+ const isNumericBound = (node) => {
2424
+ const expression = unwrapExpression(node);
2425
+ if (isNone(expression)) return false;
2426
+ const value = expression.value;
2427
+ return value.type === "Identifier" || value.type === "Literal" && typeof value.value === "number";
2428
+ };
2429
+ const updatesCounter = (node, name) => someDescendantOutsideNestedFunctions(node, (child) => child.type === "UpdateExpression" && isIdentifier(unwrapExpression(child.argument), name) || child.type === "AssignmentExpression" && (child.operator === "+=" || child.operator === "-=") && isIdentifier(unwrapExpression(child.left), name));
2430
+ const isBoundByCounterTheLoopAdvances = (loop) => {
2431
+ if (loop.test == null) return false;
2432
+ const expression = unwrapExpression(loop.test);
2433
+ if (isNone(expression) || expression.value.type !== "BinaryExpression") return false;
2434
+ if (!COUNTER_OPERATORS.has(expression.value.operator)) return false;
2435
+ const { left, right } = expression.value;
2436
+ const advances = [loop.body, loop.type === "ForStatement" ? loop.update : null];
2437
+ return [[left, right], [right, left]].some(([counter, bound]) => {
2438
+ const name = unwrapExpression(counter);
2439
+ return isSome(name) && name.value.type === "Identifier" && isNumericBound(bound) && updatesCounter(advances, name.value.name);
2440
+ });
2441
+ };
2442
+ const isTrueLiteral = (test) => {
2443
+ const expression = unwrapExpression(test);
2444
+ return isSome(expression) && expression.value.type === "Literal" && expression.value.value === true;
2445
+ };
2446
+ const hasPredicateExit = (loop) => hasConditionalExit(loop.body) || loop.test != null && !isTrueLiteral(loop.test) && !isBoundByCounterTheLoopAdvances(loop);
2447
+ var no_polling_loop_in_tests_default = defineRule({
2448
+ meta: {
2449
+ type: "problem",
2450
+ docs: { description: "Disallow loops in tests that spin on yieldNow/sleep/timer ticks until a predicate holds; await the milestone instead." },
2451
+ schema: []
2452
+ },
2453
+ create(context) {
2454
+ if (!TEST_FILE_PATTERN$4.test(context.filename)) return {};
2455
+ const check = (loop) => {
2456
+ if (!someDescendantOutsideNestedFunctions(loop.body, isWait)) return;
2457
+ if (!hasPredicateExit(loop)) return;
2458
+ context.report({
2459
+ node: loop,
2460
+ message: MESSAGE$2
2461
+ });
2462
+ };
2463
+ return {
2464
+ ForStatement: check,
2465
+ WhileStatement: check,
2466
+ DoWhileStatement: check
2467
+ };
2468
+ }
2469
+ });
2470
+ // src/rules/no-real-time-wait-in-tests.ts
2471
+ const TEST_FILE_PATTERN$3 = /\.(?:test|spec)\.[cm]?[jt]sx?$/u;
2472
+ const TEST_CLOCK_DRIVERS = /* @__PURE__ */ new Set(["adjust", "setTime"]);
2473
+ const TIMER_PROMISES_MODULES = /* @__PURE__ */ new Set(["node:timers/promises", "timers/promises"]);
2474
+ const TIMER_FUNCTIONS = /* @__PURE__ */ new Set([
2475
+ "setTimeout",
2476
+ "setInterval",
2477
+ "setImmediate"
2478
+ ]);
2479
+ const SCHEDULE_WAITS = /* @__PURE__ */ new Set([
2480
+ "spaced",
2481
+ "fixed",
2482
+ "exponential"
2483
+ ]);
2484
+ const TESTER_ROOTS = /* @__PURE__ */ new Set(["it", "test"]);
2485
+ const FUNCTIONS$1 = /* @__PURE__ */ new Set([
2486
+ "ArrowFunctionExpression",
2487
+ "FunctionExpression",
2488
+ "FunctionDeclaration"
2489
+ ]);
2490
+ const REAL_CLOCK_MESSAGE = "Real-clock wait in a test. Await the `Deferred`/`Queue`/event that marks the milestone, or run under `it.effect` and `TestClock.adjust`. `it.live` is for subprocess/network fixtures, not for sleeping.";
2491
+ const UNDRIVEN_TEST_CLOCK_MESSAGE = "Sleeps on the TestClock never fire without `TestClock.adjust`; this test can only time out.";
2492
+ const MIXED_CLOCK_MESSAGE = "`setTimeout` is wall-clock while `Effect.sleep` here is TestClock; they never meet.";
2493
+ const flattenCalleeChain = (callee) => {
2494
+ const members = [];
2495
+ const calls = [];
2496
+ let current = unwrapExpression(callee);
2497
+ while (isSome(current)) {
2498
+ const node = current.value;
2499
+ if (node.type === "Identifier") return some({
2500
+ root: node.name,
2501
+ members: members.toReversed(),
2502
+ calls
2503
+ });
2504
+ if (node.type === "CallExpression") {
2505
+ calls.push(node);
2506
+ current = unwrapExpression(node.callee);
2507
+ continue;
2508
+ }
2509
+ if (node.type === "MemberExpression") {
2510
+ const name = getPropertyName(node.property);
2511
+ if (isNone(name)) return none();
2512
+ members.push(name.value);
2513
+ current = unwrapExpression(node.object);
2514
+ continue;
2515
+ }
2516
+ return none();
2517
+ }
2518
+ return none();
2519
+ };
2520
+ const isLayerBlock = (chain) => chain.root === "layer" || TESTER_ROOTS.has(chain.root) && chain.members.includes("layer");
2521
+ const testerKind = (chain) => {
2522
+ if (!TESTER_ROOTS.has(chain.root) || chain.members.includes("layer")) return none();
2523
+ if (chain.members.includes("live") || chain.members.includes("scopedLive")) return some("live");
2524
+ if (chain.members.includes("effect") || chain.members.includes("scoped")) return some("effect");
2525
+ return some("plain");
2526
+ };
2527
+ const excludesTestServices = (chain) => chain.calls.some((call) => call.arguments.some((argument) => {
2528
+ const expression = unwrapExpression(argument);
2529
+ if (isNone(expression) || expression.value.type !== "ObjectExpression") return false;
2530
+ return expression.value.properties.some((property) => {
2531
+ if (property.type !== "Property") return false;
2532
+ const key = getPropertyName(property.key);
2533
+ const value = unwrapExpression(property.value);
2534
+ return isSome(key) && key.value === "excludeTestServices" && isSome(value) && value.value.type === "Literal" && value.value.value === true;
2535
+ });
2536
+ }));
2537
+ const clockOfNearestEnclosingTest = (node) => {
2538
+ let child = node;
2539
+ let current = node.parent;
2540
+ let tester = none();
2541
+ while (current) {
2542
+ if (current.type === "CallExpression" && current.arguments.some((argument) => argument === child)) {
2543
+ const chain = flattenCalleeChain(current.callee);
2544
+ if (isSome(chain)) {
2545
+ if (isNone(tester)) {
2546
+ tester = testerKind(chain.value);
2547
+ if (isSome(tester) && tester.value !== "effect") return tester;
2548
+ } else if (isLayerBlock(chain.value) && excludesTestServices(chain.value)) return some("live");
2549
+ }
2550
+ }
2551
+ child = current;
2552
+ current = current.parent;
2553
+ }
2554
+ return tester;
2555
+ };
2556
+ const memberCallName = (callee) => {
2557
+ const expression = unwrapExpression(callee);
2558
+ if (isNone(expression) || expression.value.type !== "MemberExpression") return none();
2559
+ const object = unwrapExpression(expression.value.object);
2560
+ const property = getPropertyName(expression.value.property);
2561
+ if (isNone(property) || isNone(object) || object.value.type !== "Identifier") return none();
2562
+ return some([object.value.name, property.value]);
2563
+ };
2564
+ const LOOPS$1 = /* @__PURE__ */ new Set([
2565
+ "DoWhileStatement",
2566
+ "ForInStatement",
2567
+ "ForOfStatement",
2568
+ "ForStatement",
2569
+ "WhileStatement"
2570
+ ]);
2571
+ const isUnconditionalStatementOfLoopBody = (node) => {
2572
+ let statement = node.parent;
2573
+ while (statement && statement.type !== "ExpressionStatement") {
2574
+ if (FUNCTIONS$1.has(statement.type)) return false;
2575
+ statement = statement.parent;
2576
+ }
2577
+ const block = statement?.parent;
2578
+ if (!block) return false;
2579
+ if (LOOPS$1.has(block.type)) return true;
2580
+ return block.type === "BlockStatement" && block.parent !== null && LOOPS$1.has(block.parent.type);
2581
+ };
2582
+ const isPromiseExecutor = (fn) => {
2583
+ const parent = fn.parent;
2584
+ return parent?.type === "NewExpression" && parent.arguments[0] === fn && isIdentifier(unwrapExpression(parent.callee), "Promise");
2585
+ };
2586
+ const isInsidePromiseExecutor = (node) => {
2587
+ let current = node.parent;
2588
+ while (current) {
2589
+ if (FUNCTIONS$1.has(current.type)) return isPromiseExecutor(current);
2590
+ current = current.parent;
2591
+ }
2592
+ return false;
2593
+ };
2594
+ var no_real_time_wait_in_tests_default = defineRule({
2595
+ meta: {
2596
+ type: "problem",
2597
+ docs: { description: "Disallow real-clock waits in tests; await the milestone or drive the TestClock instead." }
2598
+ },
2599
+ create(context) {
2600
+ if (!TEST_FILE_PATTERN$3.test(context.filename)) return {};
2601
+ let drivesTestClock = false;
2602
+ const reportsUnlessFileDrivesTestClock = [];
2603
+ const timerPromiseLocals = /* @__PURE__ */ new Set();
2604
+ const timerPromiseNamespaces = /* @__PURE__ */ new Set();
2605
+ const isTimerPromiseCall = (callee) => {
2606
+ const expression = unwrapExpression(callee);
2607
+ if (isNone(expression)) return false;
2608
+ if (expression.value.type === "Identifier") return timerPromiseLocals.has(expression.value.name);
2609
+ return match(memberCallName(callee), {
2610
+ onNone: () => false,
2611
+ onSome: ([object, property]) => timerPromiseNamespaces.has(object) && TIMER_FUNCTIONS.has(property)
2612
+ });
2613
+ };
2614
+ const isCallbackTimer = (callee) => {
2615
+ const expression = unwrapExpression(callee);
2616
+ return isSome(expression) && expression.value.type === "Identifier" && TIMER_FUNCTIONS.has(expression.value.name) && !timerPromiseLocals.has(expression.value.name);
2617
+ };
2618
+ return {
2619
+ ImportDeclaration(node) {
2620
+ if (!TIMER_PROMISES_MODULES.has(node.source.value)) return;
2621
+ for (const specifier of node.specifiers) if (specifier.type === "ImportNamespaceSpecifier") timerPromiseNamespaces.add(specifier.local.name);
2622
+ else if (specifier.type === "ImportSpecifier") {
2623
+ const imported = getPropertyName(specifier.imported);
2624
+ if (isSome(imported) && TIMER_FUNCTIONS.has(imported.value)) timerPromiseLocals.add(specifier.local.name);
2625
+ }
2626
+ },
2627
+ CallExpression(node) {
2628
+ const reportFor = (message) => context.report({
2629
+ node: node.callee,
2630
+ message
2631
+ });
2632
+ if (isTimerPromiseCall(node.callee) || isCallbackTimer(node.callee) && isInsidePromiseExecutor(node)) {
2633
+ const tester = clockOfNearestEnclosingTest(node);
2634
+ reportFor(isSome(tester) && tester.value === "effect" ? `${REAL_CLOCK_MESSAGE} ${MIXED_CLOCK_MESSAGE}` : REAL_CLOCK_MESSAGE);
2635
+ return;
2636
+ }
2637
+ const name = memberCallName(node.callee);
2638
+ if (isNone(name)) return;
2639
+ const [object, property] = name.value;
2640
+ if (object === "TestClock" && TEST_CLOCK_DRIVERS.has(property)) {
2641
+ drivesTestClock = true;
2642
+ return;
2643
+ }
2644
+ const isSleep = object === "Effect" && property === "sleep";
2645
+ if (!(isSleep || object === "Effect" && property === "delay" || object === "Schedule" && SCHEDULE_WAITS.has(property))) return;
2646
+ const tester = clockOfNearestEnclosingTest(node);
2647
+ if (isNone(tester)) {
2648
+ if (isUnconditionalStatementOfLoopBody(node)) reportFor(REAL_CLOCK_MESSAGE);
2649
+ else reportsUnlessFileDrivesTestClock.push({
2650
+ node: node.callee,
2651
+ message: REAL_CLOCK_MESSAGE
2652
+ });
2653
+ return;
2654
+ }
2655
+ if (tester.value !== "effect") reportFor(REAL_CLOCK_MESSAGE);
2656
+ else if (isSleep) reportsUnlessFileDrivesTestClock.push({
2657
+ node: node.callee,
2658
+ message: UNDRIVEN_TEST_CLOCK_MESSAGE
2659
+ });
2660
+ },
2661
+ "Program:exit"() {
2662
+ if (drivesTestClock) return;
2663
+ for (const report of reportsUnlessFileDrivesTestClock) context.report(report);
2664
+ }
2665
+ };
2666
+ }
2667
+ });
2668
+ // src/rules/no-test-in-loop.ts
2669
+ const TEST_FILE_PATTERN$2 = /\.(?:test|spec)\.[cm]?[jt]sx?$/u;
2670
+ const NODE_TEST_IMPORT_WHICH_HAS_NO_EACH = /["']node:test["']/u;
2671
+ const TEST_FUNCTIONS$1 = /* @__PURE__ */ new Set([
2672
+ "describe",
2673
+ "it",
2674
+ "suite",
2675
+ "test"
2676
+ ]);
2677
+ const EACH_CAPABLE_MODIFIERS = /* @__PURE__ */ new Set(["effect", "live"]);
2678
+ const LOOPS = /* @__PURE__ */ new Set([
2679
+ "ForStatement",
2680
+ "ForInStatement",
2681
+ "ForOfStatement"
2682
+ ]);
2683
+ const FUNCTIONS = /* @__PURE__ */ new Set([
2684
+ "ArrowFunctionExpression",
2685
+ "FunctionExpression",
2686
+ "FunctionDeclaration"
2687
+ ]);
2688
+ const testCallName = (callee) => {
2689
+ const expression = unwrapExpression(callee);
2690
+ if (isNone(expression)) return none();
2691
+ if (expression.value.type === "Identifier") return TEST_FUNCTIONS$1.has(expression.value.name) ? some(expression.value.name) : none();
2692
+ if (expression.value.type !== "MemberExpression") return none();
2693
+ const object = unwrapExpression(expression.value.object);
2694
+ const property = getPropertyName(expression.value.property);
2695
+ if (isNone(object) || isNone(property)) return none();
2696
+ if (!EACH_CAPABLE_MODIFIERS.has(property.value)) return none();
2697
+ if (object.value.type !== "Identifier" || !TEST_FUNCTIONS$1.has(object.value.name)) return none();
2698
+ return some(`${object.value.name}.${property.value}`);
2699
+ };
2700
+ const isInsideLoop = (node) => {
2701
+ let current = node.parent;
2702
+ while (current) {
2703
+ if (LOOPS.has(current.type)) return true;
2704
+ if (FUNCTIONS.has(current.type)) return false;
2705
+ current = current.parent;
2706
+ }
2707
+ return false;
2708
+ };
2709
+ var no_test_in_loop_default = defineRule({
2710
+ meta: {
2711
+ type: "suggestion",
2712
+ docs: { description: "Disallow declaring tests inside a for loop; use it.each / it.effect.each / describe.each instead." }
2713
+ },
2714
+ create(context) {
2715
+ if (!TEST_FILE_PATTERN$2.test(context.filename)) return {};
2716
+ if (NODE_TEST_IMPORT_WHICH_HAS_NO_EACH.test(context.sourceCode.text)) return {};
2717
+ return { CallExpression(node) {
2718
+ const name = testCallName(node.callee);
2719
+ if (isNone(name)) return;
2720
+ if (!isInsideLoop(node)) return;
2721
+ context.report({
2722
+ node: node.callee,
2723
+ message: `Do not call ${name.value}(…) inside a for loop. Use ${name.value}.each(cases)(name, …) instead.`
2724
+ });
2725
+ } };
2726
+ }
2727
+ });
2728
+ // src/rules/no-test-timeout-or-unreasoned-skip.ts
2729
+ const TEST_FILE_PATTERN$1 = /\.(?:test|spec)\.[cm]?[jt]sx?$/u;
2730
+ const OPT_IN_LIVE_AGENT_SUITE_PATTERN = /\.live\.(?:test|spec)\.[cm]?[jt]sx?$/u;
2731
+ const TEST_FUNCTIONS = /* @__PURE__ */ new Set([
2732
+ "describe",
2733
+ "it",
2734
+ "suite",
2735
+ "test"
2736
+ ]);
2737
+ const HOOK_FUNCTIONS = /* @__PURE__ */ new Set([
2738
+ "afterAll",
2739
+ "afterEach",
2740
+ "beforeAll",
2741
+ "beforeEach"
2742
+ ]);
2743
+ const FOCUS_OR_SKIP_MODIFIERS = /* @__PURE__ */ new Set([
2744
+ "only",
2745
+ "skip",
2746
+ "todo"
2747
+ ]);
2748
+ const FOCUS_OR_SKIP_FUNCTIONS = /* @__PURE__ */ new Set([
2749
+ "fdescribe",
2750
+ "fit",
2751
+ "xdescribe",
2752
+ "xit",
2753
+ "xtest"
2754
+ ]);
2755
+ const TIMEOUT_OPTIONS = /* @__PURE__ */ new Set(["retry", "timeout"]);
2756
+ const SET_CONFIG_OPTIONS = /* @__PURE__ */ new Set([
2757
+ "hookTimeout",
2758
+ "retry",
2759
+ "testTimeout"
2760
+ ]);
2761
+ const QUARANTINE_PATTERN = /quarantine:\s*#\d+|https:\/\/github\.com\/[^\s/]+\/[^\s/]+\/issues\/\d+/u;
2762
+ const TIMEOUT_MESSAGE = "Per-test timeouts and retries hide waits that should be event-driven; the project timeout is the ceiling. Remove the override and await the milestone.";
2763
+ const SKIP_MESSAGE = "A skipped test needs a tracking issue in the comment above it: `// quarantine: #1234 <why>`.";
2764
+ const identifierThatRegistersTheTest = (node) => {
2765
+ const expression = unwrapExpression(node);
2766
+ if (isNone(expression)) return none();
2767
+ const value = expression.value;
2768
+ if (value.type === "Identifier") return some(value.name);
2769
+ if (value.type === "MemberExpression") return identifierThatRegistersTheTest(value.object);
2770
+ if (value.type === "CallExpression") return identifierThatRegistersTheTest(value.callee);
2771
+ return none();
2772
+ };
2773
+ const isTestChain = (node) => exists(identifierThatRegistersTheTest(node), (name) => TEST_FUNCTIONS.has(name));
2774
+ const hasEnabledOption = (node, names) => {
2775
+ const expression = unwrapExpression(node);
2776
+ if (isNone(expression) || expression.value.type !== "ObjectExpression") return false;
2777
+ return expression.value.properties.some((property) => property.type === "Property" && exists(getPropertyName(property.key), (name) => names.has(name)) && exists(unwrapExpression(property.value), (value) => value.type === "Literal" && value.value === true));
2778
+ };
2779
+ const hasOption = (node, names) => {
2780
+ const expression = unwrapExpression(node);
2781
+ if (isNone(expression) || expression.value.type !== "ObjectExpression") return false;
2782
+ return expression.value.properties.some((property) => property.type === "Property" && exists(getPropertyName(property.key), (name) => names.has(name)));
2783
+ };
2784
+ const isNumericLiteral = (node) => exists(unwrapExpression(node), (expression) => expression.type === "Literal" && typeof expression.value === "number");
2785
+ const isStringLiteral$1 = (node) => exists(unwrapExpression(node), (expression) => expression.type === "Literal" && typeof expression.value === "string");
2786
+ const enclosingStatement = (node) => {
2787
+ let current = node;
2788
+ while (current.parent && !/(?:Statement|Declaration)$/u.test(current.type)) current = current.parent;
2789
+ return current;
2790
+ };
2791
+ var no_test_timeout_or_unreasoned_skip_default = defineRule({
2792
+ meta: {
2793
+ type: "problem",
2794
+ docs: { description: "Disallow per-test timeouts and retries, and require a tracking issue for skipped or focused tests." }
2795
+ },
2796
+ create(context) {
2797
+ if (!TEST_FILE_PATTERN$1.test(context.filename)) return {};
2798
+ const checkTimeouts = !OPT_IN_LIVE_AGENT_SUITE_PATTERN.test(context.filename);
2799
+ const reportUnlessQuarantined = (node) => {
2800
+ if (context.sourceCode.getCommentsBefore(enclosingStatement(node)).some((comment) => QUARANTINE_PATTERN.test(comment.value))) return;
2801
+ context.report({
2802
+ node,
2803
+ message: SKIP_MESSAGE
2804
+ });
2805
+ };
2806
+ return {
2807
+ CallExpression(node) {
2808
+ const callee = unwrapExpression(node.callee);
2809
+ if (isNone(callee)) return;
2810
+ if (callee.value.type === "MemberExpression" && exists(identifierThatRegistersTheTest(callee.value.object), (name) => name === "vi") && exists(getPropertyName(callee.value.property), (name) => name === "setConfig")) {
2811
+ if (checkTimeouts && hasOption(node.arguments[0], SET_CONFIG_OPTIONS)) context.report({
2812
+ node,
2813
+ message: TIMEOUT_MESSAGE
2814
+ });
2815
+ return;
2816
+ }
2817
+ if (callee.value.type === "Identifier" && HOOK_FUNCTIONS.has(callee.value.name)) {
2818
+ if (checkTimeouts && isNumericLiteral(node.arguments[1])) context.report({
2819
+ node,
2820
+ message: TIMEOUT_MESSAGE
2821
+ });
2822
+ return;
2823
+ }
2824
+ if (!isTestChain(callee.value)) return;
2825
+ const [, second, third] = node.arguments;
2826
+ if (checkTimeouts && (isNumericLiteral(third) || hasOption(third, TIMEOUT_OPTIONS) || hasOption(second, TIMEOUT_OPTIONS))) context.report({
2827
+ node,
2828
+ message: TIMEOUT_MESSAGE
2829
+ });
2830
+ if (hasEnabledOption(second, FOCUS_OR_SKIP_MODIFIERS) || hasEnabledOption(third, FOCUS_OR_SKIP_MODIFIERS)) reportUnlessQuarantined(node);
2831
+ },
2832
+ Identifier(node) {
2833
+ if (!FOCUS_OR_SKIP_FUNCTIONS.has(node.name)) return;
2834
+ const parent = node.parent;
2835
+ if (parent?.type !== "CallExpression" || parent.callee !== node) return;
2836
+ reportUnlessQuarantined(node);
2837
+ },
2838
+ MemberExpression(node) {
2839
+ if (!exists(getPropertyName(node.property), (n) => FOCUS_OR_SKIP_MODIFIERS.has(n))) return;
2840
+ if (node.computed && !isStringLiteral$1(node.property)) return;
2841
+ if (!isTestChain(node.object)) return;
2842
+ reportUnlessQuarantined(node);
2843
+ }
2844
+ };
2845
+ }
2846
+ });
2847
+ // src/rules/no-unreasoned-state-sync.ts
2848
+ const EFFECT_HOOKS = /* @__PURE__ */ new Set([
2849
+ "useEffect",
2850
+ "useLayoutEffect",
2851
+ "useInsertionEffect"
2852
+ ]);
2853
+ const EFFECT_HOOK_TEXT = /use(?:Layout|Insertion)?Effect/;
2854
+ const TEST_FILE = /\.(?:test|spec)\.[cm]?[jt]sx?$|[\\/](?:tests?|__tests__)[\\/]/;
2855
+ const isEffectHookCall = (node) => {
2856
+ const callee = unwrapExpression(node.callee);
2857
+ if (isNone(callee)) return false;
2858
+ const expression = callee.value;
2859
+ if (expression.type === "Identifier") return EFFECT_HOOKS.has(expression.name);
2860
+ if (expression.type === "MemberExpression" && !expression.computed) return exists(getPropertyName(expression.property), (name) => EFFECT_HOOKS.has(name));
2861
+ return false;
2862
+ };
2863
+ const MESSAGE_FOR_AGENTS_ALTERNATIVES_FIRST = "Stop and reconsider before keeping this effect. Is it computable from props or state? Compute it during render; the compiler memoizes it. Does it respond to a user action? Do it in that handler. Does it reset state when a prop changes? Key the component on that prop. Does it tell a parent or store that a value changed? Do it where the change happens. Does it load app data? Read it from the data layer (an atom, query or loader). Does it read a value from outside React? Use a store subscription or useSyncExternalStore. An effect that sets state another effect reads is one handler or one derivation. An effect is right only when it keeps something outside React in step with this component while mounted: a DOM node, listener, timer, native module, connection, router, imperative toast, or a registry entry or resource held until unmount. Moving the same logic into a ref or store to dodge this rule is not a fix. If the effect does that, name what it keeps in step on the line above: `// oxlint-disable-next-line jandragsbaek/no-unreasoned-state-sync -- <what it syncs with and why>`.";
2864
+ var no_unreasoned_state_sync_default = defineRule({
2865
+ meta: {
2866
+ type: "suggestion",
2867
+ docs: { description: "Report every React effect hook, the usual way state gets synchronized; one that stays says why." }
2868
+ },
2869
+ create(context) {
2870
+ if (TEST_FILE.test(context.filename) || !EFFECT_HOOK_TEXT.test(context.sourceCode.text)) return {};
2871
+ return { CallExpression(node) {
2872
+ if (!isEffectHookCall(node)) return;
2873
+ context.report({
2874
+ node,
2875
+ message: MESSAGE_FOR_AGENTS_ALTERNATIVES_FIRST
2876
+ });
2877
+ } };
2878
+ }
2879
+ });
2880
+ // src/rules/no-unscoped-has.ts
2881
+ const COMBINATOR_PATTERN = /[\s>+~]/u;
2882
+ const CLASS_ID_ATTRIBUTE_OR_LEADING_TAG = /[.#[]|^[a-z]/iu;
2883
+ const ROOT_COMPOUND_PATTERN = /^(?:html|body|:root)(?![\w-])/iu;
2884
+ const GROUP_OR_PEER_ELEMENT_PREFIX = /(?:^|:)(?:group|peer)-$/u;
2885
+ const ANCESTOR_PREFIX = /(?:^|:)in-$/u;
2886
+ const ATTRIBUTE_VALUE_NOT_SELECTOR_PREFIX = /(?:^|:)(?:data|aria)-$/u;
2887
+ const TAILWIND_SPACE = "_";
2888
+ const TAILWIND_ELEMENT_WITH_THE_CLASS = "&";
2889
+ const QUOTED_PATTERN = /(["'])(?:\\.|(?!\1).)*\1/gu;
2890
+ const VARIANT_END_PATTERN = /^(?:\/[\w-]+)?:/u;
2891
+ function variantGroups(token) {
2892
+ const groups = [];
2893
+ let depth = 0;
2894
+ let start = -1;
2895
+ for (let index = 0; index < token.length; index++) {
2896
+ const char = token[index];
2897
+ if (char === "[") {
2898
+ if (depth === 0) start = index + 1;
2899
+ depth++;
2900
+ } else if (char === "]" && depth > 0) {
2901
+ depth--;
2902
+ if (depth === 0 && VARIANT_END_PATTERN.test(token.slice(index + 1))) groups.push({
2903
+ prefix: token.slice(0, start - 1),
2904
+ group: token.slice(start, index)
2905
+ });
2906
+ }
2907
+ }
2908
+ return groups;
2909
+ }
2910
+ function closingParen(selector, open) {
2911
+ let depth = 0;
2912
+ for (let index = open; index < selector.length; index++) if (selector[index] === "(") depth++;
2913
+ else if (selector[index] === ")" && --depth === 0) return index;
2914
+ return selector.length;
2915
+ }
2916
+ function hasIsInSubjectPositionOfNotIsOrWhere(selector, from) {
2917
+ let depth = 0;
2918
+ for (let index = from; index < selector.length; index++) {
2919
+ const char = selector[index] ?? "";
2920
+ if (char === "(") depth++;
2921
+ else if (char === ")") {
2922
+ if (depth === 0) return true;
2923
+ depth--;
2924
+ } else if (depth > 0) continue;
2925
+ else if (char === ",") return true;
2926
+ else if (COMBINATOR_PATTERN.test(char)) {
2927
+ const next = selector.slice(index).trimStart()[0];
2928
+ if (/\s/u.test(char) && (next === void 0 || next === ")" || next === ",")) continue;
2929
+ return false;
2930
+ }
2931
+ }
2932
+ return true;
2933
+ }
2934
+ function hasCompounds(selector) {
2935
+ const compounds = [];
2936
+ let index = selector.indexOf(":has(");
2937
+ while (index !== -1) {
2938
+ let compound = "";
2939
+ let depth = 0;
2940
+ let subjectEnd = closingParen(selector, index + 4) + 1;
2941
+ let skippingOtherSelectorListBranch = false;
2942
+ for (let position = index - 1; position >= 0; position--) {
2943
+ const char = selector[position] ?? "";
2944
+ if (char === ")") depth++;
2945
+ else if (char === "(") {
2946
+ if (depth > 0) depth--;
2947
+ else {
2948
+ if (!hasIsInSubjectPositionOfNotIsOrWhere(selector, subjectEnd)) break;
2949
+ skippingOtherSelectorListBranch = false;
2950
+ subjectEnd = closingParen(selector, position) + 1;
2951
+ }
2952
+ } else if (depth === 0 && char === ",") {
2953
+ skippingOtherSelectorListBranch = true;
2954
+ continue;
2955
+ } else if (depth === 0 && !skippingOtherSelectorListBranch && COMBINATOR_PATTERN.test(char)) break;
2956
+ if (!skippingOtherSelectorListBranch) compound = char + compound;
2957
+ }
2958
+ compounds.push(compound);
2959
+ index = selector.indexOf(":has(", index + 1);
2960
+ }
2961
+ return compounds;
2962
+ }
2963
+ function withoutNegations(compound) {
2964
+ let result = "";
2965
+ let index = 0;
2966
+ while (index < compound.length) {
2967
+ if (!compound.startsWith(":not(", index)) {
2968
+ result += compound[index];
2969
+ index++;
2970
+ continue;
2971
+ }
2972
+ let depth = 0;
2973
+ for (index += 4; index < compound.length; index++) if (compound[index] === "(") depth++;
2974
+ else if (compound[index] === ")" && --depth === 0) break;
2975
+ index++;
2976
+ }
2977
+ return result;
2978
+ }
2979
+ function findUnscopedHasVariants(text) {
2980
+ if (!text.toLowerCase().includes(":has(")) return [];
2981
+ const offenders = [];
2982
+ for (const token of text.split(/\s+/u)) for (const { prefix, group } of variantGroups(token)) {
2983
+ if (ATTRIBUTE_VALUE_NOT_SELECTOR_PREFIX.test(prefix)) continue;
2984
+ const relative = group.toLowerCase().replace(QUOTED_PATTERN, "\"\"").replaceAll(TAILWIND_SPACE, " ");
2985
+ const owner = GROUP_OR_PEER_ELEMENT_PREFIX.test(prefix) ? ".group" : ".self";
2986
+ if (hasCompounds(ANCESTOR_PREFIX.test(prefix) ? `:is(${relative.replaceAll(TAILWIND_ELEMENT_WITH_THE_CLASS, "*")}) .self` : relative.includes(TAILWIND_ELEMENT_WITH_THE_CLASS) ? relative.replaceAll(TAILWIND_ELEMENT_WITH_THE_CLASS, owner) : `${owner}:is(${relative})`).some((compound) => {
2987
+ const anchor = withoutNegations(compound);
2988
+ return !CLASS_ID_ATTRIBUTE_OR_LEADING_TAG.test(anchor) || ROOT_COMPOUND_PATTERN.test(anchor);
2989
+ })) offenders.push(`[${group}]`);
2990
+ }
2991
+ return offenders;
2992
+ }
2993
+ var no_unscoped_has_default = defineRule({
2994
+ meta: {
2995
+ type: "problem",
2996
+ docs: { description: "Disallow Tailwind arbitrary variants with a :has() that is not anchored to a class, attribute, id, or tag." }
2997
+ },
2998
+ create(context) {
2999
+ const message = (variant) => `Anchor the :has() in ${variant} to a class, attribute, or tag below the document root, e.g. [&+[data-x]_…] or a has-* variant. Chrome evaluates an unanchored :has() on every ancestor, so any DOM change then restyles the whole page.`;
3000
+ return {
3001
+ Literal(node) {
3002
+ if (typeof node.value !== "string") return;
3003
+ for (const variant of findUnscopedHasVariants(node.value)) context.report({
3004
+ node,
3005
+ message: message(variant)
3006
+ });
3007
+ },
3008
+ TemplateElement(node) {
3009
+ for (const variant of findUnscopedHasVariants(node.value.cooked ?? node.value.raw)) context.report({
3010
+ node,
3011
+ message: message(variant)
3012
+ });
3013
+ }
3014
+ };
3015
+ }
3016
+ });
3017
+ // src/rules/no-untranslated-ui-text.ts
3018
+ const DEFAULT_MESSAGE = "Every user-facing string goes through the message catalogs. Move this text to a catalog and read it from there.";
3019
+ const readMessage = (options) => {
3020
+ const [first] = options;
3021
+ return typeof first === "object" && first !== null && "message" in first && typeof first.message === "string" ? first.message : DEFAULT_MESSAGE;
3022
+ };
3023
+ const ATTRIBUTES_USERS_READ_OR_HEAR = /* @__PURE__ */ new Set([
3024
+ "alt",
3025
+ "aria-description",
3026
+ "aria-label",
3027
+ "aria-placeholder",
3028
+ "aria-roledescription",
3029
+ "aria-valuetext",
3030
+ "label",
3031
+ "placeholder",
3032
+ "title"
3033
+ ]);
3034
+ const HAS_LETTER_NOT_ONLY_SEPARATORS_OR_MARKS = /\p{L}/u;
3035
+ var no_untranslated_ui_text_default = defineRule({
3036
+ meta: {
3037
+ type: "problem",
3038
+ docs: { description: "Disallow JSX text and user-facing attributes that bypass the i18n catalogs." },
3039
+ schema: [{
3040
+ type: "object",
3041
+ properties: { message: {
3042
+ type: "string",
3043
+ description: "Names the project's catalogs and how to read them, in place of the default."
3044
+ } },
3045
+ additionalProperties: false
3046
+ }]
3047
+ },
3048
+ create(context) {
3049
+ const message = readMessage(context.options);
3050
+ const check = (node, text) => {
3051
+ if (HAS_LETTER_NOT_ONLY_SEPARATORS_OR_MARKS.test(text)) context.report({
3052
+ node,
3053
+ message
3054
+ });
3055
+ };
3056
+ return {
3057
+ JSXText(node) {
3058
+ check(node, node.value);
3059
+ },
3060
+ JSXAttribute(node) {
3061
+ if (node.name.type !== "JSXIdentifier" || !ATTRIBUTES_USERS_READ_OR_HEAR.has(node.name.name)) return;
3062
+ const value = node.value;
3063
+ if (value?.type === "Literal" && typeof value.value === "string") check(value, value.value);
3064
+ if (value?.type === "JSXExpressionContainer" && value.expression.type === "Literal" && typeof value.expression.value === "string") check(value.expression, value.expression.value);
3065
+ }
3066
+ };
3067
+ }
3068
+ });
3069
+ // src/rules/no-wall-clock-in-tests.ts
3070
+ const TEST_FILE_PATTERN = /\.(?:test|spec)\.[cm]?[jt]sx?$/u;
3071
+ const WALL_CLOCK_CALLS = /* @__PURE__ */ new Set([
3072
+ "Date.now",
3073
+ "performance.now",
3074
+ "process.hrtime",
3075
+ "process.hrtime.bigint"
3076
+ ]);
3077
+ const VI_MOCKING_FUNCTIONS = /* @__PURE__ */ new Set([
3078
+ "fn",
3079
+ "mock",
3080
+ "setSystemTime",
3081
+ "spyOn"
3082
+ ]);
3083
+ const MOCK_METHODS = /* @__PURE__ */ new Set([
3084
+ "mockImplementation",
3085
+ "mockImplementationOnce",
3086
+ "mockResolvedValue",
3087
+ "mockResolvedValueOnce",
3088
+ "mockReturnValue",
3089
+ "mockReturnValueOnce"
3090
+ ]);
3091
+ const MESSAGE$1 = "Wall-clock reading in a test; elapsed-time assertions pass or fail with runner load. Use TestClock/`Clock` under `it.effect`, `vi.setSystemTime`, or a fixed epoch. Benchmarks live behind an env gate.";
3092
+ const isStringLiteral = (node) => exists(unwrapExpression(node), (expression) => expression.type === "Literal" && typeof expression.value === "string");
3093
+ const memberPath = (node) => {
3094
+ const expression = unwrapExpression(node);
3095
+ if (isNone(expression)) return none();
3096
+ if (expression.value.type === "Identifier") return some([expression.value.name]);
3097
+ if (expression.value.type !== "MemberExpression") return none();
3098
+ if (expression.value.computed && !isStringLiteral(expression.value.property)) return none();
3099
+ const property = getPropertyName(expression.value.property);
3100
+ if (isNone(property)) return none();
3101
+ return map(memberPath(expression.value.object), (path) => [...path, property.value]);
3102
+ };
3103
+ const isWallClockCall = (callee) => match(memberPath(callee), {
3104
+ onNone: () => false,
3105
+ onSome: (path) => WALL_CLOCK_CALLS.has(path.join("."))
3106
+ });
3107
+ const isMockingCall = (callee) => {
3108
+ const expression = unwrapExpression(callee);
3109
+ if (isNone(expression) || expression.value.type !== "MemberExpression") return false;
3110
+ const property = getPropertyName(expression.value.property);
3111
+ if (isNone(property)) return false;
3112
+ if (MOCK_METHODS.has(property.value)) return true;
3113
+ return VI_MOCKING_FUNCTIONS.has(property.value) && isIdentifier(unwrapExpression(expression.value.object), "vi");
3114
+ };
3115
+ const seedsFakeTimeThroughAMock = (node) => {
3116
+ let child = node;
3117
+ let current = node.parent;
3118
+ while (current) {
3119
+ if (current.type === "CallExpression" && current.callee !== child && isMockingCall(current.callee)) return true;
3120
+ child = current;
3121
+ current = current.parent;
3122
+ }
3123
+ return false;
3124
+ };
3125
+ var no_wall_clock_in_tests_default = defineRule({
3126
+ meta: {
3127
+ type: "problem",
3128
+ docs: { description: "Disallow wall-clock readings (Date.now, new Date(), performance.now, process.hrtime) in tests." }
3129
+ },
3130
+ create(context) {
3131
+ if (!TEST_FILE_PATTERN.test(context.filename)) return {};
3132
+ return {
3133
+ CallExpression(node) {
3134
+ if (!isWallClockCall(node.callee)) return;
3135
+ if (seedsFakeTimeThroughAMock(node)) return;
3136
+ context.report({
3137
+ node,
3138
+ message: MESSAGE$1
3139
+ });
3140
+ },
3141
+ NewExpression(node) {
3142
+ if (node.arguments.length > 0) return;
3143
+ if (!isIdentifier(unwrapExpression(node.callee), "Date")) return;
3144
+ if (seedsFakeTimeThroughAMock(node)) return;
3145
+ context.report({
3146
+ node,
3147
+ message: MESSAGE$1
3148
+ });
3149
+ }
3150
+ };
3151
+ }
3152
+ });
3153
+ // src/rules/prefer-catch-tags.ts
3154
+ const MESSAGE = "Catch known tags with `Effect.catchTags({ Tag: handler })`, even for one tag.";
3155
+ var prefer_catch_tags_default = defineRule({
3156
+ meta: {
3157
+ type: "suggestion",
3158
+ docs: { description: "Require `Effect.catchTags` over `Effect.catchTag`." }
3159
+ },
3160
+ create(context) {
3161
+ const isEffectNamespace = (identifier) => {
3162
+ let scope = context.sourceCode.getScope(identifier);
3163
+ while (true) {
3164
+ const variable = scope.set.get(identifier.name);
3165
+ if (variable !== void 0) return variable.defs.some((def) => def.type === "ImportBinding" && def.node.type === "ImportNamespaceSpecifier" && def.parent?.type === "ImportDeclaration" && def.parent.source.value === "effect/Effect");
3166
+ if (scope.upper === null) return false;
3167
+ scope = scope.upper;
3168
+ }
3169
+ };
3170
+ return {
3171
+ ImportDeclaration(node) {
3172
+ if (node.source.value !== "effect/Effect") return;
3173
+ for (const specifier of node.specifiers) if (specifier.type === "ImportSpecifier" && (specifier.imported.type === "Identifier" ? specifier.imported.name : specifier.imported.value) === "catchTag") context.report({
3174
+ node: specifier,
3175
+ message: MESSAGE
3176
+ });
3177
+ },
3178
+ MemberExpression(node) {
3179
+ if (!node.computed && node.object.type === "Identifier" && node.property.type === "Identifier" && node.property.name === "catchTag" && isEffectNamespace(node.object)) context.report({
3180
+ node,
3181
+ message: MESSAGE
3182
+ });
3183
+ }
3184
+ };
3185
+ }
3186
+ });
3187
+ // src/rules/prefer-effect-fn.ts
3188
+ var prefer_effect_fn_default = defineRule({
3189
+ meta: {
3190
+ type: "suggestion",
3191
+ docs: { description: "Use Effect.fn for reusable generator-based Effect functions." }
3192
+ },
3193
+ create(context) {
3194
+ const isEffectImport = (identifier, member) => {
3195
+ let scope = context.sourceCode.getScope(identifier);
3196
+ while (true) {
3197
+ const variable = scope.set.get(identifier.name);
3198
+ if (variable !== void 0) return variable.defs.some((def) => {
3199
+ if (def.type !== "ImportBinding" || def.parent?.type !== "ImportDeclaration") return false;
3200
+ const source = def.parent.source.value;
3201
+ if (source === "effect/Effect") {
3202
+ if (member === "") return def.node.type === "ImportSpecifier" && (def.node.imported.type === "Identifier" ? def.node.imported.name : def.node.imported.value) === "gen";
3203
+ return def.node.type === "ImportNamespaceSpecifier";
3204
+ }
3205
+ return source === "effect" && def.node.type === "ImportSpecifier" && (def.node.imported.type === "Identifier" ? def.node.imported.name : def.node.imported.value) === "Effect";
3206
+ });
3207
+ if (scope.upper === null) return false;
3208
+ scope = scope.upper;
3209
+ }
3210
+ };
3211
+ const isGeneratorCall = (expression) => {
3212
+ if (expression.type !== "CallExpression") return false;
3213
+ const callee = expression.callee;
3214
+ if (callee.type === "Identifier") return isEffectImport(callee, "");
3215
+ if (callee.type !== "MemberExpression" || callee.computed) return false;
3216
+ if (callee.property.type !== "Identifier") return false;
3217
+ if (callee.property.name === "pipe") return isGeneratorCall(callee.object);
3218
+ return callee.property.name === "gen" && callee.object.type === "Identifier" && isEffectImport(callee.object, "gen");
3219
+ };
3220
+ const check = (node) => {
3221
+ if (node.async || node.generator) return;
3222
+ const parent = node.parent;
3223
+ if (node.type !== "FunctionDeclaration") {
3224
+ if (parent.type === "MethodDefinition") {
3225
+ if (parent.kind !== "method") return;
3226
+ } else if (parent.type === "Property") {
3227
+ if (parent.kind !== "init") return;
3228
+ const name = parent.key.type === "Identifier" ? parent.key.name : parent.key.type === "Literal" ? parent.key.value : void 0;
3229
+ const call = parent.parent.parent;
3230
+ if (call?.type === "CallExpression") {
3231
+ let callee = call.callee;
3232
+ while (callee.type === "CallExpression") callee = callee.callee;
3233
+ if (callee.type === "MemberExpression" && callee.property.type === "Identifier") {
3234
+ if ([
3235
+ "catchTags",
3236
+ "match",
3237
+ "matchEffect",
3238
+ "matchCauseEffect"
3239
+ ].includes(callee.property.name) || name === "defaultValue" && callee.property.name === "Reference") return;
3240
+ }
3241
+ }
3242
+ } else if (parent.type !== "VariableDeclarator" && parent.type !== "PropertyDefinition") return;
3243
+ }
3244
+ const body = node.body;
3245
+ if (body === null) return;
3246
+ let expression;
3247
+ if (body.type === "BlockStatement") {
3248
+ if (body.body.length !== 1 || body.body[0]?.type !== "ReturnStatement") return;
3249
+ expression = body.body[0].argument;
3250
+ } else expression = body;
3251
+ if (expression === null || !isGeneratorCall(expression)) return;
3252
+ context.report({
3253
+ node,
3254
+ message: "Use Effect.fn(\"Service.operation\") for reusable Effect functions. Reserve Effect.fnUntraced for documented hot paths or an existing span; keep Effect.gen for inline programs."
3255
+ });
3256
+ };
3257
+ return {
3258
+ ArrowFunctionExpression: check,
3259
+ FunctionExpression: check,
3260
+ FunctionDeclaration: check
3261
+ };
3262
+ }
3263
+ });
3264
+ // src/rules/require-suppression-reason.ts
3265
+ const TS_DIRECTIVE_PATTERN = /^\s*\*?\s*@ts-(?:expect-error|ignore|nocheck)(?![\w-])(.*)$/su;
3266
+ // src/index.ts
3267
+ var src_default = definePlugin({
3268
+ meta: { name: "jandragsbaek" },
3269
+ rules: {
3270
+ "max-file-lines": max_file_lines_default,
3271
+ "max-file-lines-hard": max_file_lines_hard_default,
3272
+ "namespace-node-imports": namespace_node_imports_default,
3273
+ "no-dom-test-environment": no_dom_test_environment_default,
3274
+ "no-em-dash-copy": no_em_dash_copy_default,
3275
+ "no-explanatory-comments": no_explanatory_comments_default,
3276
+ "no-hookless-use-function": no_hookless_use_function_default,
3277
+ "no-inline-schema-compile": no_inline_schema_compile_default,
3278
+ "no-manual-effect-runtime-in-tests": no_manual_effect_runtime_in_tests_default,
3279
+ "no-manual-memo": no_manual_memo_default,
3280
+ "no-polling-loop-in-tests": no_polling_loop_in_tests_default,
3281
+ "no-real-time-wait-in-tests": no_real_time_wait_in_tests_default,
3282
+ "no-test-in-loop": no_test_in_loop_default,
3283
+ "no-test-timeout-or-unreasoned-skip": no_test_timeout_or_unreasoned_skip_default,
3284
+ "no-unreasoned-state-sync": no_unreasoned_state_sync_default,
3285
+ "no-unscoped-has": no_unscoped_has_default,
3286
+ "no-untranslated-ui-text": no_untranslated_ui_text_default,
3287
+ "no-wall-clock-in-tests": no_wall_clock_in_tests_default,
3288
+ "prefer-catch-tags": prefer_catch_tags_default,
3289
+ "prefer-effect-fn": prefer_effect_fn_default,
3290
+ "require-suppression-reason": defineRule({
3291
+ meta: {
3292
+ type: "suggestion",
3293
+ docs: { description: "Require every lint or type-checker suppression to say why, in the directive." }
3294
+ },
3295
+ create(context) {
3296
+ const { sourceCode } = context;
3297
+ return { Program() {
3298
+ for (const directive of sourceCode.getDisableDirectives().directives) {
3299
+ if (directive.type === "enable" || directive.justification.trim()) continue;
3300
+ context.report({
3301
+ loc: directive.node.loc,
3302
+ message: "Say why: end the directive with `-- <reason>`."
3303
+ });
3304
+ }
3305
+ for (const comment of sourceCode.getAllComments()) {
3306
+ const after = TS_DIRECTIVE_PATTERN.exec(comment.value)?.[1];
3307
+ if (after === void 0 || after.replace(/^[\s:-]+/u, "").trim()) continue;
3308
+ context.report({
3309
+ loc: comment.loc,
3310
+ message: "Say why: write the reason after the directive, on the same comment."
3311
+ });
3312
+ }
3313
+ } };
3314
+ }
3315
+ })
3316
+ }
3317
+ });
3318
+ export { src_default as default };