
Security News
npm ‘is’ Package Hijacked in Expanding Supply Chain Attack
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.
@effect/language-service
Advanced tools
A Language-Service Plugin to Refactor and Diagnostic effect-ts projects
This package implements a TypeScript language service plugin that allows additional refactors and diagnostics with your VSCode editor (or any editor that supports TypeScript's LSP).
npm install @effect/language-service --save-dev
in your project{
"compilerOptions": {
"plugins": [
// ... other LSPs (if any) and as last
{
"name": "@effect/language-service"
}
]
}
}
Ensure that you have installed TypeScript locally in your project and set your editor to use your workspace TypeScript version.
And you're done! You'll now be able to use a set of refactors and diagnostics that target Effect!
yield*
of Effect.gen
will show the Effect type parametersEffect.gen
Effect.provide
anti-patternEffect.gen
or pipe()
Effect.gen
and familyX.pipe(Y).pipe(Z)
Effect.Service
, Context.Tag
, Schema.TaggedClass
, Schema.TaggedRequest
and familyEffect.gen
with function*(){}
Effect.fn
with the span name given by the exported memberimport * as Effect from "effect"
Schema.brand
Effect.Service
or Context.Tag
declarationEffect.gen
definitions that contains a single yield
statement.Effect
expression with Effect.gen
X.pipe(Y)
and pipe(X, Y)
Few options can be provided alongside the initialization of the Language Service Plugin.
{
"compilerOptions": {
"plugins": [
{
"name": "@effect/language-service",
"diagnostics": true, // controls Effect diagnostics (default: true)
"diagnosticSeverity": { // allows to change per-rule default severity of the diagnostic in the whole project
"floatingEffect": "warning" // example for a rule, allowed values are off,error,warning,message,suggestion
},
"quickinfo": true, // controls quickinfo over Effect (default: true)
"completions": true, // controls Effect completions (default: true)
"goto": true, // controls Effect goto references (default: true)
"allowedDuplicatedPackages": [], // list of package names that have effect in peer dependencies and are allowed to be duplicated (default: [])
"barrelImportPackages": [], // package names that should be preferred as imported from the top level barrel file (default: [])
"namespaceImportPackages": [] // package names that should be preferred as imported with namespace imports e.g. ["effect", "@effect/*"] (default: [])
}
]
}
}
TypeScript LSPs are loaded only while editing your files. That means that if you run tsc
in your project, the plugin won't be loaded and you'll miss out on the Effect diagnostics.
HOWEVER, if you use ts-patch
you can enable the transform as well to get the diagnostics also at compile time.
Your tsconfig.json
should look like this:
{
"compilerOptions": {
"plugins": [
{
"name": "@effect/language-service",
"transform": "@effect/language-service/transform" // enables diagnostics at compile time when using ts-patch
}
]
}
}
To get diagnostics you need to install ts-patch
which will make it possible to run tspc
.
Running tspc
in your project will now also run the plugin and give you the error diagnostics at compile time.
Effect error diagnostics will be shown only after standard TypeScript diagnostics have been satisfied.
Beware that setting noEmit will completely skip the effect diagnostics.
$ npx tspc
index.ts:3:1 - error TS3: Effect must be yielded or assigned to a variable.
3 Effect.succeed(1)
~~~~~~~~~~~~~~~~~
Found 1 error in index.ts:3
You can either disable or change the severity of specific diagnostics by using comments in your code.
// @effect-diagnostics effect/floatingEffect:off
Effect.succeed(1); // This will not be reported as a floating effect
// @effect-diagnostics effect/floatingEffect:error
Effect.succeed(1); // This will be reported as a floating effect
or you can set the severity for the entire project in the global plugin configuration
{
"compilerOptions": {
"plugins": [
{
// ...
"diagnosticSeverity": { // allows to change per-rule default severity of the diagnostic in the whole project
"floatingEffect": "warning" // example for a rule, allowed values are off,error,warning,message,suggestion
},
// ...
}
]
}
}
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.
If you did not install the Svelte LSP into your local project but instead through the Svelte VSCode extension, we recommend instead to install it locally and add it as the first entry. That way it won't be applied by the VSCode extension.
Your tsconfig.json should look like this:
{
"compilerOptions": {
"plugins": [
{ "name": "typescript-svelte-plugin" },
{ "name": "@effect/language-service" }
]
}
}
FAQs
A Language-Service Plugin to Refactor and Diagnostic effect-ts projects
The npm package @effect/language-service receives a total of 181,455 weekly downloads. As such, @effect/language-service popularity was classified as popular.
We found that @effect/language-service demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.
Security News
A critical flaw in the popular npm form-data package could allow HTTP parameter pollution, affecting millions of projects until patched versions are adopted.
Security News
Bun 1.2.19 introduces isolated installs for smoother monorepo workflows, along with performance boosts, new tooling, and key compatibility fixes.