Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/curvy-toes-laugh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@effect/language-service": minor
---

Generate a root `schema.json` for `tsconfig.json` plugin configuration, add typed Effect Language Service plugin options to that schema, and have `effect-language-service setup` add or remove the matching `$schema` entry automatically.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ This package implements a TypeScript language service plugin that allows additio
2. Inside your tsconfig.json, you should add the plugin configuration as follows:
```jsonc
{
"$schema": "https://raw.githubusercontent.com/Effect-TS/language-service/refs/heads/main/schema.json",
"compilerOptions": {
"plugins": [
// ... other LSPs (if any) and as last
Expand Down Expand Up @@ -231,7 +232,7 @@ so that across updates the patch will be re-applied again.
The effect language service plugin comes with a builtin CLI tool that can be used to perform various utilities, checks and setups. Since it relies on typescript, we recommend to install it locally and run it locally to ensure it loads the same typescript version of your project rather than a global installation that may resolve to use a different TS version from the one of your project.

### `effect-language-service setup`
Runs through a wizard to setup/update some basic functionalities of the LSP in an interactive way.
Runs through a wizard to setup/update some basic functionalities of the LSP in an interactive way. This also keeps the `tsconfig.json` `$schema` aligned with the published Effect Language Service schema.

### `effect-language-service codegen`
Automatically updates Effect codegens in your TypeScript files. This command scans files for `@effect-codegens` directives and applies the necessary code transformations. Use `--file` to update a specific file, or `--project` with a tsconfig file to update an entire project. The `--verbose` flag provides detailed output about which files are being processed and updated.
Expand Down
121 changes: 94 additions & 27 deletions packages/harness-effect-v3/__snapshots__/setup-cli.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ exports[`Setup CLI > should add Effect Language Service section to existing AGEN
"file": "package.json",
},
{
"description": "Add plugins array with @effect/language-service plugin",
"description": "Add $schema to tsconfig; Add plugins array with @effect/language-service plugin",
"file": "tsconfig.json",
},
{
Expand All @@ -51,7 +51,8 @@ exports[`Setup CLI > should add Effect Language Service section to existing AGEN
"plugins": [
{ "name": "@effect/language-service" }
]
}
},
"$schema": "https://raw.githubusercontent.com/Effect-TS/language-service/refs/heads/main/schema.json"
}"
`;

Expand All @@ -62,7 +63,7 @@ exports[`Setup CLI > should add LSP plugin alongside existing plugins > change s
"file": "package.json",
},
{
"description": "Add @effect/language-service plugin to existing plugins array",
"description": "Add $schema to tsconfig; Add @effect/language-service plugin to existing plugins array",
"file": "tsconfig.json",
},
]
Expand All @@ -88,7 +89,8 @@ exports[`Setup CLI > should add LSP plugin alongside existing plugins > tsconfig
},
{ "name": "@effect/language-service" }
]
}
},
"$schema": "https://raw.githubusercontent.com/Effect-TS/language-service/refs/heads/main/schema.json"
}"
`;

Expand All @@ -106,7 +108,7 @@ exports[`Setup CLI > should add LSP with VS Code editor selected and configure V
"file": "package.json",
},
{
"description": "Add plugins array with @effect/language-service plugin",
"description": "Add $schema to tsconfig; Add plugins array with @effect/language-service plugin",
"file": "tsconfig.json",
},
{
Expand All @@ -133,7 +135,8 @@ exports[`Setup CLI > should add LSP with VS Code editor selected and configure V
"plugins": [
{ "name": "@effect/language-service" }
]
}
},
"$schema": "https://raw.githubusercontent.com/Effect-TS/language-service/refs/heads/main/schema.json"
}"
`;

Expand All @@ -144,7 +147,7 @@ exports[`Setup CLI > should generate changes for adding LSP with custom diagnost
"file": "package.json",
},
{
"description": "Add plugins array with @effect/language-service plugin",
"description": "Add $schema to tsconfig; Add plugins array with @effect/language-service plugin",
"file": "tsconfig.json",
},
]
Expand Down Expand Up @@ -173,7 +176,8 @@ exports[`Setup CLI > should generate changes for adding LSP with custom diagnost
}
}
]
}
},
"$schema": "https://raw.githubusercontent.com/Effect-TS/language-service/refs/heads/main/schema.json"
}"
`;

Expand All @@ -184,7 +188,7 @@ exports[`Setup CLI > should generate changes for adding LSP with defaults > chan
"file": "package.json",
},
{
"description": "Add plugins array with @effect/language-service plugin",
"description": "Add $schema to tsconfig; Add plugins array with @effect/language-service plugin",
"file": "tsconfig.json",
},
]
Expand All @@ -207,7 +211,8 @@ exports[`Setup CLI > should generate changes for adding LSP with defaults > tsco
"plugins": [
{ "name": "@effect/language-service" }
]
}
},
"$schema": "https://raw.githubusercontent.com/Effect-TS/language-service/refs/heads/main/schema.json"
}"
`;

Expand All @@ -218,7 +223,7 @@ exports[`Setup CLI > should generate changes for adding LSP with prepare script
"file": "package.json",
},
{
"description": "Add plugins array with @effect/language-service plugin",
"description": "Add $schema to tsconfig; Add plugins array with @effect/language-service plugin",
"file": "tsconfig.json",
},
]
Expand All @@ -242,7 +247,8 @@ exports[`Setup CLI > should generate changes for adding LSP with prepare script
"plugins": [
{ "name": "@effect/language-service" }
]
}
},
"$schema": "https://raw.githubusercontent.com/Effect-TS/language-service/refs/heads/main/schema.json"
}"
`;

Expand Down Expand Up @@ -289,7 +295,7 @@ exports[`Setup CLI > should generate changes for removing LSP when already insta
"file": "package.json",
},
{
"description": "Remove @effect/language-service plugin from tsconfig",
"description": "Remove $schema from tsconfig; Remove @effect/language-service plugin from tsconfig",
"file": "tsconfig.json",
},
]
Expand Down Expand Up @@ -320,7 +326,7 @@ exports[`Setup CLI > should generate changes for removing LSP when already insta
exports[`Setup CLI > should generate changes for updating existing LSP with new diagnostic severities > change summary 1`] = `
[
{
"description": "Update @effect/language-service plugin diagnostic severities",
"description": "Add $schema to tsconfig; Update @effect/language-service plugin diagnostic severities",
"file": "tsconfig.json",
},
]
Expand All @@ -340,14 +346,15 @@ exports[`Setup CLI > should generate changes for updating existing LSP with new
}
}
]
}
},
"$schema": "https://raw.githubusercontent.com/Effect-TS/language-service/refs/heads/main/schema.json"
}"
`;

exports[`Setup CLI > should handle tsconfig with existing plugin having custom options and diagnosticSeverity > change summary 1`] = `
[
{
"description": "Update @effect/language-service plugin diagnostic severities",
"description": "Add $schema to tsconfig; Update @effect/language-service plugin diagnostic severities",
"file": "tsconfig.json",
},
]
Expand Down Expand Up @@ -397,7 +404,8 @@ exports[`Setup CLI > should handle tsconfig with existing plugin having custom o
"exclude": [
"node_modules",
"dist"
]
],
"$schema": "https://raw.githubusercontent.com/Effect-TS/language-service/refs/heads/main/schema.json"
}"
`;

Expand All @@ -408,7 +416,7 @@ exports[`Setup CLI > should not override existing plugins when adding LSP plugin
"file": "package.json",
},
{
"description": "Add @effect/language-service plugin to existing plugins array",
"description": "Add $schema to tsconfig; Add @effect/language-service plugin to existing plugins array",
"file": "tsconfig.json",
},
]
Expand Down Expand Up @@ -445,7 +453,8 @@ exports[`Setup CLI > should not override existing plugins when adding LSP plugin
}
}
]
}
},
"$schema": "https://raw.githubusercontent.com/Effect-TS/language-service/refs/heads/main/schema.json"
}"
`;

Expand All @@ -456,7 +465,7 @@ exports[`Setup CLI > should preserve all existing VSCode settings from real repo
"file": "package.json",
},
{
"description": "Add plugins array with @effect/language-service plugin",
"description": "Add $schema to tsconfig; Add plugins array with @effect/language-service plugin",
"file": "tsconfig.json",
},
]
Expand All @@ -479,14 +488,15 @@ exports[`Setup CLI > should preserve all existing VSCode settings from real repo
"plugins": [
{ "name": "@effect/language-service" }
]
}
},
"$schema": "https://raw.githubusercontent.com/Effect-TS/language-service/refs/heads/main/schema.json"
}"
`;

exports[`Setup CLI > should preserve existing LSP plugin options when updating diagnostic severities > change summary 1`] = `
[
{
"description": "Update @effect/language-service plugin diagnostic severities",
"description": "Add $schema to tsconfig; Update @effect/language-service plugin diagnostic severities",
"file": "tsconfig.json",
},
]
Expand All @@ -510,7 +520,8 @@ exports[`Setup CLI > should preserve existing LSP plugin options when updating d
}
}
]
}
},
"$schema": "https://raw.githubusercontent.com/Effect-TS/language-service/refs/heads/main/schema.json"
}"
`;

Expand All @@ -531,7 +542,7 @@ exports[`Setup CLI > should preserve existing VSCode settings when adding LSP-sp
"file": "package.json",
},
{
"description": "Add plugins array with @effect/language-service plugin",
"description": "Add $schema to tsconfig; Add plugins array with @effect/language-service plugin",
"file": "tsconfig.json",
},
{
Expand All @@ -558,7 +569,8 @@ exports[`Setup CLI > should preserve existing VSCode settings when adding LSP-sp
"plugins": [
{ "name": "@effect/language-service" }
]
}
},
"$schema": "https://raw.githubusercontent.com/Effect-TS/language-service/refs/heads/main/schema.json"
}"
`;

Expand Down Expand Up @@ -685,12 +697,51 @@ exports[`Setup CLI > should remove only LSP plugin while preserving other plugin
}"
`;

exports[`Setup CLI > should replace existing tsconfig schema when adding LSP > change summary 1`] = `
[
{
"description": "Add @effect/language-service@workspace:* to devDependencies",
"file": "package.json",
},
{
"description": "Update $schema in tsconfig; Add plugins array with @effect/language-service plugin",
"file": "tsconfig.json",
},
]
`;

exports[`Setup CLI > should replace existing tsconfig schema when adding LSP > package.json 1`] = `
"{
"name": "test-project",
"version": "1.0.0",
"dependencies": {},
"devDependencies": { "@effect/language-service": "workspace:*" }
}"
`;

exports[`Setup CLI > should replace existing tsconfig schema when adding LSP > tsconfig.json 1`] = `
"{
"$schema": "https://raw.githubusercontent.com/Effect-TS/language-service/refs/heads/main/schema.json",
"compilerOptions": {
"strict": true,
"target": "ES2022",
"plugins": [
{ "name": "@effect/language-service" }
]
}
}"
`;

exports[`Setup CLI > should update LSP version when already installed with older version > change summary 1`] = `
[
{
"description": "Update @effect/language-service from ^0.1.0 to ^0.2.0",
"file": "package.json",
},
{
"description": "Add $schema to tsconfig",
"file": "tsconfig.json",
},
]
`;

Expand All @@ -706,6 +757,21 @@ exports[`Setup CLI > should update LSP version when already installed with older
}"
`;

exports[`Setup CLI > should update LSP version when already installed with older version > tsconfig.json 1`] = `
"{
"compilerOptions": {
"strict": true,
"target": "ES2022",
"plugins": [
{
"name": "@effect/language-service"
}
]
},
"$schema": "https://raw.githubusercontent.com/Effect-TS/language-service/refs/heads/main/schema.json"
}"
`;

exports[`Setup CLI > should update outdated Effect Language Service section in AGENTS.md when enabling LSP > AGENTS.md 1`] = `
"# AGENTS.md

Expand All @@ -730,7 +796,7 @@ exports[`Setup CLI > should update outdated Effect Language Service section in A
"file": "package.json",
},
{
"description": "Add plugins array with @effect/language-service plugin",
"description": "Add $schema to tsconfig; Add plugins array with @effect/language-service plugin",
"file": "tsconfig.json",
},
{
Expand All @@ -757,6 +823,7 @@ exports[`Setup CLI > should update outdated Effect Language Service section in A
"plugins": [
{ "name": "@effect/language-service" }
]
}
},
"$schema": "https://raw.githubusercontent.com/Effect-TS/language-service/refs/heads/main/schema.json"
}"
`;
Loading
Loading