@effect/language-service 0.50.0 → 0.51.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/cli.js +52 -2
- package/cli.js.map +1 -1
- package/effect-lsp-patch-utils.js +53 -2
- package/effect-lsp-patch-utils.js.map +1 -1
- package/index.js +74 -8
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/transform.js +53 -2
- package/transform.js.map +1 -1
|
@@ -771,6 +771,7 @@ var unsafeGet = /* @__PURE__ */ dual(2, (self, index) => {
|
|
|
771
771
|
});
|
|
772
772
|
var headNonEmpty = /* @__PURE__ */ unsafeGet(0);
|
|
773
773
|
var tailNonEmpty = (self) => self.slice(1);
|
|
774
|
+
var reverse = (self) => Array.from(self).reverse();
|
|
774
775
|
var sort = /* @__PURE__ */ dual(2, (self, O) => {
|
|
775
776
|
const out = Array.from(self);
|
|
776
777
|
out.sort(O);
|
|
@@ -4320,7 +4321,12 @@ var missedPipeableOpportunity = createDiagnostic({
|
|
|
4320
4321
|
"pipe"
|
|
4321
4322
|
),
|
|
4322
4323
|
void 0,
|
|
4323
|
-
|
|
4324
|
+
pipe(
|
|
4325
|
+
parentChain,
|
|
4326
|
+
filter(ts.isCallExpression),
|
|
4327
|
+
map3((call) => call.expression),
|
|
4328
|
+
reverse
|
|
4329
|
+
)
|
|
4324
4330
|
)
|
|
4325
4331
|
);
|
|
4326
4332
|
})
|
|
@@ -5615,6 +5621,50 @@ var strictBooleanExpressions = createDiagnostic({
|
|
|
5615
5621
|
})
|
|
5616
5622
|
});
|
|
5617
5623
|
|
|
5624
|
+
// src/diagnostics/strictEffectProvide.ts
|
|
5625
|
+
var strictEffectProvide = createDiagnostic({
|
|
5626
|
+
name: "strictEffectProvide",
|
|
5627
|
+
code: 27,
|
|
5628
|
+
severity: "off",
|
|
5629
|
+
apply: fn("strictEffectProvide.apply")(function* (sourceFile, report) {
|
|
5630
|
+
const ts = yield* service(TypeScriptApi);
|
|
5631
|
+
const typeChecker = yield* service(TypeCheckerApi);
|
|
5632
|
+
const typeParser = yield* service(TypeParser);
|
|
5633
|
+
const parseEffectProvideWithLayer = (node) => gen(function* () {
|
|
5634
|
+
if (!ts.isCallExpression(node) || !ts.isPropertyAccessExpression(node.expression) || !ts.isIdentifier(node.expression.name) || ts.idText(node.expression.name) !== "provide" || node.arguments.length === 0) {
|
|
5635
|
+
return yield* typeParserIssue("Not an Effect.provide call");
|
|
5636
|
+
}
|
|
5637
|
+
yield* typeParser.importedEffectModule(node.expression.expression);
|
|
5638
|
+
return yield* firstSuccessOf(
|
|
5639
|
+
node.arguments.map((arg) => {
|
|
5640
|
+
const argType = typeChecker.getTypeAtLocation(arg);
|
|
5641
|
+
return typeParser.layerType(argType, arg);
|
|
5642
|
+
})
|
|
5643
|
+
);
|
|
5644
|
+
});
|
|
5645
|
+
const nodeToVisit = [];
|
|
5646
|
+
const appendNodeToVisit = (node) => {
|
|
5647
|
+
nodeToVisit.push(node);
|
|
5648
|
+
return void 0;
|
|
5649
|
+
};
|
|
5650
|
+
ts.forEachChild(sourceFile, appendNodeToVisit);
|
|
5651
|
+
while (nodeToVisit.length > 0) {
|
|
5652
|
+
const node = nodeToVisit.shift();
|
|
5653
|
+
ts.forEachChild(node, appendNodeToVisit);
|
|
5654
|
+
if (ts.isCallExpression(node)) {
|
|
5655
|
+
const layerCheck = yield* pipe(parseEffectProvideWithLayer(node), option);
|
|
5656
|
+
if (isSome2(layerCheck)) {
|
|
5657
|
+
report({
|
|
5658
|
+
location: node,
|
|
5659
|
+
messageText: "Effect.provide with a Layer should only be used at application entry points. If this is an entry point, you can safely disable this diagnostic. Otherwise, using Effect.provide may break scope lifetimes. Compose all layers at your entry point and provide them at once.",
|
|
5660
|
+
fixes: []
|
|
5661
|
+
});
|
|
5662
|
+
}
|
|
5663
|
+
}
|
|
5664
|
+
}
|
|
5665
|
+
})
|
|
5666
|
+
});
|
|
5667
|
+
|
|
5618
5668
|
// src/diagnostics/tryCatchInEffectGen.ts
|
|
5619
5669
|
var tryCatchInEffectGen = createDiagnostic({
|
|
5620
5670
|
name: "tryCatchInEffectGen",
|
|
@@ -5905,7 +5955,8 @@ var diagnostics = [
|
|
|
5905
5955
|
unsupportedServiceAccessors,
|
|
5906
5956
|
nonObjectEffectServiceType,
|
|
5907
5957
|
deterministicKeys,
|
|
5908
|
-
missedPipeableOpportunity
|
|
5958
|
+
missedPipeableOpportunity,
|
|
5959
|
+
strictEffectProvide
|
|
5909
5960
|
];
|
|
5910
5961
|
|
|
5911
5962
|
// src/effect-lsp-patch-utils.ts
|