@effect/language-service 0.54.0 → 0.55.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effect/language-service",
3
- "version": "0.54.0",
3
+ "version": "0.55.0",
4
4
  "description": "A Language-Service Plugin to Refactor and Diagnostic effect-ts projects",
5
5
  "main": "index.cjs",
6
6
  "bin": {
package/transform.js CHANGED
@@ -24,7 +24,7 @@ __export(transform_exports, {
24
24
  });
25
25
  module.exports = __toCommonJS(transform_exports);
26
26
 
27
- // node_modules/.pnpm/@pkg.pr.new+Effect-TS+effect@97ff1dc_6ntygjheib5kdugabxjhox4fte/node_modules/effect/dist/esm/Function.js
27
+ // node_modules/.pnpm/effect@3.19.0/node_modules/effect/dist/esm/Function.js
28
28
  var isFunction = (input) => typeof input === "function";
29
29
  var dual = function(arity, body) {
30
30
  if (typeof arity === "function") {
@@ -118,7 +118,7 @@ function pipe(a, ab, bc, cd, de, ef, fg, gh, hi) {
118
118
  }
119
119
  }
120
120
 
121
- // node_modules/.pnpm/@pkg.pr.new+Effect-TS+effect@97ff1dc_6ntygjheib5kdugabxjhox4fte/node_modules/effect/dist/esm/GlobalValue.js
121
+ // node_modules/.pnpm/effect@3.19.0/node_modules/effect/dist/esm/GlobalValue.js
122
122
  var globalStoreId = `effect/GlobalValue`;
123
123
  var globalStore;
124
124
  var globalValue = (id, compute) => {
@@ -132,7 +132,7 @@ var globalValue = (id, compute) => {
132
132
  return globalStore.get(id);
133
133
  };
134
134
 
135
- // node_modules/.pnpm/@pkg.pr.new+Effect-TS+effect@97ff1dc_6ntygjheib5kdugabxjhox4fte/node_modules/effect/dist/esm/Predicate.js
135
+ // node_modules/.pnpm/effect@3.19.0/node_modules/effect/dist/esm/Predicate.js
136
136
  var isString = (input) => typeof input === "string";
137
137
  var isNumber = (input) => typeof input === "number";
138
138
  var isBoolean = (input) => typeof input === "boolean";
@@ -142,7 +142,7 @@ var isObject = (input) => isRecordOrArray(input) || isFunction2(input);
142
142
  var hasProperty = /* @__PURE__ */ dual(2, (self, property) => isObject(self) && property in self);
143
143
  var isRecord = (input) => isRecordOrArray(input) && !Array.isArray(input);
144
144
 
145
- // node_modules/.pnpm/@pkg.pr.new+Effect-TS+effect@97ff1dc_6ntygjheib5kdugabxjhox4fte/node_modules/effect/dist/esm/Utils.js
145
+ // node_modules/.pnpm/effect@3.19.0/node_modules/effect/dist/esm/Utils.js
146
146
  var GenKindTypeId = /* @__PURE__ */ Symbol.for("effect/Gen/GenKind");
147
147
  var GenKindImpl = class {
148
148
  value;
@@ -264,7 +264,7 @@ var internalCall = isNotOptimizedAway ? standard.effect_internal_function : forc
264
264
  var genConstructor = function* () {
265
265
  }.constructor;
266
266
 
267
- // node_modules/.pnpm/@pkg.pr.new+Effect-TS+effect@97ff1dc_6ntygjheib5kdugabxjhox4fte/node_modules/effect/dist/esm/Hash.js
267
+ // node_modules/.pnpm/effect@3.19.0/node_modules/effect/dist/esm/Hash.js
268
268
  var randomHashCache = /* @__PURE__ */ globalValue(/* @__PURE__ */ Symbol.for("effect/Hash/randomHashCache"), () => /* @__PURE__ */ new WeakMap());
269
269
  var symbol = /* @__PURE__ */ Symbol.for("effect/Hash");
270
270
  var hash = (self) => {
@@ -363,7 +363,7 @@ var cached = function() {
363
363
  return hash2;
364
364
  };
365
365
 
366
- // node_modules/.pnpm/@pkg.pr.new+Effect-TS+effect@97ff1dc_6ntygjheib5kdugabxjhox4fte/node_modules/effect/dist/esm/Equal.js
366
+ // node_modules/.pnpm/effect@3.19.0/node_modules/effect/dist/esm/Equal.js
367
367
  var symbol2 = /* @__PURE__ */ Symbol.for("effect/Equal");
368
368
  function equals() {
369
369
  if (arguments.length === 1) {
@@ -417,7 +417,7 @@ function compareBoth(self, that) {
417
417
  var isEqual = (u) => hasProperty(u, symbol2);
418
418
  var equivalence = () => equals;
419
419
 
420
- // node_modules/.pnpm/@pkg.pr.new+Effect-TS+effect@97ff1dc_6ntygjheib5kdugabxjhox4fte/node_modules/effect/dist/esm/Inspectable.js
420
+ // node_modules/.pnpm/effect@3.19.0/node_modules/effect/dist/esm/Inspectable.js
421
421
  var NodeInspectSymbol = /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom");
422
422
  var toJSON = (x) => {
423
423
  try {
@@ -469,7 +469,7 @@ var redact = (u) => {
469
469
  return u;
470
470
  };
471
471
 
472
- // node_modules/.pnpm/@pkg.pr.new+Effect-TS+effect@97ff1dc_6ntygjheib5kdugabxjhox4fte/node_modules/effect/dist/esm/Pipeable.js
472
+ // node_modules/.pnpm/effect@3.19.0/node_modules/effect/dist/esm/Pipeable.js
473
473
  var pipeArguments = (self, args2) => {
474
474
  switch (args2.length) {
475
475
  case 0:
@@ -502,14 +502,14 @@ var pipeArguments = (self, args2) => {
502
502
  }
503
503
  };
504
504
 
505
- // node_modules/.pnpm/@pkg.pr.new+Effect-TS+effect@97ff1dc_6ntygjheib5kdugabxjhox4fte/node_modules/effect/dist/esm/internal/opCodes/effect.js
505
+ // node_modules/.pnpm/effect@3.19.0/node_modules/effect/dist/esm/internal/opCodes/effect.js
506
506
  var OP_COMMIT = "Commit";
507
507
 
508
- // node_modules/.pnpm/@pkg.pr.new+Effect-TS+effect@97ff1dc_6ntygjheib5kdugabxjhox4fte/node_modules/effect/dist/esm/internal/version.js
509
- var moduleVersion = "3.18.4";
508
+ // node_modules/.pnpm/effect@3.19.0/node_modules/effect/dist/esm/internal/version.js
509
+ var moduleVersion = "3.19.0";
510
510
  var getCurrentVersion = () => moduleVersion;
511
511
 
512
- // node_modules/.pnpm/@pkg.pr.new+Effect-TS+effect@97ff1dc_6ntygjheib5kdugabxjhox4fte/node_modules/effect/dist/esm/internal/effectable.js
512
+ // node_modules/.pnpm/effect@3.19.0/node_modules/effect/dist/esm/internal/effectable.js
513
513
  var EffectTypeId = /* @__PURE__ */ Symbol.for("effect/Effect");
514
514
  var StreamTypeId = /* @__PURE__ */ Symbol.for("effect/Stream");
515
515
  var SinkTypeId = /* @__PURE__ */ Symbol.for("effect/Sink");
@@ -596,7 +596,7 @@ var StructuralCommitPrototype = {
596
596
  ...StructuralPrototype
597
597
  };
598
598
 
599
- // node_modules/.pnpm/@pkg.pr.new+Effect-TS+effect@97ff1dc_6ntygjheib5kdugabxjhox4fte/node_modules/effect/dist/esm/internal/option.js
599
+ // node_modules/.pnpm/effect@3.19.0/node_modules/effect/dist/esm/internal/option.js
600
600
  var TypeId = /* @__PURE__ */ Symbol.for("effect/Option");
601
601
  var CommonProto = {
602
602
  ...EffectPrototype,
@@ -654,7 +654,7 @@ var some = (value) => {
654
654
  return a;
655
655
  };
656
656
 
657
- // node_modules/.pnpm/@pkg.pr.new+Effect-TS+effect@97ff1dc_6ntygjheib5kdugabxjhox4fte/node_modules/effect/dist/esm/internal/either.js
657
+ // node_modules/.pnpm/effect@3.19.0/node_modules/effect/dist/esm/internal/either.js
658
658
  var TypeId2 = /* @__PURE__ */ Symbol.for("effect/Either");
659
659
  var CommonProto2 = {
660
660
  ...EffectPrototype,
@@ -716,7 +716,7 @@ var right = (right3) => {
716
716
  return a;
717
717
  };
718
718
 
719
- // node_modules/.pnpm/@pkg.pr.new+Effect-TS+effect@97ff1dc_6ntygjheib5kdugabxjhox4fte/node_modules/effect/dist/esm/Either.js
719
+ // node_modules/.pnpm/effect@3.19.0/node_modules/effect/dist/esm/Either.js
720
720
  var right2 = right;
721
721
  var left2 = left;
722
722
  var isLeft2 = isLeft;
@@ -724,14 +724,14 @@ var isRight2 = isRight;
724
724
  var map = /* @__PURE__ */ dual(2, (self, f) => isRight2(self) ? right2(f(self.right)) : left2(self.left));
725
725
  var getOrElse = /* @__PURE__ */ dual(2, (self, onLeft) => isLeft2(self) ? onLeft(self.left) : self.right);
726
726
 
727
- // node_modules/.pnpm/@pkg.pr.new+Effect-TS+effect@97ff1dc_6ntygjheib5kdugabxjhox4fte/node_modules/effect/dist/esm/internal/array.js
727
+ // node_modules/.pnpm/effect@3.19.0/node_modules/effect/dist/esm/internal/array.js
728
728
  var isNonEmptyArray = (self) => self.length > 0;
729
729
 
730
- // node_modules/.pnpm/@pkg.pr.new+Effect-TS+effect@97ff1dc_6ntygjheib5kdugabxjhox4fte/node_modules/effect/dist/esm/Order.js
730
+ // node_modules/.pnpm/effect@3.19.0/node_modules/effect/dist/esm/Order.js
731
731
  var make = (compare) => (self, that) => self === that ? 0 : compare(self, that);
732
732
  var string2 = /* @__PURE__ */ make((self, that) => self < that ? -1 : 1);
733
733
 
734
- // node_modules/.pnpm/@pkg.pr.new+Effect-TS+effect@97ff1dc_6ntygjheib5kdugabxjhox4fte/node_modules/effect/dist/esm/Option.js
734
+ // node_modules/.pnpm/effect@3.19.0/node_modules/effect/dist/esm/Option.js
735
735
  var none2 = () => none;
736
736
  var some2 = some;
737
737
  var isNone2 = isNone;
@@ -739,7 +739,7 @@ var isSome2 = isSome;
739
739
  var orElse = /* @__PURE__ */ dual(2, (self, that) => isNone2(self) ? that() : self);
740
740
  var fromNullable = (nullableValue) => nullableValue == null ? none2() : some2(nullableValue);
741
741
 
742
- // node_modules/.pnpm/@pkg.pr.new+Effect-TS+effect@97ff1dc_6ntygjheib5kdugabxjhox4fte/node_modules/effect/dist/esm/Record.js
742
+ // node_modules/.pnpm/effect@3.19.0/node_modules/effect/dist/esm/Record.js
743
743
  var map2 = /* @__PURE__ */ dual(2, (self, f) => {
744
744
  const out = {
745
745
  ...self
@@ -751,7 +751,7 @@ var map2 = /* @__PURE__ */ dual(2, (self, f) => {
751
751
  });
752
752
  var keys = (self) => Object.keys(self);
753
753
 
754
- // node_modules/.pnpm/@pkg.pr.new+Effect-TS+effect@97ff1dc_6ntygjheib5kdugabxjhox4fte/node_modules/effect/dist/esm/Array.js
754
+ // node_modules/.pnpm/effect@3.19.0/node_modules/effect/dist/esm/Array.js
755
755
  var fromIterable = (collection) => Array.isArray(collection) ? collection : Array.from(collection);
756
756
  var append = /* @__PURE__ */ dual(2, (self, last) => [...self, last]);
757
757
  var appendAll = /* @__PURE__ */ dual(2, (self, that) => fromIterable(self).concat(fromIterable(that)));
@@ -3537,6 +3537,7 @@ function make2(ts, tsUtils, typeChecker, typeCheckerUtils, program) {
3537
3537
  );
3538
3538
  return {
3539
3539
  isNodeReferenceToEffectModuleApi,
3540
+ isNodeReferenceToEffectSchemaModuleApi,
3540
3541
  effectType,
3541
3542
  strictEffectType,
3542
3543
  layerType,
@@ -5582,6 +5583,140 @@ Nested Effect-able types may be intended if you plan to later manually flatten o
5582
5583
  })
5583
5584
  });
5584
5585
 
5586
+ // src/diagnostics/runEffectInsideEffect.ts
5587
+ var runEffectInsideEffect = createDiagnostic({
5588
+ name: "runEffectInsideEffect",
5589
+ code: 32,
5590
+ severity: "suggestion",
5591
+ apply: fn("runEffectInsideEffect.apply")(function* (sourceFile, report) {
5592
+ const ts = yield* service(TypeScriptApi);
5593
+ const typeParser = yield* service(TypeParser);
5594
+ const nodeToVisit = [];
5595
+ const appendNodeToVisit = (node) => {
5596
+ nodeToVisit.push(node);
5597
+ return void 0;
5598
+ };
5599
+ ts.forEachChild(sourceFile, appendNodeToVisit);
5600
+ while (nodeToVisit.length > 0) {
5601
+ const node = nodeToVisit.shift();
5602
+ ts.forEachChild(node, appendNodeToVisit);
5603
+ if (!ts.isCallExpression(node)) continue;
5604
+ const isEffectRunCall = yield* pipe(
5605
+ typeParser.isNodeReferenceToEffectModuleApi("runPromise")(node.expression),
5606
+ orElse2(() => typeParser.isNodeReferenceToEffectModuleApi("runSync")(node.expression)),
5607
+ orElse2(() => typeParser.isNodeReferenceToEffectModuleApi("runFork")(node.expression)),
5608
+ orElse2(() => typeParser.isNodeReferenceToEffectModuleApi("runCallback")(node.expression)),
5609
+ option
5610
+ );
5611
+ if (isNone2(isEffectRunCall)) continue;
5612
+ let currentParent = node.parent;
5613
+ let nodeIntroduceScope = void 0;
5614
+ while (currentParent) {
5615
+ const possiblyEffectGen = currentParent;
5616
+ if (!nodeIntroduceScope) {
5617
+ if (ts.isFunctionExpression(possiblyEffectGen) || ts.isFunctionDeclaration(possiblyEffectGen) || ts.isMethodDeclaration(possiblyEffectGen) || ts.isArrowFunction(possiblyEffectGen)) {
5618
+ nodeIntroduceScope = possiblyEffectGen;
5619
+ continue;
5620
+ }
5621
+ }
5622
+ const isInEffectGen = yield* pipe(
5623
+ typeParser.effectGen(possiblyEffectGen),
5624
+ orElse2(() => typeParser.effectFnUntracedGen(possiblyEffectGen)),
5625
+ orElse2(() => typeParser.effectFnGen(possiblyEffectGen)),
5626
+ option
5627
+ );
5628
+ if (isSome2(isInEffectGen)) {
5629
+ const nodeText = sourceFile.text.substring(
5630
+ ts.getTokenPosOfNode(node.expression, sourceFile),
5631
+ node.expression.end
5632
+ );
5633
+ const messageText = nodeIntroduceScope && nodeIntroduceScope !== isInEffectGen.value.generatorFunction ? `Using ${nodeText} inside an Effect is not recommended. The same runtime should generally be used instead to run child effects.
5634
+ Consider extracting the Runtime by using for example Effect.runtime and then use Runtime.run* with the extracted runtime instead.` : `Using ${nodeText} inside an Effect is not recommended. Effects inside generators can usually just be yielded.`;
5635
+ report({
5636
+ location: node.expression,
5637
+ messageText,
5638
+ fixes: []
5639
+ });
5640
+ }
5641
+ currentParent = currentParent.parent;
5642
+ }
5643
+ }
5644
+ })
5645
+ });
5646
+
5647
+ // src/diagnostics/schemaUnionOfLiterals.ts
5648
+ var schemaUnionOfLiterals = createDiagnostic({
5649
+ name: "schemaUnionOfLiterals",
5650
+ code: 33,
5651
+ severity: "off",
5652
+ apply: fn("schemaUnionOfLiterals.apply")(function* (sourceFile, report) {
5653
+ const ts = yield* service(TypeScriptApi);
5654
+ const typeParser = yield* service(TypeParser);
5655
+ const nodeToVisit = [];
5656
+ const appendNodeToVisit = (node) => {
5657
+ nodeToVisit.push(node);
5658
+ return void 0;
5659
+ };
5660
+ ts.forEachChild(sourceFile, appendNodeToVisit);
5661
+ while (nodeToVisit.length > 0) {
5662
+ const node = nodeToVisit.shift();
5663
+ if (ts.isCallExpression(node)) {
5664
+ const isSchemaUnionCall = yield* pipe(
5665
+ typeParser.isNodeReferenceToEffectSchemaModuleApi("Union")(node.expression),
5666
+ orElse2(() => void_)
5667
+ );
5668
+ if (isSchemaUnionCall) {
5669
+ const args2 = fromIterable(node.arguments);
5670
+ if (args2.length >= 2) {
5671
+ const allAreCallExpressions = args2.every((arg) => ts.isCallExpression(arg));
5672
+ if (allAreCallExpressions) {
5673
+ const literalChecks = args2.map((arg) => {
5674
+ const callArg = arg;
5675
+ return pipe(
5676
+ typeParser.isNodeReferenceToEffectSchemaModuleApi("Literal")(callArg.expression),
5677
+ map4(() => callArg)
5678
+ );
5679
+ });
5680
+ const allLiteralsResult = yield* pipe(
5681
+ all(...literalChecks),
5682
+ option
5683
+ );
5684
+ if (allLiteralsResult._tag === "Some") {
5685
+ const allLiteralValues = [];
5686
+ for (const literalCall of allLiteralsResult.value) {
5687
+ for (const arg of literalCall.arguments) {
5688
+ allLiteralValues.push(arg);
5689
+ }
5690
+ }
5691
+ const firstLiteralCall = allLiteralsResult.value[0];
5692
+ const schemaLiteralExpression = firstLiteralCall.expression;
5693
+ report({
5694
+ location: node,
5695
+ messageText: "A Schema.Union of multiple Schema.Literal calls can be simplified to a single Schema.Literal call.",
5696
+ fixes: [{
5697
+ fixName: "schemaUnionOfLiterals_fix",
5698
+ description: "Replace with a single Schema.Literal call",
5699
+ apply: gen(function* () {
5700
+ const changeTracker = yield* service(ChangeTracker);
5701
+ const newNode = ts.factory.createCallExpression(
5702
+ schemaLiteralExpression,
5703
+ void 0,
5704
+ allLiteralValues
5705
+ );
5706
+ changeTracker.replaceNode(sourceFile, node, newNode);
5707
+ })
5708
+ }]
5709
+ });
5710
+ }
5711
+ }
5712
+ }
5713
+ }
5714
+ }
5715
+ ts.forEachChild(node, appendNodeToVisit);
5716
+ }
5717
+ })
5718
+ });
5719
+
5585
5720
  // src/diagnostics/scopeInLayerEffect.ts
5586
5721
  var scopeInLayerEffect = createDiagnostic({
5587
5722
  name: "scopeInLayerEffect",
@@ -6135,7 +6270,9 @@ var diagnostics = [
6135
6270
  deterministicKeys,
6136
6271
  missedPipeableOpportunity,
6137
6272
  strictEffectProvide,
6138
- unknownInEffectCatch
6273
+ unknownInEffectCatch,
6274
+ runEffectInsideEffect,
6275
+ schemaUnionOfLiterals
6139
6276
  ];
6140
6277
 
6141
6278
  // src/transform.ts