@effect/language-service 0.27.0 → 0.27.2
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 -1
- package/cli.js +5 -1
- package/cli.js.map +1 -1
- package/index.js +67 -13
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/transform.js +5 -1
- package/transform.js.map +1 -1
package/index.js
CHANGED
|
@@ -1710,7 +1710,11 @@ var createDiagnosticExecutor = fn("LSP.createCommentDirectivesProcessor")(
|
|
|
1710
1710
|
const diagnostics2 = [];
|
|
1711
1711
|
const codeFixes = [];
|
|
1712
1712
|
const ruleNameLowered = rule.name.toLowerCase();
|
|
1713
|
+
const defaultLevel = pluginOptions.diagnosticSeverity[ruleNameLowered] || rule.severity;
|
|
1713
1714
|
if (skippedRules.indexOf(ruleNameLowered) > -1) return { diagnostics: diagnostics2, codeFixes };
|
|
1715
|
+
if (defaultLevel === "off" && (lineOverrides[ruleNameLowered] || sectionOverrides[ruleNameLowered] || []).length === 0) {
|
|
1716
|
+
return { diagnostics: diagnostics2, codeFixes };
|
|
1717
|
+
}
|
|
1714
1718
|
const fixByDisableNextLine = (_) => ({
|
|
1715
1719
|
fixName: rule.name + "_skipNextLine",
|
|
1716
1720
|
description: "Disable " + rule.name + " for this line",
|
|
@@ -1751,7 +1755,7 @@ var createDiagnosticExecutor = fn("LSP.createCommentDirectivesProcessor")(
|
|
|
1751
1755
|
});
|
|
1752
1756
|
});
|
|
1753
1757
|
for (const emitted of applicableDiagnostics.slice(0)) {
|
|
1754
|
-
let newLevel =
|
|
1758
|
+
let newLevel = defaultLevel;
|
|
1755
1759
|
const lineOverride = (lineOverrides[ruleNameLowered] || []).find(
|
|
1756
1760
|
(_) => _.pos < emitted.node.getStart(sourceFile) && _.end >= emitted.node.getEnd()
|
|
1757
1761
|
);
|
|
@@ -4133,6 +4137,55 @@ var rpcMakeClasses = createCompletion({
|
|
|
4133
4137
|
})
|
|
4134
4138
|
});
|
|
4135
4139
|
|
|
4140
|
+
// src/completions/schemaBrand.ts
|
|
4141
|
+
var schemaBrand = createCompletion({
|
|
4142
|
+
name: "schemaBrand",
|
|
4143
|
+
apply: fn("schemaBrand")(function* (sourceFile, position) {
|
|
4144
|
+
const ts = yield* service(TypeScriptApi);
|
|
4145
|
+
const maybeInfos = yield* option(
|
|
4146
|
+
parseAccessedExpressionForCompletion(sourceFile, position)
|
|
4147
|
+
);
|
|
4148
|
+
if (isNone2(maybeInfos)) return [];
|
|
4149
|
+
const { accessedObject } = maybeInfos.value;
|
|
4150
|
+
if (!ts.isIdentifier(accessedObject)) return [];
|
|
4151
|
+
const schemaName = match(
|
|
4152
|
+
yield* option(
|
|
4153
|
+
findImportedModuleIdentifierByPackageAndNameOrBarrel(
|
|
4154
|
+
sourceFile,
|
|
4155
|
+
"effect",
|
|
4156
|
+
"Schema"
|
|
4157
|
+
)
|
|
4158
|
+
),
|
|
4159
|
+
{
|
|
4160
|
+
onNone: () => "Schema",
|
|
4161
|
+
onSome: (_) => _.text
|
|
4162
|
+
}
|
|
4163
|
+
);
|
|
4164
|
+
if (schemaName !== accessedObject.text) return [];
|
|
4165
|
+
const span = ts.createTextSpan(
|
|
4166
|
+
accessedObject.end + 1,
|
|
4167
|
+
Math.max(0, position - accessedObject.end - 1)
|
|
4168
|
+
);
|
|
4169
|
+
return pipe(
|
|
4170
|
+
yield* getAncestorNodesInRange(sourceFile, toTextRange(accessedObject.pos)),
|
|
4171
|
+
filter(ts.isVariableDeclaration),
|
|
4172
|
+
map3((_) => _.name && ts.isIdentifier(_.name) ? _.name.text : ""),
|
|
4173
|
+
filter((_) => _.length > 0),
|
|
4174
|
+
head,
|
|
4175
|
+
map2((name) => [
|
|
4176
|
+
{
|
|
4177
|
+
name: `brand("${name}")`,
|
|
4178
|
+
kind: ts.ScriptElementKind.constElement,
|
|
4179
|
+
insertText: `brand("${name}")`,
|
|
4180
|
+
replacementSpan: span,
|
|
4181
|
+
isSnippet: true
|
|
4182
|
+
}
|
|
4183
|
+
]),
|
|
4184
|
+
getOrElse2(() => [])
|
|
4185
|
+
);
|
|
4186
|
+
})
|
|
4187
|
+
});
|
|
4188
|
+
|
|
4136
4189
|
// src/completions.ts
|
|
4137
4190
|
var completions = [
|
|
4138
4191
|
effectSchemaSelfInClasses,
|
|
@@ -4143,7 +4196,8 @@ var completions = [
|
|
|
4143
4196
|
fnFunctionStar,
|
|
4144
4197
|
effectDataClasses,
|
|
4145
4198
|
effectDiagnosticsComment,
|
|
4146
|
-
durationInput
|
|
4199
|
+
durationInput,
|
|
4200
|
+
schemaBrand
|
|
4147
4201
|
];
|
|
4148
4202
|
|
|
4149
4203
|
// src/completions/middlewareAutoImports.ts
|
|
@@ -9698,7 +9752,7 @@ var _createOpaqueTypes = fn("_createOpaqueTypes")(function* (effectSchemaName, i
|
|
|
9698
9752
|
ts.factory.createIdentifier(inferFromName)
|
|
9699
9753
|
)]
|
|
9700
9754
|
);
|
|
9701
|
-
const opaqueType = typeA.
|
|
9755
|
+
const opaqueType = !(typeA.flags & ts.TypeFlags.Object) ? ts.factory.createTypeAliasDeclaration(
|
|
9702
9756
|
[ts.factory.createModifier(ts.SyntaxKind.ExportKeyword)],
|
|
9703
9757
|
opaqueTypeName,
|
|
9704
9758
|
[],
|
|
@@ -9725,7 +9779,7 @@ var _createOpaqueTypes = fn("_createOpaqueTypes")(function* (effectSchemaName, i
|
|
|
9725
9779
|
ts.factory.createIdentifier(inferFromName)
|
|
9726
9780
|
)]
|
|
9727
9781
|
);
|
|
9728
|
-
const encodedType = typeE.
|
|
9782
|
+
const encodedType = !(typeE.flags & ts.TypeFlags.Object) ? ts.factory.createTypeAliasDeclaration(
|
|
9729
9783
|
[ts.factory.createModifier(ts.SyntaxKind.ExportKeyword)],
|
|
9730
9784
|
opaqueEncodedName,
|
|
9731
9785
|
[],
|
|
@@ -10860,6 +10914,15 @@ var refactors = [
|
|
|
10860
10914
|
// src/index.ts
|
|
10861
10915
|
var LSP_INJECTED_URI = "@effect/language-service/injected";
|
|
10862
10916
|
var init = (modules) => {
|
|
10917
|
+
const diagnosticsErrorCodes = diagnostics.map((diagnostic) => diagnostic.code);
|
|
10918
|
+
try {
|
|
10919
|
+
;
|
|
10920
|
+
modules.typescript.codefix.registerCodeFix({
|
|
10921
|
+
errorCodes: diagnosticsErrorCodes,
|
|
10922
|
+
getCodeActions: () => void 0
|
|
10923
|
+
});
|
|
10924
|
+
} catch (_) {
|
|
10925
|
+
}
|
|
10863
10926
|
let languageServicePluginOptions = parse({});
|
|
10864
10927
|
function onConfigurationChanged(config) {
|
|
10865
10928
|
languageServicePluginOptions = parse(config);
|
|
@@ -10869,15 +10932,6 @@ var init = (modules) => {
|
|
|
10869
10932
|
languageServicePluginOptions = parse(info.config);
|
|
10870
10933
|
if (languageService[LSP_INJECTED_URI]) return languageService;
|
|
10871
10934
|
info.project.log("[@effect/language-service] Started!");
|
|
10872
|
-
const diagnosticsErrorCodes = diagnostics.map((diagnostic) => diagnostic.code);
|
|
10873
|
-
try {
|
|
10874
|
-
;
|
|
10875
|
-
modules.typescript.codefix.registerCodeFix({
|
|
10876
|
-
errorCodes: diagnosticsErrorCodes,
|
|
10877
|
-
getCodeActions: () => void 0
|
|
10878
|
-
});
|
|
10879
|
-
} catch (_) {
|
|
10880
|
-
}
|
|
10881
10935
|
const proxy = /* @__PURE__ */ Object.create(null);
|
|
10882
10936
|
proxy[LSP_INJECTED_URI] = true;
|
|
10883
10937
|
for (const k of Object.keys(languageService)) {
|