@systemfsoftware/oxlint-plugin-effect-platform 2.2.0 → 3.0.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 CHANGED
@@ -1,5 +1,7 @@
1
1
  import { defineRule } from "@oxlint/plugins";
2
2
  import { Effect, Schema } from "effect";
3
+ import { readFileSync } from "node:fs";
4
+ import { dirname, join, relative, resolve } from "node:path";
3
5
  // src/rules/entrypoint-interprets-once.config.ts
4
6
  const Options$7 = Schema.Struct({});
5
7
  const ENTRYPOINT_FILE$2 = /(?:^|[\\/])main\.ts$/u;
@@ -22,7 +24,7 @@ const MULTIPLE_EDGES_EXPECTED = "exactly one interpretation edge in the entrypoi
22
24
  const MULTIPLE_EDGES_ACTUAL = "a second interpretation edge in the same entrypoint";
23
25
  const MULTIPLE_EDGES_FIX = "collapse the program into one Effect and interpret it once; a second edge starts fibers the outer edge cannot interrupt and whose finalizers it never runs";
24
26
  const INTERPRETS_ONCE_MESSAGE = "{{name}} is forbidden. Expected: {{expected}}. Actual: {{actual}}. Fix: {{fix}}.";
25
- const meta$9 = {
27
+ const meta$11 = {
26
28
  type: "problem",
27
29
  docs: { description: "Require exactly one interpretation edge in main.ts. An Effect value is a description; the entrypoint is the single place it is interpreted. Zero edges means the file is a module wearing the entrypoint name; two means the outer edge cannot interrupt or finalize the fibers the inner one started." },
28
30
  schema: [Options$7],
@@ -46,7 +48,7 @@ const edgeName = (callee) => {
46
48
  return QUALIFIED_EDGE_CALLEES.has(qualified) ? qualified : null;
47
49
  };
48
50
  const entrypointInterpretsOnce = defineRule({
49
- meta: meta$9,
51
+ meta: meta$11,
50
52
  create(context) {
51
53
  if (!isEntrypointFile$2(context.filename)) return {};
52
54
  const edges = [];
@@ -96,7 +98,7 @@ const STAR_EXPORT = "a re-export from main.ts";
96
98
  const ENTRYPOINT_EXPORT_EXPECTED = "an entrypoint with no public surface at all";
97
99
  const ENTRYPOINT_EXPORT_ACTUAL = "an entrypoint exporting a binding for another module to import";
98
100
  const ENTRYPOINT_EXPORT_FIX = "nothing may import main.ts, so an export here is dead weight - move the binding to the cell that owns it (executor, adapter, layer) and leave main.ts holding only the interpretation edge";
99
- const meta$8 = {
101
+ const meta$10 = {
100
102
  type: "problem",
101
103
  docs: { description: "Ban every export from main.ts. An entrypoint is interpreted, never imported, so an exported binding proves the file is a library wearing the entrypoint name - the exemption that lets a junk drawer grow behind a sanctioned filename." },
102
104
  schema: [Options$6],
@@ -105,7 +107,7 @@ const meta$8 = {
105
107
  // src/rules/entrypoint-no-exports.ts
106
108
  const isEntrypointFile$1 = (filename) => ENTRYPOINT_FILE$1.test(filename);
107
109
  const entrypointNoExports = defineRule({
108
- meta: meta$8,
110
+ meta: meta$10,
109
111
  create(context) {
110
112
  if (!isEntrypointFile$1(context.filename)) return {};
111
113
  const reportExport = (node, name) => {
@@ -141,7 +143,7 @@ const PROMISE_CONSTRUCTORS = /* @__PURE__ */ new Set(["Effect.promise", "Effect.
141
143
  const PROMISE_WRAPPER_EXPECTED = "the program itself handed to runMain";
142
144
  const PROMISE_WRAPPER_ACTUAL = "a foreign promise wrapped in an Effect and handed to runMain";
143
145
  const PROMISE_WRAPPER_FIX = "the awaited framework starts its own fibers, so runMain interrupts nothing and runs none of their finalizers - either let the framework own the loop and drop runMain, or build the program as one Effect and interpret that";
144
- const meta$7 = {
146
+ const meta$9 = {
145
147
  type: "problem",
146
148
  docs: { description: "Ban runMain wrapping a bare Effect.promise or Effect.tryPromise in main.ts. The outer edge only awaits a promise: the fibers doing the work belong to a runtime inside it, beyond reach of the interrupt handling and teardown runMain exists to provide." },
147
149
  schema: [Options$5],
@@ -169,7 +171,7 @@ const promiseConstructorName = (node) => {
169
171
  return PROMISE_CONSTRUCTORS.has(qualified) ? qualified : null;
170
172
  };
171
173
  const entrypointNoPromiseWrapper = defineRule({
172
- meta: meta$7,
174
+ meta: meta$9,
173
175
  create(context) {
174
176
  if (!isEntrypointFile(context.filename)) return {};
175
177
  return { CallExpression(node) {
@@ -230,10 +232,830 @@ const entrypointNotImported = defineRule({
230
232
  ExportAllDeclaration(node) {
231
233
  reportSource(node, node.source.value);
232
234
  },
233
- ImportExpression(node) {
234
- if (node.source.type !== "Literal") return;
235
- if (typeof node.source.value !== "string") return;
236
- reportSource(node, node.source.value);
235
+ ImportExpression(node) {
236
+ if (node.source.type !== "Literal") return;
237
+ if (typeof node.source.value !== "string") return;
238
+ reportSource(node, node.source.value);
239
+ }
240
+ };
241
+ }
242
+ });
243
+ // ../import-origin/dist/index.mjs
244
+ const isScopeLike$3 = (value) => typeof value === "object" && value !== null && "references" in value && "upper" in value;
245
+ const isIdentifier$1 = (node) => node.type === "Identifier";
246
+ const isMemberExpression = (node) => node.type === "MemberExpression";
247
+ const isVariableDeclarator = (node) => node.type === "VariableDeclarator";
248
+ /**
249
+ * The variable a reference identifier resolves to: the reference's own
250
+ * `resolved` binding, found by identity in the scope tree. Name-based scope
251
+ * lookups merge same-scope re-declarations (an import plus a shadowing const
252
+ * collapse into one variable), so only the reference knows the shadow.
253
+ */
254
+ const variableOfIdentifier = (identifier, getScope) => {
255
+ const scopeValue = getScope(identifier);
256
+ let scope = isScopeLike$3(scopeValue) ? scopeValue : null;
257
+ while (scope !== null) {
258
+ const found = scope.references.find((reference) => reference.identifier === identifier);
259
+ if (found !== void 0 && found.resolved !== null) return { defs: found.resolved.defs };
260
+ if (found !== void 0) return null;
261
+ scope = scope.upper;
262
+ }
263
+ return null;
264
+ };
265
+ /** The member names that forward, rather than extend, an origin. */
266
+ const FORWARDING_MEMBERS = {
267
+ bind: true,
268
+ call: true,
269
+ apply: true
270
+ };
271
+ /** TS wrappers that carry an expression without changing what it denotes. */
272
+ const TS_EXPRESSION_WRAPPERS = {
273
+ TSAsExpression: true,
274
+ TSSatisfiesExpression: true,
275
+ TSNonNullExpression: true,
276
+ TSTypeAssertion: true,
277
+ TSInstantiationExpression: true
278
+ };
279
+ const isExpressionWrapper = (node) => TS_EXPRESSION_WRAPPERS[node.type] === true;
280
+ const unwrapExpression$1 = (node) => {
281
+ let current = node;
282
+ while (isExpressionWrapper(current)) current = current.expression;
283
+ return current;
284
+ };
285
+ /**
286
+ * The statically known string value of an expression that evaluates to a
287
+ * string: a string literal, a template with no substitutions, a `+`
288
+ * concatenation of two such, or `Symbol.for('name')`. Anything not foldable
289
+ * from syntax alone is `null` — never a guessed name. The `Symbol.for` fold is
290
+ * the well-known-symbol member addressing: `S[Symbol.for('Struct')]` names the
291
+ * same member as `S.Struct`. A shadowed `Symbol` binding would break the fold —
292
+ * the same permissiveness the resolver already extends to local aliases.
293
+ */
294
+ const staticStringValue = (node, depth = 0) => {
295
+ if (node === null || depth > 64) return null;
296
+ if (node.type === "Literal" && typeof node.value === "string") return node.value;
297
+ if (node.type === "TemplateLiteral" && node.expressions.length === 0) return node.quasis[0]?.value.cooked ?? null;
298
+ if (node.type === "BinaryExpression" && node.operator === "+") {
299
+ const left = staticStringValue(node.left, depth + 1);
300
+ if (left === null) return null;
301
+ const right = staticStringValue(node.right, depth + 1);
302
+ return right === null ? null : left + right;
303
+ }
304
+ if (node.type === "CallExpression" && node.arguments.length === 1) {
305
+ const argument = node.arguments[0];
306
+ if (argument !== void 0 && argument.type === "Literal" && typeof argument.value === "string" && node.callee.type === "MemberExpression" && !node.callee.computed && node.callee.object.type === "Identifier" && node.callee.object.name === "Symbol" && node.callee.property.type === "Identifier" && node.callee.property.name === "for") return argument.value;
307
+ }
308
+ return null;
309
+ };
310
+ /**
311
+ * The declared member name of a member expression: an identifier property in a
312
+ * non-computed position, or a computed property whose key folds to a static
313
+ * string (`S['Union']`, `S['Stru' + 'ct']`, `S[Symbol.for('Struct')]`).
314
+ * Everything else — a variable subscript `S[key]` — is `null`: the member is
315
+ * not statically known. Never fall back to the subscript variable's name; that
316
+ * would read `S[decoder]` as the member `decoder` and misclassify a codec use
317
+ * as a schema construction.
318
+ */
319
+ const memberNameOf = (node) => {
320
+ const property = node.property;
321
+ if (!node.computed && property.type === "Identifier") return property.name;
322
+ return staticStringValue(property);
323
+ };
324
+ /**
325
+ * The alias-chain ladder guard. 64 levels of alias/member indirection is
326
+ * beyond any real chain; a chain that exhausts it resolves to `null` — the
327
+ * "undetermined" value, not "definitely not an import". Callers that must
328
+ * fail closed treat that exhausted-`null` the same as any other unresolved
329
+ * module-local chain (schema-declaration-location reports it), so a deep
330
+ * ladder can no longer park a schema silently. Tune the cap, never the
331
+ * semantics: a depth overflow is a report, not a pass.
332
+ */
333
+ const MAX_DEPTH = 64;
334
+ /**
335
+ * What this expression ultimately denotes: `{ source, importedName, path }`
336
+ * for an identifier or member chain that reaches an import binding, `null`
337
+ * for everything the resolver cannot prove — my "undetermined", not "this is
338
+ * not an import".
339
+ */
340
+ const resolveImportOrigin = (node, getScope, depth = 0) => {
341
+ if (depth > MAX_DEPTH) return null;
342
+ node = unwrapExpression$1(node);
343
+ if (isIdentifier$1(node)) return resolveIdentifierOrigin(node, getScope, depth);
344
+ if (node.type === "SequenceExpression") {
345
+ const last = node.expressions[node.expressions.length - 1];
346
+ return last === void 0 ? null : resolveImportOrigin(last, getScope, depth + 1);
347
+ }
348
+ if (isMemberExpression(node)) {
349
+ const object = resolveImportOrigin(node.object, getScope, depth + 1);
350
+ if (object === null) return null;
351
+ const member = memberNameOf(node);
352
+ if (member === null || FORWARDING_MEMBERS[member] === true) return object;
353
+ return object.importedName === null ? {
354
+ ...object,
355
+ importedName: member
356
+ } : {
357
+ ...object,
358
+ path: [...object.path, member]
359
+ };
360
+ }
361
+ if (node.type === "CallExpression" && isMemberExpression(node.callee)) {
362
+ const member = memberNameOf(node.callee);
363
+ if (member !== null && FORWARDING_MEMBERS[member] === true) return resolveImportOrigin(node.callee.object, getScope, depth + 1);
364
+ }
365
+ return null;
366
+ };
367
+ const resolveIdentifierOrigin = (identifier, getScope, depth) => {
368
+ const variable = variableOfIdentifier(identifier, getScope);
369
+ if (variable === null) return null;
370
+ const def = variable.defs[variable.defs.length - 1];
371
+ if (def === void 0) return null;
372
+ if (def.type === "ImportBinding") {
373
+ const declaration = def.parent;
374
+ if (declaration === null || declaration.type !== "ImportDeclaration") return null;
375
+ const source = declaration.source.value;
376
+ if (typeof source !== "string") return null;
377
+ const specifier = def.node;
378
+ if (specifier.type === "ImportSpecifier") {
379
+ const imported = specifier.imported;
380
+ if (imported.type === "Identifier") return {
381
+ source,
382
+ importedName: imported.name,
383
+ path: []
384
+ };
385
+ return imported.type === "Literal" && typeof imported.value === "string" ? {
386
+ source,
387
+ importedName: imported.value,
388
+ path: []
389
+ } : null;
390
+ }
391
+ if (specifier.type === "ImportDefaultSpecifier") return {
392
+ source,
393
+ importedName: "default",
394
+ path: []
395
+ };
396
+ return {
397
+ source,
398
+ importedName: null,
399
+ path: []
400
+ };
401
+ }
402
+ if (def.type !== "Variable") return null;
403
+ const declarator = isVariableDeclarator(def.node) ? def.node : def.parent !== null && isVariableDeclarator(def.parent) ? def.parent : null;
404
+ if (declarator === null) return null;
405
+ const declaration = declarator.parent;
406
+ if (declaration === null || declaration.type !== "VariableDeclaration") return null;
407
+ const init = declarator.init;
408
+ if (init === null) return null;
409
+ const base = resolveImportOrigin(init, getScope, depth + 1);
410
+ if (base === null) return null;
411
+ if (declarator.id.type === "ObjectPattern") {
412
+ const bound = def.name;
413
+ if (bound === null) return null;
414
+ for (const property of declarator.id.properties) {
415
+ if (property.type !== "Property") continue;
416
+ const key = property.key;
417
+ const keyName = !property.computed && key.type === "Identifier" ? key.name : staticStringValue(key);
418
+ if (keyName === null) continue;
419
+ let binding = property.value;
420
+ if (binding.type === "AssignmentPattern") {
421
+ if (binding.left.type !== "Identifier") continue;
422
+ binding = binding.left;
423
+ }
424
+ if (binding !== bound) continue;
425
+ return base.importedName === null ? {
426
+ ...base,
427
+ importedName: keyName
428
+ } : {
429
+ ...base,
430
+ path: [...base.path, keyName]
431
+ };
432
+ }
433
+ return null;
434
+ }
435
+ return base;
436
+ };
437
+ const EFFECT_PACKAGE = "effect";
438
+ const EFFECT_SUBPATH_PREFIX = "effect/";
439
+ const isAreaBarrelPath = (path) => path.length > 0 && !path.includes("/") && path[0] === path[0]?.toLowerCase();
440
+ const isEffectBarrel = (source) => source === EFFECT_PACKAGE || source.startsWith(EFFECT_SUBPATH_PREFIX) && isAreaBarrelPath(source.slice(7));
441
+ const effectModulePath = (source, importedName) => {
442
+ if (source === EFFECT_PACKAGE) return importedName;
443
+ if (!source.startsWith(EFFECT_SUBPATH_PREFIX)) return null;
444
+ const path = source.slice(7);
445
+ if (!isAreaBarrelPath(path)) return path;
446
+ return importedName === null ? null : `${path}/${importedName}`;
447
+ };
448
+ /** The mappers that apply a handler to an effect's success value. */
449
+ const MAPPER_MODULES = /* @__PURE__ */ new Set([
450
+ "Effect/map",
451
+ "Effect/flatMap",
452
+ "Effect/andThen"
453
+ ]);
454
+ /** The left-to-right pipelines whose arguments continue the effect chain. */
455
+ const PIPE_MODULES = /* @__PURE__ */ new Set([
456
+ "Effect/pipe",
457
+ "Function/pipe",
458
+ "pipe"
459
+ ]);
460
+ /** Option consumers that are themselves a defect on absence. */
461
+ const THROWING_CONSUMER_MODULES = /* @__PURE__ */ new Set(["Option/getOrThrow", "Option/getOrThrowWith"]);
462
+ /** The predicates that narrow a bound Option to one side. */
463
+ const NARROWER_MODULES = /* @__PURE__ */ new Set(["Option/isNone", "Option/isSome"]);
464
+ const OR_DIE_MODULE = "Effect/orDie";
465
+ const meta$7 = {
466
+ type: "problem",
467
+ docs: { description: "An `Effect.serviceOption` read that reaches a defect while its own Option is None. The rule follows the read to its None branch — the `onNone` handler of `Option.match`, the fallback of `Option.getOrElse`, `Option.getOrThrow`/`Option.getOrThrowWith` themselves, the None side of an `Option.isNone`/`Option.isSome` narrowing, and `Effect.orDie` over any `Effect.fromOption` of the read — through `Effect.map`, `Effect.flatMap`, `Effect.andThen`, `.pipe`, a bound `yield*` value, or an inline `yield*` argument. Sinks are `Effect.die`, `Effect.failCause(Cause.die(...))`, `throw`, and the throwing Option getters, resolved by import origin so aliased, namespaced and named imports agree. Optional reads that fall back, skip, or fail with a typed error pass with no annotation. Gaps and examples: the README." },
468
+ schema: [],
469
+ messages: { defectOnNone: "A defect on a missing service is forbidden. Expected: {{tag}} in the requirement type, or a fallback, a skip or Effect.fail on None. Actual: {{read}} reaches {{sink}} on None. Fix: {{fix}}." }
470
+ };
471
+ // src/rules/no-die-on-service-option.ts
472
+ const isScopeLike$2 = (value) => typeof value === "object" && value !== null && "references" in value && "upper" in value && "set" in value;
473
+ const isFunctionNode$1 = (node) => node.type === "FunctionDeclaration" || node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression";
474
+ const isGeneratorFunction = (node) => node.type !== "ArrowFunctionExpression" && node.generator === true;
475
+ const staticMemberNameOf$1 = (member) => {
476
+ if (member.computed === true) {
477
+ const property = member.property;
478
+ return property.type === "Literal" && typeof property.value === "string" ? property.value : null;
479
+ }
480
+ return member.property.type === "Identifier" ? member.property.name : null;
481
+ };
482
+ /** The outermost TypeScript wrapper or parentheses around `node`, which is what its consumer sees. */
483
+ const wrapperOf = (node) => {
484
+ let current = node;
485
+ for (;;) {
486
+ const parent = current.parent ?? null;
487
+ if (parent !== null && (parent.type === "TSAsExpression" || parent.type === "TSSatisfiesExpression" || parent.type === "TSNonNullExpression" || parent.type === "TSTypeAssertion" || parent.type === "ParenthesizedExpression") && parent.expression === current) {
488
+ current = parent;
489
+ continue;
490
+ }
491
+ return current;
492
+ }
493
+ };
494
+ const unwrapExpression = (node) => {
495
+ let current = node;
496
+ for (;;) {
497
+ if (current.type === "TSAsExpression" || current.type === "TSSatisfiesExpression" || current.type === "TSNonNullExpression" || current.type === "TSTypeAssertion" || current.type === "TSInstantiationExpression") {
498
+ current = current.expression;
499
+ continue;
500
+ }
501
+ return current;
502
+ }
503
+ };
504
+ /**
505
+ * The module path an origin denotes, keyed the way the vendored Effect names its exports:
506
+ * `Effect/die`, `Option/match`, `Cause/die`. A root-barrel or `effect/<area>` import folds the
507
+ * imported name into the module (`effect` + `Effect` is `Effect`); a deeper subpath is the module
508
+ * itself and its imported name is a member (`effect/Effect` + `serviceOption` is `Effect/serviceOption`).
509
+ */
510
+ const originModulePath = (source, importedName, path) => {
511
+ const barrel = isEffectBarrel(source);
512
+ if (importedName !== null) {
513
+ const module = effectModulePath(source, importedName);
514
+ if (module === null) return null;
515
+ return [module, ...barrel ? path : [importedName, ...path]].join("/");
516
+ }
517
+ const module = effectModulePath(source, null);
518
+ return module === null ? null : [module, ...path].join("/");
519
+ };
520
+ const enclosingFunctionOf$1 = (node) => {
521
+ let current = node.parent ?? null;
522
+ while (current !== null) {
523
+ if (isFunctionNode$1(current)) return current;
524
+ current = current.parent ?? null;
525
+ }
526
+ return null;
527
+ };
528
+ const scopeAt = (node, getScope) => {
529
+ const value = getScope(node);
530
+ return isScopeLike$2(value) ? value : null;
531
+ };
532
+ /** The variable a declared identifier binds, searched up the scope chain like the resolver does. */
533
+ const variableOfBinding = (identifier, getScope) => {
534
+ if (identifier.type !== "Identifier") return null;
535
+ let scope = scopeAt(identifier, getScope);
536
+ while (scope !== null) {
537
+ const variable = scope.set.get(identifier.name);
538
+ if (variable !== void 0) return variable;
539
+ scope = scope.upper;
540
+ }
541
+ return null;
542
+ };
543
+ /** The variable a reference identifier resolves to, or `null` for an unresolved or shadowed name. */
544
+ const variableOfReference = (identifier, getScope) => {
545
+ let scope = scopeAt(identifier, getScope);
546
+ while (scope !== null) {
547
+ const reference = scope.references.find((candidate) => candidate.identifier === identifier);
548
+ if (reference !== void 0) return reference.resolved;
549
+ scope = scope.upper;
550
+ }
551
+ return null;
552
+ };
553
+ const referencesOfBinding = (variable, excluded) => variable.references.flatMap((reference) => reference.identifier === excluded ? [] : [reference.identifier]);
554
+ /** The callee to resolve, seeing through the traced form `Effect.fn('name')(generator)`. */
555
+ const fnCalleeOf = (call) => call.callee.type === "CallExpression" ? call.callee.callee : call.callee;
556
+ /** The `Effect.gen`/`Effect.fn` generator runs as part of the branch that contains it, not behind a boundary. */
557
+ const isTransparentGenerator = (node, root, moduleOfCallee) => {
558
+ if (!isGeneratorFunction(node)) return false;
559
+ const call = node.parent ?? null;
560
+ if (call === null || call.type !== "CallExpression") return false;
561
+ if (!call.arguments.some((argument) => argument === node)) return false;
562
+ const origin = moduleOfCallee(fnCalleeOf(call));
563
+ if (origin === "Effect/gen") return true;
564
+ if (origin !== "Effect/fn") return false;
565
+ if (call === root) return true;
566
+ const outer = call.parent ?? null;
567
+ return outer !== null && outer.type === "CallExpression" && outer.callee === call;
568
+ };
569
+ const isWithin = (node, root, moduleOfCallee) => {
570
+ let current = node;
571
+ for (;;) {
572
+ if (current === root) return true;
573
+ if (isFunctionNode$1(current) && current !== root && !isTransparentGenerator(current, root, moduleOfCallee)) return false;
574
+ const parent = current.parent ?? null;
575
+ if (parent === null) return false;
576
+ current = parent;
577
+ }
578
+ };
579
+ /** Every path through the statement ends in `return` or `throw`. */
580
+ const definitelyExits = (node) => {
581
+ if (node === null) return false;
582
+ if (node.type === "ReturnStatement" || node.type === "ThrowStatement") return true;
583
+ if (node.type === "BlockStatement") {
584
+ const last = node.body[node.body.length - 1];
585
+ return last !== void 0 && definitelyExits(last);
586
+ }
587
+ if (node.type === "IfStatement") return node.alternate !== null && definitelyExits(node.consequent) && definitelyExits(node.alternate);
588
+ return false;
589
+ };
590
+ const noneHandlerOf = (config) => {
591
+ if (config === null) return null;
592
+ const node = unwrapExpression(config);
593
+ if (node.type !== "ObjectExpression") return null;
594
+ for (const property of node.properties) {
595
+ if (property.type !== "Property" || property.computed) continue;
596
+ const key = property.key;
597
+ if ((key.type === "Identifier" ? key.name : key.type === "Literal" && typeof key.value === "string" ? key.value : null) === "onNone") return property.value;
598
+ }
599
+ return null;
600
+ };
601
+ const causeDieArgument = (call, moduleOfCallee) => {
602
+ const argument = call.arguments[0];
603
+ if (argument === void 0) return false;
604
+ const value = unwrapExpression(argument);
605
+ return value.type === "CallExpression" && moduleOfCallee(value.callee) === "Cause/die";
606
+ };
607
+ const noDieOnServiceOption = defineRule({
608
+ meta: meta$7,
609
+ create(context) {
610
+ const getScope = (node) => context.sourceCode.getScope(node);
611
+ const sourceCode = context.sourceCode;
612
+ const reads = [];
613
+ const sinks = [];
614
+ const narrowers = [];
615
+ const collapse = (text) => text.replace(/\s+/gu, " ").trim();
616
+ const textOf = (node) => collapse(sourceCode.getText(node));
617
+ function moduleOf(node) {
618
+ const origin = resolveImportOrigin(node, getScope);
619
+ return origin === null ? null : originModulePath(origin.source, origin.importedName, origin.path);
620
+ }
621
+ function moduleOfCallee(node) {
622
+ return moduleOf(node);
623
+ }
624
+ const record = (node, search) => {
625
+ if (search.finding !== null) return;
626
+ search.finding = {
627
+ node,
628
+ label: textOf(node)
629
+ };
630
+ };
631
+ function firstSinkWithin(root) {
632
+ if (root === null) return null;
633
+ for (const site of sinks) if (isWithin(site.node, root, moduleOfCallee)) return site;
634
+ return null;
635
+ }
636
+ function recordWithin(root, search) {
637
+ if (root === null) return search.finding !== null;
638
+ if (search.finding !== null) return true;
639
+ const site = firstSinkWithin(root);
640
+ if (site === null) return false;
641
+ search.finding = site;
642
+ return true;
643
+ }
644
+ const isOrDie = (node) => {
645
+ const value = unwrapExpression(node);
646
+ return moduleOf(value.type === "CallExpression" ? value.callee : value) === OR_DIE_MODULE;
647
+ };
648
+ const orDieCalleeOf = (node) => {
649
+ const value = unwrapExpression(node);
650
+ return value.type === "CallExpression" ? value.callee : value;
651
+ };
652
+ /** An `Effect.orDie` step that runs after `current` in a pipeline; one before it sees no typed failure yet. */
653
+ const orDieAfter = (steps, current) => {
654
+ const index = steps.findIndex((step) => step === current);
655
+ const step = steps.slice(index + 1).find((argument) => isOrDie(argument));
656
+ return step === void 0 ? null : orDieCalleeOf(step);
657
+ };
658
+ /** `Effect.orDie` above any `Effect.fromOption` of the read turns its typed failure into a defect. */
659
+ function orDieAbove(start) {
660
+ let current = start;
661
+ for (let hop = 0; hop < 64; hop += 1) {
662
+ const parent = current.parent ?? null;
663
+ if (parent === null) return null;
664
+ if (isFunctionNode$1(parent)) {
665
+ if (parent.type === "ArrowFunctionExpression" && parent.body === current) {
666
+ current = parent;
667
+ continue;
668
+ }
669
+ return null;
670
+ }
671
+ if (parent.type === "ReturnStatement" && parent.argument === current) {
672
+ const enclosing = enclosingFunctionOf$1(parent);
673
+ if (enclosing === null) return null;
674
+ current = enclosing;
675
+ continue;
676
+ }
677
+ if (parent.type === "MemberExpression" && parent.object === current && staticMemberNameOf$1(parent) === "pipe") {
678
+ const call = parent.parent ?? null;
679
+ if (call === null || call.type !== "CallExpression" || call.callee !== parent) return null;
680
+ const step = call.arguments.find((argument) => isOrDie(argument));
681
+ if (step !== void 0) return orDieCalleeOf(step);
682
+ current = call;
683
+ continue;
684
+ }
685
+ if (parent.type === "CallExpression") {
686
+ if (!parent.arguments.some((argument) => argument === current)) return null;
687
+ const origin = moduleOf(parent.callee);
688
+ if (origin === "Effect/orDie") return parent.callee;
689
+ if (parent.callee.type === "MemberExpression" && staticMemberNameOf$1(parent.callee) === "pipe" || origin !== null && PIPE_MODULES.has(origin)) {
690
+ const orDie = orDieAfter(parent.arguments, current);
691
+ if (orDie !== null) return orDie;
692
+ current = parent;
693
+ continue;
694
+ }
695
+ if (origin !== null && MAPPER_MODULES.has(origin)) {
696
+ current = parent;
697
+ continue;
698
+ }
699
+ return null;
700
+ }
701
+ return null;
702
+ }
703
+ return null;
704
+ }
705
+ function checkOrDie(fromOption, search) {
706
+ const orDie = orDieAbove(fromOption);
707
+ if (orDie !== null) record(orDie, search);
708
+ }
709
+ const denotes = (argument, key) => {
710
+ const value = unwrapExpression(argument);
711
+ if (key.kind === "node") return value === key.node;
712
+ return value.type === "Identifier" && variableOfReference(value, getScope) === key.variable;
713
+ };
714
+ /** The enclosing `if`/conditional test a narrower call sits in, with `!` and left-most `&&` chains climbed. */
715
+ const narrowingContext = (call) => {
716
+ const origin = moduleOf(call.callee);
717
+ if (origin === null || !NARROWER_MODULES.has(origin)) return null;
718
+ let test = call;
719
+ let inverted = false;
720
+ for (;;) {
721
+ const parent = test.parent ?? null;
722
+ if (parent === null) break;
723
+ if (parent.type === "UnaryExpression" && parent.operator === "!" && parent.argument === test) {
724
+ inverted = !inverted;
725
+ test = parent;
726
+ continue;
727
+ }
728
+ if (parent.type === "LogicalExpression" && parent.operator === "&&" && parent.left === test) {
729
+ test = parent;
730
+ continue;
731
+ }
732
+ break;
733
+ }
734
+ const noneOnTrue = origin === "Option/isNone" !== inverted;
735
+ return {
736
+ test,
737
+ noneOnTrue,
738
+ bothSidesNone: noneOnTrue && test !== call && !inverted
739
+ };
740
+ };
741
+ const noneSideOf = (contextResult) => {
742
+ const parent = contextResult.test.parent ?? null;
743
+ if (parent === null) return null;
744
+ if (contextResult.bothSidesNone) return parent;
745
+ const noneOnTrue = contextResult.noneOnTrue;
746
+ if (parent.type === "IfStatement" && parent.test === contextResult.test) return noneOnTrue ? parent.consequent : parent.alternate;
747
+ if (parent.type === "ConditionalExpression" && parent.test === contextResult.test) return noneOnTrue ? parent.consequent : parent.alternate;
748
+ return null;
749
+ };
750
+ /** A later `if` on the same Option whose None side exits ends reachability on None. */
751
+ function subsequentNoneSideExits(statement, key) {
752
+ for (const narrower of narrowers) {
753
+ if (!isWithin(narrower, statement, moduleOfCallee)) continue;
754
+ const argument = narrower.arguments[0];
755
+ if (argument === void 0 || !denotes(argument, key)) continue;
756
+ const narrowing = narrowingContext(narrower);
757
+ if (narrowing === null) continue;
758
+ const noneSide = noneSideOf(narrowing);
759
+ if (noneSide !== null && definitelyExits(noneSide)) return true;
760
+ }
761
+ return false;
762
+ }
763
+ /** Statements after a narrowing `if` remain reachable on None while its None side can fall through. */
764
+ function afterNarrowing(ifStatement, key, search) {
765
+ const at = narrowingOfIf(ifStatement, key);
766
+ if (at === null) return;
767
+ const noneSide = at.noneOnTrue ? ifStatement.consequent : ifStatement.alternate;
768
+ if (noneSide !== null && definitelyExits(noneSide)) return;
769
+ const parent = ifStatement.parent ?? null;
770
+ let body = null;
771
+ if (parent !== null && parent.type === "BlockStatement") body = parent.body;
772
+ else if (parent !== null && parent.type === "Program") body = parent.body;
773
+ if (body === null) return;
774
+ const index = body.findIndex((statement) => statement === ifStatement);
775
+ if (index < 0) return;
776
+ for (let position = index + 1; position < body.length; position += 1) {
777
+ const statement = body[position];
778
+ if (statement === void 0) return;
779
+ const later = statement.type === "IfStatement" ? narrowingOfIf(statement, key) : null;
780
+ if (later !== null && statement.type === "IfStatement") {
781
+ const laterNone = later.noneOnTrue ? statement.consequent : statement.alternate;
782
+ if (recordWithin(laterNone, search)) return;
783
+ if (laterNone !== null && definitelyExits(laterNone)) return;
784
+ continue;
785
+ }
786
+ if (recordWithin(statement, search)) return;
787
+ if (subsequentNoneSideExits(statement, key)) return;
788
+ if (definitelyExits(statement)) return;
789
+ }
790
+ }
791
+ const narrowingOfIf = (ifStatement, key) => {
792
+ for (const narrower of narrowers) {
793
+ const argument = narrower.arguments[0];
794
+ if (argument === void 0 || !denotes(argument, key)) continue;
795
+ const narrowing = narrowingContext(narrower);
796
+ if (narrowing === null) continue;
797
+ const parent = narrowing.test.parent ?? null;
798
+ if (parent === null || parent.type !== "IfStatement" || parent !== ifStatement) continue;
799
+ if (narrowing.bothSidesNone) return null;
800
+ return { noneOnTrue: narrowing.noneOnTrue };
801
+ }
802
+ return null;
803
+ };
804
+ function visitNarrower(call, key, search) {
805
+ const narrowing = narrowingContext(call);
806
+ if (narrowing === null) return;
807
+ const parent = narrowing.test.parent ?? null;
808
+ if (parent === null) return;
809
+ if (narrowing.bothSidesNone) {
810
+ recordWithin(parent, search);
811
+ return;
812
+ }
813
+ const noneOnTrue = narrowing.noneOnTrue;
814
+ if (parent.type === "IfStatement" && parent.test === narrowing.test) {
815
+ if (noneOnTrue) recordWithin(narrowing.test, search);
816
+ if (recordWithin(noneOnTrue ? parent.consequent : parent.alternate, search)) return;
817
+ afterNarrowing(parent, key, search);
818
+ return;
819
+ }
820
+ if (parent.type === "ConditionalExpression" && parent.test === narrowing.test) recordWithin(noneOnTrue ? parent.consequent : parent.alternate, search);
821
+ }
822
+ function visitOptionPipeSteps(steps, search) {
823
+ for (const step of steps) {
824
+ const value = unwrapExpression(step);
825
+ if (value.type === "CallExpression") {
826
+ const origin = moduleOf(value.callee);
827
+ if (origin === "Option/match") analyzeNoneHandler(noneHandlerOf(value.arguments[0] ?? null), search);
828
+ else if (origin === "Option/getOrElse") analyzeNoneHandler(value.arguments[0] ?? null, search);
829
+ else if (origin === "Effect/fromOption") checkOrDie(value, search);
830
+ else if (origin !== null && THROWING_CONSUMER_MODULES.has(origin)) record(value.callee, search);
831
+ continue;
832
+ }
833
+ const origin = moduleOf(value);
834
+ if (origin !== null && THROWING_CONSUMER_MODULES.has(origin)) record(value, search);
835
+ else if (origin === "Effect/fromOption") checkOrDie(value, search);
836
+ }
837
+ }
838
+ function analyzeNoneHandler(handler, search) {
839
+ if (handler === null) return;
840
+ const value = unwrapExpression(handler);
841
+ const origin = value.type === "CallExpression" ? moduleOf(value.callee) : moduleOf(value);
842
+ if (origin !== null && THROWING_CONSUMER_MODULES.has(origin)) {
843
+ record(value.type === "CallExpression" ? value.callee : value, search);
844
+ return;
845
+ }
846
+ recordWithin(value, search);
847
+ }
848
+ function analyzeFunctionParameter(fn, search) {
849
+ const parameter = fn.params[0];
850
+ if (parameter === void 0) {
851
+ recordWithin(fn.body, search);
852
+ return;
853
+ }
854
+ const identifier = parameter.type === "AssignmentPattern" ? parameter.left : parameter;
855
+ const variable = identifier.type === "Identifier" ? variableOfBinding(identifier, getScope) : null;
856
+ if (identifier.type !== "Identifier" || variable === null || referencesOfBinding(variable, identifier).length === 0) {
857
+ recordWithin(fn.body, search);
858
+ return;
859
+ }
860
+ const key = {
861
+ kind: "binding",
862
+ variable
863
+ };
864
+ for (const reference of referencesOfBinding(variable, identifier)) {
865
+ if (search.visited.has(reference)) continue;
866
+ visitOptionValue(reference, key, search);
867
+ }
868
+ }
869
+ function analyzeHandler(handler, search) {
870
+ if (handler === null) return;
871
+ const value = unwrapExpression(handler);
872
+ if (isFunctionNode$1(value)) {
873
+ analyzeFunctionParameter(value, search);
874
+ return;
875
+ }
876
+ if (value.type === "CallExpression") {
877
+ const origin = moduleOf(value.callee);
878
+ if (origin === "Option/match") {
879
+ analyzeNoneHandler(noneHandlerOf(value.arguments[0] ?? null), search);
880
+ return;
881
+ }
882
+ if (origin === "Option/getOrElse") {
883
+ analyzeNoneHandler(value.arguments[0] ?? null, search);
884
+ return;
885
+ }
886
+ if (origin !== null && THROWING_CONSUMER_MODULES.has(origin)) {
887
+ record(value.callee, search);
888
+ return;
889
+ }
890
+ if (origin === "Effect/fromOption") {
891
+ checkOrDie(value, search);
892
+ return;
893
+ }
894
+ if (origin === "Effect/fn" || moduleOf(fnCalleeOf(value)) === "Effect/fn") {
895
+ const generator = value.arguments[0];
896
+ if (generator !== void 0 && isFunctionNode$1(generator)) analyzeFunctionParameter(generator, search);
897
+ }
898
+ return;
899
+ }
900
+ const origin = moduleOf(value);
901
+ if (origin !== null && THROWING_CONSUMER_MODULES.has(origin)) {
902
+ record(value, search);
903
+ return;
904
+ }
905
+ if (origin === "Effect/fromOption") checkOrDie(value, search);
906
+ }
907
+ function visitOptionValue(start, key, search) {
908
+ if (search.visited.has(start)) return;
909
+ search.visited.add(start);
910
+ const node = wrapperOf(start);
911
+ const parent = node.parent ?? null;
912
+ if (parent === null) return;
913
+ if (parent.type === "VariableDeclarator" && parent.init === node && parent.id.type === "Identifier") {
914
+ const variable = variableOfBinding(parent.id, getScope);
915
+ if (variable === null) return;
916
+ const bound = {
917
+ kind: "binding",
918
+ variable
919
+ };
920
+ for (const reference of referencesOfBinding(variable, parent.id)) {
921
+ if (search.visited.has(reference)) continue;
922
+ visitOptionValue(reference, bound, search);
923
+ }
924
+ return;
925
+ }
926
+ if (parent.type === "MemberExpression" && parent.object === node && staticMemberNameOf$1(parent) === "pipe") {
927
+ const call = parent.parent ?? null;
928
+ if (call !== null && call.type === "CallExpression" && call.callee === parent) visitOptionPipeSteps(call.arguments, search);
929
+ return;
930
+ }
931
+ if (parent.type !== "CallExpression") return;
932
+ if (!parent.arguments.some((argument) => argument === node)) return;
933
+ if (parent.callee.type === "CallExpression") {
934
+ const origin = moduleOf(parent.callee.callee);
935
+ if (origin === "Option/match") analyzeNoneHandler(noneHandlerOf(parent.callee.arguments[0] ?? null), search);
936
+ else if (origin === "Option/getOrElse") analyzeNoneHandler(parent.callee.arguments[0] ?? null, search);
937
+ else if (origin === "Effect/fromOption") checkOrDie(parent, search);
938
+ else if (origin !== null && THROWING_CONSUMER_MODULES.has(origin)) record(parent.callee.callee, search);
939
+ return;
940
+ }
941
+ const origin = moduleOf(parent.callee);
942
+ if (origin === "Option/match") analyzeNoneHandler(noneHandlerOf(parent.arguments[1] ?? null), search);
943
+ else if (origin === "Option/getOrElse") analyzeNoneHandler(parent.arguments[1] ?? null, search);
944
+ else if (origin === "Effect/fromOption") checkOrDie(parent, search);
945
+ else if (origin !== null && THROWING_CONSUMER_MODULES.has(origin)) record(parent.callee, search);
946
+ else if (origin !== null && NARROWER_MODULES.has(origin)) visitNarrower(parent, key, search);
947
+ else if (origin !== null && PIPE_MODULES.has(origin) && parent.arguments[0] === node) visitOptionPipeSteps(parent.arguments.slice(1), search);
948
+ }
949
+ function visitEffectPipeSteps(steps, search) {
950
+ for (const step of steps) {
951
+ const value = unwrapExpression(step);
952
+ if (value.type !== "CallExpression") continue;
953
+ const origin = moduleOf(value.callee);
954
+ if (origin === null || !MAPPER_MODULES.has(origin)) continue;
955
+ const handler = value.arguments[0] ?? null;
956
+ analyzeHandler(handler, search);
957
+ const made = handler === null ? null : unwrapExpression(handler);
958
+ if (made === null || made.type !== "CallExpression" || moduleOf(made.callee) !== "Option/map") return;
959
+ }
960
+ }
961
+ function visitEffectValue(start, search) {
962
+ if (search.visited.has(start)) return;
963
+ search.visited.add(start);
964
+ const node = wrapperOf(start);
965
+ const parent = node.parent ?? null;
966
+ if (parent === null) return;
967
+ if (parent.type === "YieldExpression" && parent.argument === node) {
968
+ visitOptionValue(parent, {
969
+ kind: "node",
970
+ node: parent
971
+ }, search);
972
+ return;
973
+ }
974
+ if (parent.type === "VariableDeclarator" && parent.init === node && parent.id.type === "Identifier") {
975
+ const variable = variableOfBinding(parent.id, getScope);
976
+ if (variable === null) return;
977
+ for (const reference of referencesOfBinding(variable, parent.id)) {
978
+ if (search.visited.has(reference)) continue;
979
+ visitEffectValue(reference, search);
980
+ }
981
+ return;
982
+ }
983
+ if (parent.type === "MemberExpression" && parent.object === node && staticMemberNameOf$1(parent) === "pipe") {
984
+ const call = parent.parent ?? null;
985
+ if (call !== null && call.type === "CallExpression" && call.callee === parent) visitEffectPipeSteps(call.arguments, search);
986
+ return;
987
+ }
988
+ if (parent.type !== "CallExpression") return;
989
+ if (!parent.arguments.some((argument) => argument === node)) return;
990
+ if (parent.callee.type === "CallExpression") {
991
+ const origin = moduleOf(parent.callee.callee);
992
+ if (origin !== null && MAPPER_MODULES.has(origin)) analyzeHandler(parent.callee.arguments[0] ?? null, search);
993
+ return;
994
+ }
995
+ const origin = moduleOf(parent.callee);
996
+ if (origin !== null && MAPPER_MODULES.has(origin)) {
997
+ analyzeHandler(parent.arguments[1] ?? null, search);
998
+ return;
999
+ }
1000
+ if (origin !== null && PIPE_MODULES.has(origin)) {
1001
+ if (parent.arguments.findIndex((argument) => argument === node) === 0) visitEffectPipeSteps(parent.arguments.slice(1), search);
1002
+ }
1003
+ }
1004
+ function analyzeRead(read) {
1005
+ const search = {
1006
+ finding: null,
1007
+ visited: /* @__PURE__ */ new Set()
1008
+ };
1009
+ visitEffectValue(read, search);
1010
+ const finding = search.finding;
1011
+ if (finding === null) return;
1012
+ const tagNode = read.arguments[0];
1013
+ const tag = tagNode === void 0 ? textOf(read) : textOf(tagNode);
1014
+ const readParent = read.parent ?? null;
1015
+ const fix = readParent !== null && readParent.type === "YieldExpression" ? `yield* ${tag}` : tag;
1016
+ context.report({
1017
+ node: read,
1018
+ messageId: "defectOnNone",
1019
+ data: {
1020
+ tag,
1021
+ read: textOf(read),
1022
+ sink: finding.label,
1023
+ fix
1024
+ }
1025
+ });
1026
+ }
1027
+ return {
1028
+ CallExpression(node) {
1029
+ const origin = moduleOf(node.callee);
1030
+ if (origin === "Effect/serviceOption") {
1031
+ reads.push(node);
1032
+ return;
1033
+ }
1034
+ if (origin === null) return;
1035
+ if (origin === "Effect/die" || THROWING_CONSUMER_MODULES.has(origin)) {
1036
+ sinks.push({
1037
+ node,
1038
+ label: textOf(node.callee)
1039
+ });
1040
+ return;
1041
+ }
1042
+ if (origin === "Effect/failCause") {
1043
+ if (causeDieArgument(node, moduleOfCallee)) sinks.push({
1044
+ node,
1045
+ label: textOf(node.callee)
1046
+ });
1047
+ return;
1048
+ }
1049
+ if (NARROWER_MODULES.has(origin)) narrowers.push(node);
1050
+ },
1051
+ ThrowStatement(node) {
1052
+ sinks.push({
1053
+ node,
1054
+ label: "throw"
1055
+ });
1056
+ },
1057
+ "Program:exit"() {
1058
+ for (const read of reads) analyzeRead(read);
237
1059
  }
238
1060
  };
239
1061
  }
@@ -375,7 +1197,7 @@ const Options$3 = Schema.Struct({
375
1197
  expected: Schema.String.pipe(Schema.withDecodingDefaultType(Effect.succeed("HashMap from effect (HashMap.empty() or HashMap.fromIterable())"))),
376
1198
  fix: Schema.String.pipe(Schema.withDecodingDefaultType(Effect.succeed("Replace with HashMap.empty() for empty maps, or HashMap.fromIterable(iterable) for maps with initial data")))
377
1199
  });
378
- const meta$4 = {
1200
+ const meta$5 = {
379
1201
  type: "problem",
380
1202
  docs: { description: "When Effect is imported, ban native Map (new Map). Use HashMap from effect instead." },
381
1203
  schema: [Schema.toJsonSchemaDocument(Options$3).schema],
@@ -395,7 +1217,7 @@ const isMapCallee = (callee) => {
395
1217
  return false;
396
1218
  };
397
1219
  const noNativeMapInEffect = defineRule({
398
- meta: meta$4,
1220
+ meta: meta$5,
399
1221
  create(context) {
400
1222
  const options = Schema.decodeUnknownSync(Options$3)(context.options[0] ?? {});
401
1223
  const allow = new Set(options.allow);
@@ -429,7 +1251,7 @@ const Options$2 = Schema.Struct({
429
1251
  expected: Schema.String.pipe(Schema.withDecodingDefaultType(Effect.succeed("HashSet from effect (HashSet.empty() or HashSet.fromIterable())"))),
430
1252
  fix: Schema.String.pipe(Schema.withDecodingDefaultType(Effect.succeed("Replace with HashSet.empty() for empty sets, or HashSet.fromIterable(iterable) for sets with initial data")))
431
1253
  });
432
- const meta$3 = {
1254
+ const meta$4 = {
433
1255
  type: "problem",
434
1256
  docs: { description: "When Effect is imported, ban native Set (new Set). Use HashSet from effect instead." },
435
1257
  schema: [Schema.toJsonSchemaDocument(Options$2).schema],
@@ -445,7 +1267,7 @@ const isInsideEffectGen = (node) => {
445
1267
  return isInsideEffectGen(parent);
446
1268
  };
447
1269
  const noNativeSetInEffect = defineRule({
448
- meta: meta$3,
1270
+ meta: meta$4,
449
1271
  create(context) {
450
1272
  const options = Schema.decodeUnknownSync(Options$2)(context.options[0] ?? {});
451
1273
  const allow = new Set(options.allow);
@@ -479,7 +1301,7 @@ const Options$1 = Schema.Struct({
479
1301
  expected: Schema.String.pipe(Schema.withDecodingDefaultType(Effect.succeed("Bun.spawn subprocess pool"))),
480
1302
  fix: Schema.String.pipe(Schema.withDecodingDefaultType(Effect.succeed("Run each worker in its own OS process (not in a thread of the parent) so each one has its own WASM heap and concurrent init cannot race. A subprocess-per-worker pool with a per-child crash handler (re-dispatch the in-flight work and spawn a replacement) is the standard shape.")))
481
1303
  });
482
- const meta$2 = {
1304
+ const meta$3 = {
483
1305
  type: "problem",
484
1306
  docs: { description: "When a file imports a WASM module (e.g. `*-wasm`), ban new Worker(filePath). Use Bun.spawn for process isolation — WASM global state races on concurrent init across threads of the same OS process and segfaults bun." },
485
1307
  schema: [Schema.toJsonSchemaDocument(Options$1).schema],
@@ -493,7 +1315,7 @@ const isNewWorkerCall = (node) => {
493
1315
  return true;
494
1316
  };
495
1317
  const noNewWorkerWithWasmImport = defineRule({
496
- meta: meta$2,
1318
+ meta: meta$3,
497
1319
  create(context) {
498
1320
  const options = Schema.decodeUnknownSync(Options$1)(context.options[0] ?? {});
499
1321
  const patterns = options.wasmImportPatterns.map((src) => new RegExp(src));
@@ -559,7 +1381,7 @@ const isRegisteredPort = (filename, ports) => {
559
1381
  return candidate === normalized || candidate.endsWith(`/${normalized}`);
560
1382
  });
561
1383
  };
562
- const meta$1 = {
1384
+ const meta$2 = {
563
1385
  type: "problem",
564
1386
  docs: { description: "Production source takes timers, clocks, randomness, and task scheduling only through a named, replaceable port: a direct Date.now, argument-less new Date(), performance.now, process.hrtime, Math.random, crypto.getRandomValues, crypto.randomUUID, setTimeout, setInterval, or setImmediate call, or an import of node:timers, fails at that call unless the file is listed in the rule's `ports` option. queueMicrotask reads no clock and is not flagged. A source injected as a parameter is a port crossing the boundary, not a direct read. Test and fixture files are outside the rule." },
565
1387
  schema: [Schema.toJsonSchemaDocument(Options).schema],
@@ -579,11 +1401,11 @@ const rootIdentifierOf = (node) => {
579
1401
  while (current.type === "MemberExpression") current = current.object;
580
1402
  return isIdentifierNode(current) ? current : null;
581
1403
  };
582
- const memberPathOf = (node) => {
1404
+ const memberPathOf$1 = (node) => {
583
1405
  if (isIdentifierNode(node)) return [node.name];
584
1406
  if (node.type !== "MemberExpression" || node.computed === true) return null;
585
1407
  if (!isIdentifierNode(node.property)) return null;
586
- const object = memberPathOf(node.object);
1408
+ const object = memberPathOf$1(node.object);
587
1409
  return object === null ? null : [...object, node.property.name];
588
1410
  };
589
1411
  const timeSourceApiOf = (path) => TIME_SOURCE_APIS.find((api) => {
@@ -605,7 +1427,7 @@ const isGlobalReference = (identifier, getScope) => {
605
1427
  return true;
606
1428
  };
607
1429
  const noUnportedTimeSource = defineRule({
608
- meta: meta$1,
1430
+ meta: meta$2,
609
1431
  create(context) {
610
1432
  if (isTestOrFixtureFile(context.filename)) return {};
611
1433
  const options = decodeOptions(context.options[0] ?? {});
@@ -652,7 +1474,7 @@ const noUnportedTimeSource = defineRule({
652
1474
  if (GLOBAL_CALL_APIS.includes(callee.name) && isGlobalReference(callee, getScope)) report(globalCallVerdict(callee.name), node);
653
1475
  return;
654
1476
  }
655
- const path = memberPathOf(callee);
1477
+ const path = memberPathOf$1(callee);
656
1478
  if (path !== null) reportGlobalCall(node, path);
657
1479
  },
658
1480
  NewExpression(node) {
@@ -665,200 +1487,265 @@ const noUnportedTimeSource = defineRule({
665
1487
  };
666
1488
  }
667
1489
  });
668
- // ../import-origin/dist/index.mjs
669
- const isScopeLike = (value) => typeof value === "object" && value !== null && "references" in value && "upper" in value;
670
- const isIdentifier = (node) => node.type === "Identifier";
671
- const isMemberExpression = (node) => node.type === "MemberExpression";
672
- const isVariableDeclarator = (node) => node.type === "VariableDeclarator";
673
- /**
674
- * The variable a reference identifier resolves to: the reference's own
675
- * `resolved` binding, found by identity in the scope tree. Name-based scope
676
- * lookups merge same-scope re-declarations (an import plus a shadowing const
677
- * collapse into one variable), so only the reference knows the shadow.
678
- */
679
- const variableOfIdentifier = (identifier, getScope) => {
680
- const scopeValue = getScope(identifier);
681
- let scope = isScopeLike(scopeValue) ? scopeValue : null;
682
- while (scope !== null) {
683
- const found = scope.references.find((reference) => reference.identifier === identifier);
684
- if (found !== void 0 && found.resolved !== null) return { defs: found.resolved.defs };
685
- if (found !== void 0) return null;
686
- scope = scope.upper;
1490
+ // src/rules/node-runtime-needs-engines.config.ts
1491
+ const NODE_GLOBAL_NAMES = /* @__PURE__ */ new Set([
1492
+ "__dirname",
1493
+ "__filename",
1494
+ "Buffer",
1495
+ "clearImmediate",
1496
+ "exports",
1497
+ "global",
1498
+ "module",
1499
+ "process",
1500
+ "require",
1501
+ "setImmediate"
1502
+ ]);
1503
+ const GLOBAL_OBJECT_NAMES = /* @__PURE__ */ new Set(["global", "globalThis"]);
1504
+ const GLOBAL_READ_CALLEES = /* @__PURE__ */ new Set([
1505
+ "Object.getOwnPropertyDescriptor",
1506
+ "Reflect.get",
1507
+ "Reflect.getOwnPropertyDescriptor"
1508
+ ]);
1509
+ const IMPORT_META_NODE_MEMBERS = /* @__PURE__ */ new Set([
1510
+ "dirname",
1511
+ "filename",
1512
+ "resolve"
1513
+ ]);
1514
+ const NODE_BUILTIN_PREFIX = /^node:/u;
1515
+ const BARE_NODE_BUILTIN = /^(?:assert|async_hooks|buffer|child_process|cluster|console|constants|crypto|dgram|diagnostics_channel|dns|domain|events|fs|http|http2|https|inspector|module|net|os|path|perf_hooks|process|punycode|querystring|readline|repl|stream|string_decoder|sys|timers|tls|trace_events|tty|url|util|v8|vm|wasi|worker_threads|zlib)(?:\/.*)?$/u;
1516
+ const TEST_FILE_PATH = /(^|\/)(?:__tests__|tests)\/|\.(?:test|spec)\.[cm]?[jt]sx?$/u;
1517
+ const isTestFilePath = (filename) => TEST_FILE_PATH.test(filename.replaceAll("\\", "/"));
1518
+ const ENGINES_CLAUSE = /^(?:\^|>=)(\d+)\.(\d+)\.(\d+)$/u;
1519
+ const parseEnginesRange = (value) => {
1520
+ const clauses = [];
1521
+ for (const text of value.split("||")) {
1522
+ const trimmed = text.trim();
1523
+ const match = ENGINES_CLAUSE.exec(trimmed);
1524
+ if (match === null) return null;
1525
+ clauses.push({
1526
+ atLeast: trimmed.startsWith(">="),
1527
+ major: Number(match[1]),
1528
+ minor: Number(match[2]),
1529
+ patch: Number(match[3])
1530
+ });
687
1531
  }
688
- return null;
1532
+ return clauses.length === 0 ? null : clauses;
689
1533
  };
690
- /** The member names that forward, rather than extend, an origin. */
691
- const FORWARDING_MEMBERS = {
692
- bind: true,
693
- call: true,
694
- apply: true
1534
+ const SUGGESTED_RANGE = "^22.22.2 || ^24.15.0 || >=26.0.0";
1535
+ const meta$1 = {
1536
+ type: "problem",
1537
+ docs: { description: "A package that reaches the Node runtime through a builtin module, a Node global, a static global-object key, or import.meta must declare engines.node in its nearest package.json, because its tests run on every non-EOL Node line that range admits. Test files and fixtures of a package that ships are outside the rule; a private package ships nothing, so its tests are its code." },
1538
+ schema: [],
1539
+ messages: {
1540
+ nodeRuntimeNeedsEngines: "{{api}} in a package with no engines.node is forbidden. Expected: {{manifest}} declares the Node lines it supports. Actual: {{api}} reaches the Node runtime and {{manifest}} declares no engines.node. Fix: add \"engines\": { \"node\": \"{{range}}\" } to {{manifest}}.",
1541
+ malformedEngines: "A malformed engines.node is forbidden. Expected: ^M.m.p or >=M.m.p clauses joined by ||. Actual: {{manifest}} declares \"{{value}}\". Fix: write it in that form, for example \"{{range}}\"."
1542
+ }
695
1543
  };
696
- /** TS wrappers that carry an expression without changing what it denotes. */
697
- const TS_EXPRESSION_WRAPPERS = {
698
- TSAsExpression: true,
699
- TSSatisfiesExpression: true,
700
- TSNonNullExpression: true,
701
- TSTypeAssertion: true,
702
- TSInstantiationExpression: true
1544
+ // src/rules/node-runtime-needs-engines.ts
1545
+ const ManifestJson = Schema.Struct({
1546
+ engines: Schema.optional(Schema.Struct({ node: Schema.optional(Schema.String) })),
1547
+ private: Schema.optional(Schema.Boolean)
1548
+ });
1549
+ const isScopeLike = (value) => typeof value === "object" && value !== null && "references" in value && "upper" in value;
1550
+ const isIdentifier = (node) => node.type === "Identifier";
1551
+ const isGlobalObjectName = (node) => {
1552
+ if (!isIdentifier(node)) return null;
1553
+ return GLOBAL_OBJECT_NAMES.has(node.name) ? node.name : null;
703
1554
  };
704
- const isExpressionWrapper = (node) => TS_EXPRESSION_WRAPPERS[node.type] === true;
705
- const unwrapExpression = (node) => {
706
- let current = node;
707
- while (isExpressionWrapper(current)) current = current.expression;
708
- return current;
1555
+ const scopeOf = (node, getScope) => {
1556
+ const value = getScope(node);
1557
+ return isScopeLike(value) ? value : null;
709
1558
  };
710
- /**
711
- * The statically known string value of an expression that evaluates to a
712
- * string: a string literal, a template with no substitutions, a `+`
713
- * concatenation of two such, or `Symbol.for('name')`. Anything not foldable
714
- * from syntax alone is `null` — never a guessed name. The `Symbol.for` fold is
715
- * the well-known-symbol member addressing: `S[Symbol.for('Struct')]` names the
716
- * same member as `S.Struct`. A shadowed `Symbol` binding would break the fold —
717
- * the same permissiveness the resolver already extends to local aliases.
718
- */
719
- const staticStringValue = (node, depth = 0) => {
720
- if (node === null || depth > 64) return null;
721
- if (node.type === "Literal" && typeof node.value === "string") return node.value;
722
- if (node.type === "TemplateLiteral" && node.expressions.length === 0) return node.quasis[0]?.value.cooked ?? null;
723
- if (node.type === "BinaryExpression" && node.operator === "+") {
724
- const left = staticStringValue(node.left, depth + 1);
725
- if (left === null) return null;
726
- const right = staticStringValue(node.right, depth + 1);
727
- return right === null ? null : left + right;
728
- }
729
- if (node.type === "CallExpression" && node.arguments.length === 1) {
730
- const argument = node.arguments[0];
731
- if (argument !== void 0 && argument.type === "Literal" && typeof argument.value === "string" && node.callee.type === "MemberExpression" && !node.callee.computed && node.callee.object.type === "Identifier" && node.callee.object.name === "Symbol" && node.callee.property.type === "Identifier" && node.callee.property.name === "for") return argument.value;
1559
+ const findReference = (identifier, getScope) => {
1560
+ for (let scope = scopeOf(identifier, getScope); scope !== null; scope = scope.upper) {
1561
+ const found = scope.references.find((reference) => reference.identifier === identifier);
1562
+ if (found !== void 0) return found;
732
1563
  }
733
1564
  return null;
734
1565
  };
1566
+ const hasNoDeclaration = (variable) => typeof variable === "object" && variable !== null && "defs" in variable && Array.isArray(variable.defs) && variable.defs.length === 0;
735
1567
  /**
736
- * The declared member name of a member expression: an identifier property in a
737
- * non-computed position, or a computed property whose key folds to a static
738
- * string (`S['Union']`, `S['Stru' + 'ct']`, `S[Symbol.for('Struct')]`).
739
- * Everything else — a variable subscript `S[key]` — is `null`: the member is
740
- * not statically known. Never fall back to the subscript variable's name; that
741
- * would read `S[decoder]` as the member `decoder` and misclassify a codec use
742
- * as a schema construction.
1568
+ * A reference names a global when the scope chain leaves it unresolved, or resolves it to a variable
1569
+ * no code declares: a built-in such as `globalThis` or a global the lint configuration adds. A
1570
+ * declared one is a local binding, a parameter, or an import; an identifier the scopes do not
1571
+ * record at all is a property name or a declaration, not a read.
743
1572
  */
744
- const memberNameOf = (node) => {
745
- const property = node.property;
746
- if (!node.computed && property.type === "Identifier") return property.name;
747
- return staticStringValue(property);
1573
+ const isUnresolvedGlobal = (node, getScope) => {
1574
+ if (!isIdentifier(node)) return false;
1575
+ const reference = findReference(node, getScope);
1576
+ return reference !== null && (reference.resolved === null || hasNoDeclaration(reference.resolved));
748
1577
  };
749
- /**
750
- * The alias-chain ladder guard. 64 levels of alias/member indirection is
751
- * beyond any real chain; a chain that exhausts it resolves to `null` — the
752
- * "undetermined" value, not "definitely not an import". Callers that must
753
- * fail closed treat that exhausted-`null` the same as any other unresolved
754
- * module-local chain (schema-declaration-location reports it), so a deep
755
- * ladder can no longer park a schema silently. Tune the cap, never the
756
- * semantics: a depth overflow is a report, not a pass.
757
- */
758
- const MAX_DEPTH = 64;
759
- /**
760
- * What this expression ultimately denotes: `{ source, importedName, path }`
761
- * for an identifier or member chain that reaches an import binding, `null`
762
- * for everything the resolver cannot prove — my "undetermined", not "this is
763
- * not an import".
764
- */
765
- const resolveImportOrigin = (node, getScope, depth = 0) => {
766
- if (depth > MAX_DEPTH) return null;
767
- node = unwrapExpression(node);
768
- if (isIdentifier(node)) return resolveIdentifierOrigin(node, getScope, depth);
769
- if (node.type === "SequenceExpression") {
770
- const last = node.expressions[node.expressions.length - 1];
771
- return last === void 0 ? null : resolveImportOrigin(last, getScope, depth + 1);
1578
+ const staticKeyOf = (node) => {
1579
+ if (node.type === "Literal") return typeof node.value === "string" ? node.value : null;
1580
+ if (node.type !== "TemplateLiteral" || node.expressions.length > 0) return null;
1581
+ const first = node.quasis[0];
1582
+ if (first === void 0) return null;
1583
+ const cooked = first.value.cooked;
1584
+ return typeof cooked === "string" ? cooked : null;
1585
+ };
1586
+ const memberKeyOf = (member) => {
1587
+ if (member.computed) return staticKeyOf(member.property);
1588
+ return isIdentifier(member.property) ? member.property.name : null;
1589
+ };
1590
+ const memberPathOf = (node) => {
1591
+ if (isIdentifier(node)) return [node.name];
1592
+ if (node.type !== "MemberExpression" || node.computed) return null;
1593
+ if (!isIdentifier(node.property)) return null;
1594
+ const object = memberPathOf(node.object);
1595
+ return object === null ? null : [...object, node.property.name];
1596
+ };
1597
+ const isImportMeta = (node) => node.type === "MetaProperty" && isIdentifier(node.meta) && node.meta.name === "import" && isIdentifier(node.property) && node.property.name === "meta";
1598
+ const isNodeBuiltinSpecifier = (specifier) => NODE_BUILTIN_PREFIX.test(specifier) || BARE_NODE_BUILTIN.test(specifier);
1599
+ const decodeManifest = (text) => {
1600
+ const decoded = Effect.runSync(Effect.orDie(Schema.decodeUnknownEffect(ManifestJson)(JSON.parse(text))));
1601
+ const enginesNode = decoded.engines?.node;
1602
+ return {
1603
+ private: decoded.private === true,
1604
+ enginesNode: enginesNode === void 0 || enginesNode.trim() === "" ? null : enginesNode
1605
+ };
1606
+ };
1607
+ const readManifestFile = (manifestPath) => {
1608
+ let text;
1609
+ try {
1610
+ text = readFileSync(manifestPath, "utf8");
1611
+ } catch {
1612
+ return "absent";
772
1613
  }
773
- if (isMemberExpression(node)) {
774
- const object = resolveImportOrigin(node.object, getScope, depth + 1);
775
- if (object === null) return null;
776
- const member = memberNameOf(node);
777
- if (member === null || FORWARDING_MEMBERS[member] === true) return object;
778
- return object.importedName === null ? {
779
- ...object,
780
- importedName: member
781
- } : {
782
- ...object,
783
- path: [...object.path, member]
1614
+ try {
1615
+ const fields = decodeManifest(text);
1616
+ return {
1617
+ path: manifestPath,
1618
+ directory: dirname(manifestPath),
1619
+ private: fields.private,
1620
+ enginesNode: fields.enginesNode
1621
+ };
1622
+ } catch {
1623
+ return {
1624
+ path: manifestPath,
1625
+ directory: dirname(manifestPath),
1626
+ private: false,
1627
+ enginesNode: null
784
1628
  };
785
1629
  }
786
- if (node.type === "CallExpression" && isMemberExpression(node.callee)) {
787
- const member = memberNameOf(node.callee);
788
- if (member !== null && FORWARDING_MEMBERS[member] === true) return resolveImportOrigin(node.callee.object, getScope, depth + 1);
789
- }
790
- return null;
791
1630
  };
792
- const resolveIdentifierOrigin = (identifier, getScope, depth) => {
793
- const variable = variableOfIdentifier(identifier, getScope);
794
- if (variable === null) return null;
795
- const def = variable.defs[variable.defs.length - 1];
796
- if (def === void 0) return null;
797
- if (def.type === "ImportBinding") {
798
- const declaration = def.parent;
799
- if (declaration === null || declaration.type !== "ImportDeclaration") return null;
800
- const source = declaration.source.value;
801
- if (typeof source !== "string") return null;
802
- const specifier = def.node;
803
- if (specifier.type === "ImportSpecifier") {
804
- const imported = specifier.imported;
805
- if (imported.type === "Identifier") return {
806
- source,
807
- importedName: imported.name,
808
- path: []
809
- };
810
- return imported.type === "Literal" && typeof imported.value === "string" ? {
811
- source,
812
- importedName: imported.value,
813
- path: []
814
- } : null;
1631
+ const manifests = /* @__PURE__ */ new Map();
1632
+ const manifestOf = (filename) => {
1633
+ let directory = dirname(resolve(filename));
1634
+ for (;;) {
1635
+ const cached = manifests.get(directory);
1636
+ if (cached !== void 0) return cached;
1637
+ const found = readManifestFile(join(directory, "package.json"));
1638
+ if (found !== "absent") {
1639
+ manifests.set(directory, found);
1640
+ return found;
815
1641
  }
816
- if (specifier.type === "ImportDefaultSpecifier") return {
817
- source,
818
- importedName: "default",
819
- path: []
1642
+ const parent = dirname(directory);
1643
+ if (parent === directory) return null;
1644
+ directory = parent;
1645
+ }
1646
+ };
1647
+ const nodeRuntimeNeedsEngines = defineRule({
1648
+ meta: meta$1,
1649
+ create(context) {
1650
+ const manifest = manifestOf(context.filename);
1651
+ if (manifest === null) return {};
1652
+ if (!manifest.private && isTestFilePath(relative(manifest.directory, resolve(context.filename)))) return {};
1653
+ if (manifest.enginesNode !== null && parseEnginesRange(manifest.enginesNode) !== null) return {};
1654
+ const shownManifest = relative(context.cwd, manifest.path).replaceAll("\\", "/");
1655
+ const report = (node, api) => {
1656
+ if (manifest.enginesNode !== null) {
1657
+ context.report({
1658
+ node,
1659
+ messageId: "malformedEngines",
1660
+ data: {
1661
+ manifest: shownManifest,
1662
+ value: manifest.enginesNode,
1663
+ range: SUGGESTED_RANGE
1664
+ }
1665
+ });
1666
+ return;
1667
+ }
1668
+ context.report({
1669
+ node,
1670
+ messageId: "nodeRuntimeNeedsEngines",
1671
+ data: {
1672
+ api,
1673
+ manifest: shownManifest,
1674
+ range: SUGGESTED_RANGE
1675
+ }
1676
+ });
820
1677
  };
821
- return {
822
- source,
823
- importedName: null,
824
- path: []
1678
+ const getScope = context.sourceCode.getScope;
1679
+ const reportSpecifier = (node, specifier) => {
1680
+ if (isNodeBuiltinSpecifier(specifier)) report(node, specifier);
825
1681
  };
826
- }
827
- if (def.type !== "Variable") return null;
828
- const declarator = isVariableDeclarator(def.node) ? def.node : def.parent !== null && isVariableDeclarator(def.parent) ? def.parent : null;
829
- if (declarator === null) return null;
830
- const declaration = declarator.parent;
831
- if (declaration === null || declaration.type !== "VariableDeclaration") return null;
832
- const init = declarator.init;
833
- if (init === null) return null;
834
- const base = resolveImportOrigin(init, getScope, depth + 1);
835
- if (base === null) return null;
836
- if (declarator.id.type === "ObjectPattern") {
837
- const bound = def.name;
838
- if (bound === null) return null;
839
- for (const property of declarator.id.properties) {
840
- if (property.type !== "Property") continue;
841
- const key = property.key;
842
- const keyName = !property.computed && key.type === "Identifier" ? key.name : staticStringValue(key);
843
- if (keyName === null) continue;
844
- let binding = property.value;
845
- if (binding.type === "AssignmentPattern") {
846
- if (binding.left.type !== "Identifier") continue;
847
- binding = binding.left;
1682
+ const reportMember = (node, key) => {
1683
+ const globalObject = isGlobalObjectName(node.object);
1684
+ if (globalObject === "global") {
1685
+ if (isUnresolvedGlobal(node.object, getScope)) report(node, `global.${key}`);
1686
+ return;
848
1687
  }
849
- if (binding !== bound) continue;
850
- return base.importedName === null ? {
851
- ...base,
852
- importedName: keyName
853
- } : {
854
- ...base,
855
- path: [...base.path, keyName]
856
- };
857
- }
858
- return null;
1688
+ if (globalObject === "globalThis" && isUnresolvedGlobal(node.object, getScope) && NODE_GLOBAL_NAMES.has(key)) report(node, `globalThis.${key}`);
1689
+ };
1690
+ return {
1691
+ Identifier(node) {
1692
+ if (!NODE_GLOBAL_NAMES.has(node.name)) return;
1693
+ if (node.name === "global" && node.parent !== null && node.parent.type === "MemberExpression" && node.parent.object === node) return;
1694
+ if (isUnresolvedGlobal(node, getScope)) report(node, node.name);
1695
+ },
1696
+ MemberExpression(node) {
1697
+ const key = memberKeyOf(node);
1698
+ if (key === null) {
1699
+ if (isGlobalObjectName(node.object) === "global" && isUnresolvedGlobal(node.object, getScope)) report(node, "global[…]");
1700
+ return;
1701
+ }
1702
+ if (isImportMeta(node.object)) {
1703
+ if (IMPORT_META_NODE_MEMBERS.has(key)) report(node, `import.meta.${key}`);
1704
+ return;
1705
+ }
1706
+ reportMember(node, key);
1707
+ },
1708
+ CallExpression(node) {
1709
+ const calleePath = memberPathOf(node.callee);
1710
+ if (calleePath === null) return;
1711
+ const callee = calleePath.join(".");
1712
+ if (!GLOBAL_READ_CALLEES.has(callee)) return;
1713
+ const [globalObject, keyNode] = node.arguments;
1714
+ if (globalObject === void 0 || keyNode === void 0) return;
1715
+ if (globalObject.type === "SpreadElement" || keyNode.type === "SpreadElement") return;
1716
+ if (isGlobalObjectName(globalObject) === null) return;
1717
+ if (!isUnresolvedGlobal(globalObject, getScope)) return;
1718
+ const key = staticKeyOf(keyNode);
1719
+ if (key === null || !NODE_GLOBAL_NAMES.has(key)) return;
1720
+ report(node, `${callee}(globalThis, '${key}')`);
1721
+ },
1722
+ VariableDeclarator(node) {
1723
+ if (node.id.type !== "ObjectPattern") return;
1724
+ const init = node.init;
1725
+ if (init === null || isGlobalObjectName(init) === null) return;
1726
+ if (!isUnresolvedGlobal(init, getScope)) return;
1727
+ for (const property of node.id.properties) {
1728
+ if (property.type !== "Property") continue;
1729
+ const key = property.computed ? staticKeyOf(property.key) : isIdentifier(property.key) ? property.key.name : null;
1730
+ if (key === null || !NODE_GLOBAL_NAMES.has(key)) continue;
1731
+ report(property, `globalThis.${key}`);
1732
+ }
1733
+ },
1734
+ ImportDeclaration(node) {
1735
+ if (node.source.type === "Literal" && typeof node.source.value === "string") reportSpecifier(node, node.source.value);
1736
+ },
1737
+ ExportNamedDeclaration(node) {
1738
+ if (node.source?.type === "Literal" && typeof node.source.value === "string") reportSpecifier(node, node.source.value);
1739
+ },
1740
+ ExportAllDeclaration(node) {
1741
+ if (node.source.type === "Literal" && typeof node.source.value === "string") reportSpecifier(node, node.source.value);
1742
+ },
1743
+ ImportExpression(node) {
1744
+ if (node.source.type === "Literal" && typeof node.source.value === "string") reportSpecifier(node, node.source.value);
1745
+ }
1746
+ };
859
1747
  }
860
- return base;
861
- };
1748
+ });
862
1749
  // src/rules/runtime-construction-placement.config.ts
863
1750
  const isRuntimeCodeFile = (filename) => /(?:^|[\\/])src[\\/]/u.test(filename) || filename.endsWith(".test.ts");
864
1751
  const isInterpretationEdge = (filename) => /(?:^|[\\/])main\.ts$/u.test(filename);
@@ -1104,6 +1991,7 @@ const recommendedRules = {
1104
1991
  [rule("entrypoint-not-imported")]: "error",
1105
1992
  [rule("entrypoint-no-promise-wrapper")]: "error",
1106
1993
  [rule("runtime-construction-placement")]: "error",
1994
+ [rule("no-die-on-service-option")]: "error",
1107
1995
  [rule("no-logging-in-catch")]: "error",
1108
1996
  [rule("no-native-map-in-effect")]: "error",
1109
1997
  [rule("no-native-set-in-effect")]: "error",
@@ -1132,10 +2020,12 @@ var src_default = {
1132
2020
  "entrypoint-not-imported": entrypointNotImported,
1133
2021
  "entrypoint-no-promise-wrapper": entrypointNoPromiseWrapper,
1134
2022
  "runtime-construction-placement": runtimeConstructionPlacement,
2023
+ "no-die-on-service-option": noDieOnServiceOption,
1135
2024
  "no-logging-in-catch": noLoggingInCatch,
1136
2025
  "no-native-map-in-effect": noNativeMapInEffect,
1137
2026
  "no-native-set-in-effect": noNativeSetInEffect,
1138
2027
  "no-new-worker-with-wasm-import": noNewWorkerWithWasmImport,
2028
+ "node-runtime-needs-engines": nodeRuntimeNeedsEngines,
1139
2029
  "no-unported-time-source": noUnportedTimeSource
1140
2030
  },
1141
2031
  configs: { recommended: {