@effect/language-service 0.21.2 → 0.21.3
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 +40 -1
- package/index.js +9 -4
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/transform.js +9 -4
- package/transform.js.map +1 -1
package/README.md
CHANGED
|
@@ -6,11 +6,11 @@ This package implements a TypeScript language service plugin that allows additio
|
|
|
6
6
|
|
|
7
7
|
1. `npm install @effect/language-service --save-dev` in your project
|
|
8
8
|
2. inside your tsconfig.json, you should add the plugin configuration as follows:
|
|
9
|
-
|
|
10
9
|
```json
|
|
11
10
|
{
|
|
12
11
|
"compilerOptions": {
|
|
13
12
|
"plugins": [
|
|
13
|
+
// ... other LSPs (if any) and as last
|
|
14
14
|
{
|
|
15
15
|
"name": "@effect/language-service"
|
|
16
16
|
}
|
|
@@ -133,3 +133,42 @@ Effect.succeed(1); // This will not be reported as a floating effect
|
|
|
133
133
|
// @effect-diagnostics effect/floatingEffect:error
|
|
134
134
|
Effect.succeed(1); // This will be reported as a floating effect
|
|
135
135
|
```
|
|
136
|
+
|
|
137
|
+
or you can set the severity for the entire project in the global plugin configuration
|
|
138
|
+
|
|
139
|
+
```json
|
|
140
|
+
{
|
|
141
|
+
"compilerOptions": {
|
|
142
|
+
"plugins": [
|
|
143
|
+
{
|
|
144
|
+
// ...
|
|
145
|
+
"diagnosticSeverity": { // allows to change per-rule default severity of the diagnostic in the whole project
|
|
146
|
+
"floatingEffect": "warning" // example for a rule, allowed values are off,error,warning,message,suggestion
|
|
147
|
+
},
|
|
148
|
+
// ...
|
|
149
|
+
}
|
|
150
|
+
]
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## Known gotchas
|
|
156
|
+
|
|
157
|
+
### Svelte VSCode extension and SvelteKit
|
|
158
|
+
|
|
159
|
+
The Svelte LSP does not properly compose with other LSPs when using SvelteKit. So the Effect LSP should be loaded as last entry to ensure proper composition.
|
|
160
|
+
|
|
161
|
+
If you did not installed the Svelte LSP into your local project but instead through the Svelte VSCode extension, we recommend instead to install locally and add it as first entry. That way it won't be applied by the VSCode extension.
|
|
162
|
+
|
|
163
|
+
Your tsconfig should look like this:
|
|
164
|
+
|
|
165
|
+
```json
|
|
166
|
+
{
|
|
167
|
+
"compilerOptions": {
|
|
168
|
+
"plugins": [
|
|
169
|
+
{ "name": "typescript-svelte-plugin" },
|
|
170
|
+
{ "name": "@effect/language-service" }
|
|
171
|
+
]
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
```
|
package/index.js
CHANGED
|
@@ -1191,6 +1191,8 @@ function parsePackageContentNameAndVersionFromScope(v) {
|
|
|
1191
1191
|
const packageJsonContent = packageJsonScope.contents.packageJsonContent;
|
|
1192
1192
|
if (!hasProperty(packageJsonContent, "name")) return;
|
|
1193
1193
|
if (!hasProperty(packageJsonContent, "version")) return;
|
|
1194
|
+
if (!hasProperty(packageJsonScope, "packageDirectory")) return;
|
|
1195
|
+
if (!isString(packageJsonScope.packageDirectory)) return;
|
|
1194
1196
|
const { name, version } = packageJsonContent;
|
|
1195
1197
|
if (!isString(name)) return;
|
|
1196
1198
|
if (!isString(version)) return;
|
|
@@ -1199,7 +1201,8 @@ function parsePackageContentNameAndVersionFromScope(v) {
|
|
|
1199
1201
|
name: name.toLowerCase(),
|
|
1200
1202
|
version: version.toLowerCase(),
|
|
1201
1203
|
hasEffectInPeerDependencies,
|
|
1202
|
-
contents: packageJsonContent
|
|
1204
|
+
contents: packageJsonContent,
|
|
1205
|
+
packageDirectory: packageJsonScope.packageDirectory
|
|
1203
1206
|
};
|
|
1204
1207
|
}
|
|
1205
1208
|
|
|
@@ -2864,7 +2867,7 @@ var duplicatePackage = createDiagnostic({
|
|
|
2864
2867
|
if (!(packageInfo.name === "effect" || packageInfo.hasEffectInPeerDependencies)) return;
|
|
2865
2868
|
if (options.allowedDuplicatedPackages.indexOf(packageInfo.name) > -1) return;
|
|
2866
2869
|
resolvedPackages[packageInfo.name] = resolvedPackages[packageInfo.name] || {};
|
|
2867
|
-
resolvedPackages[packageInfo.name][packageInfo.version] = packageInfo.
|
|
2870
|
+
resolvedPackages[packageInfo.name][packageInfo.version] = packageInfo.packageDirectory;
|
|
2868
2871
|
});
|
|
2869
2872
|
checkedPackagesCache.set(sourceFile.fileName, resolvedPackages);
|
|
2870
2873
|
programResolvedCacheSize.set(sourceFile.fileName, newResolvedModuleSize);
|
|
@@ -2877,7 +2880,9 @@ var duplicatePackage = createDiagnostic({
|
|
|
2877
2880
|
category: ts.DiagnosticCategory.Warning,
|
|
2878
2881
|
messageText: `Package ${packageName} is referenced multiple times with different versions (${versions.join(", ")}) and may cause unexpected type errors.
|
|
2879
2882
|
Cleanup your dependencies and your package lockfile to avoid multiple instances of this package and reload the project.
|
|
2880
|
-
If this is intended set the LSP config "allowedDuplicatedPackages" to ${JSON.stringify(options.allowedDuplicatedPackages.concat([packageName]))}
|
|
2883
|
+
If this is intended set the LSP config "allowedDuplicatedPackages" to ${JSON.stringify(options.allowedDuplicatedPackages.concat([packageName]))}.
|
|
2884
|
+
|
|
2885
|
+
${versions.map((version) => `- found ${version} at ${resolvedPackages[packageName][version]}`).join("\n")}`,
|
|
2881
2886
|
fixes: []
|
|
2882
2887
|
});
|
|
2883
2888
|
}
|
|
@@ -3208,7 +3213,7 @@ var missingReturnYieldStar = createDiagnostic({
|
|
|
3208
3213
|
effectDiagnostics.push({
|
|
3209
3214
|
node,
|
|
3210
3215
|
category: ts.DiagnosticCategory.Error,
|
|
3211
|
-
messageText: `Yielded Effect never
|
|
3216
|
+
messageText: `Yielded Effect never succeeds, so it is best to use a 'return yield*' instead.`,
|
|
3212
3217
|
fixes: fix
|
|
3213
3218
|
});
|
|
3214
3219
|
});
|