diff --git a/editors/vscode/client/VSCodeConfig.ts b/editors/vscode/client/VSCodeConfig.ts index 254fe0aee1290..0d9e86c5938c7 100644 --- a/editors/vscode/client/VSCodeConfig.ts +++ b/editors/vscode/client/VSCodeConfig.ts @@ -6,6 +6,7 @@ export class VSCodeConfig implements VSCodeConfigInterface { private _trace!: TraceLevel; private _binPathOxlint: string | undefined; private _binPathOxfmt: string | undefined; + private _binPathTsGoLint: string | undefined; private _nodePath: string | undefined; private _requireConfig!: boolean; @@ -27,6 +28,7 @@ export class VSCodeConfig implements VSCodeConfigInterface { this._trace = this.configuration.get("trace.server") || "off"; this._binPathOxlint = binPathOxlint; this._binPathOxfmt = this.configuration.get("path.oxfmt"); + this._binPathTsGoLint = this.configuration.get("path.tsgolint"); this._nodePath = this.configuration.get("path.node"); this._requireConfig = this.configuration.get("requireConfig") ?? false; } @@ -67,6 +69,15 @@ export class VSCodeConfig implements VSCodeConfigInterface { return this.configuration.update("path.oxfmt", value); } + get binPathTsGoLint(): string | undefined { + return this._binPathTsGoLint; + } + + updateBinPathTsGoLint(value: string | undefined): PromiseLike { + this._binPathTsGoLint = value; + return this.configuration.update("path.tsgolint", value); + } + get nodePath(): string | undefined { return this._nodePath; } @@ -112,6 +123,13 @@ interface VSCodeConfigInterface { */ binPathOxlint: string | undefined; + /** + * Path to the `tsgolint` binary + * `oxc.path.tsgolint` + * @default undefined + */ + binPathTsGoLint: string | undefined; + /** * Path to Node.js * `oxc.path.node` diff --git a/editors/vscode/client/tools/linter.ts b/editors/vscode/client/tools/linter.ts index 8e1b22c9bef51..ef6be819dcd36 100644 --- a/editors/vscode/client/tools/linter.ts +++ b/editors/vscode/client/tools/linter.ts @@ -118,7 +118,11 @@ export default class LinterTool implements ToolInterface { context.subscriptions.push(restartCommand, toggleEnable, applyAllFixesFile); - const run: Executable = runExecutable(binaryPath, configService.vsCodeConfig.nodePath); + const run: Executable = runExecutable( + binaryPath, + configService.vsCodeConfig.nodePath, + configService.vsCodeConfig.binPathTsGoLint, + ); const serverOptions: ServerOptions = { run, debug: run, diff --git a/editors/vscode/client/tools/lsp_helper.ts b/editors/vscode/client/tools/lsp_helper.ts index 7e2539bc6ca6a..ad31ae442715e 100644 --- a/editors/vscode/client/tools/lsp_helper.ts +++ b/editors/vscode/client/tools/lsp_helper.ts @@ -1,7 +1,7 @@ import { LogOutputChannel, window } from "vscode"; import { Executable, MessageType, ShowMessageParams } from "vscode-languageclient/node"; -export function runExecutable(path: string, nodePath?: string): Executable { +export function runExecutable(path: string, nodePath?: string, tsgolintPath?: string): Executable { const serverEnv: Record = { ...process.env, RUST_LOG: process.env.RUST_LOG || "info", @@ -9,6 +9,9 @@ export function runExecutable(path: string, nodePath?: string): Executable { if (nodePath) { serverEnv.PATH = `${nodePath}${process.platform === "win32" ? ";" : ":"}${process.env.PATH ?? ""}`; } + if (tsgolintPath) { + serverEnv.OXLINT_TSGOLINT_PATH = tsgolintPath; + } const isNode = path.endsWith(".js") || path.endsWith(".cjs") || path.endsWith(".mjs"); return isNode diff --git a/editors/vscode/package.json b/editors/vscode/package.json index 42c289e1724fe..63ad303f4d1d4 100644 --- a/editors/vscode/package.json +++ b/editors/vscode/package.json @@ -228,6 +228,11 @@ "scope": "window", "markdownDescription": "Path to an Oxc formatter binary. Will be used by the language server instead of the bundled one." }, + "oxc.path.tsgolint": { + "type": "string", + "scope": "window", + "markdownDescription": "Path to an Oxc tsgolint binary. Will be used by the language server instead of the bundled one." + }, "oxc.path.node": { "type": "string", "scope": "window", diff --git a/editors/vscode/tests/ConfigService.spec.ts b/editors/vscode/tests/ConfigService.spec.ts index 7c3c8f40b0df2..53f960adfacbd 100644 --- a/editors/vscode/tests/ConfigService.spec.ts +++ b/editors/vscode/tests/ConfigService.spec.ts @@ -7,13 +7,13 @@ const conf = workspace.getConfiguration('oxc'); suite('ConfigService', () => { setup(async () => { - const keys = ['path.server', 'path.oxlint', 'path.oxfmt']; + const keys = ['path.server', 'path.oxlint', 'path.oxfmt', 'path.tsgolint']; await Promise.all(keys.map(key => conf.update(key, undefined))); }); teardown(async () => { - const keys = ['path.server', 'path.oxlint', 'path.oxfmt']; + const keys = ['path.server', 'path.oxlint', 'path.oxfmt', 'path.tsgolint']; await Promise.all(keys.map(key => conf.update(key, undefined))); }); diff --git a/editors/vscode/tests/VSCodeConfig.spec.ts b/editors/vscode/tests/VSCodeConfig.spec.ts index 5c9837e6a34f0..a2a567b33218b 100644 --- a/editors/vscode/tests/VSCodeConfig.spec.ts +++ b/editors/vscode/tests/VSCodeConfig.spec.ts @@ -6,7 +6,7 @@ import { testSingleFolderMode } from './test-helpers.js'; const conf = workspace.getConfiguration('oxc'); suite('VSCodeConfig', () => { - const keys = ['enable', 'requireConfig', 'trace.server', 'path.server', 'path.oxlint', 'path.oxfmt', 'path.node']; + const keys = ['enable', 'requireConfig', 'trace.server', 'path.server', 'path.oxlint', 'path.oxfmt', 'path.tsgolint', 'path.node']; setup(async () => { await Promise.all(keys.map(key => conf.update(key, undefined))); }); @@ -23,6 +23,7 @@ suite('VSCodeConfig', () => { strictEqual(config.trace, 'off'); strictEqual(config.binPathOxlint, ''); strictEqual(config.binPathOxfmt, ''); + strictEqual(config.binPathTsGoLint, ''); strictEqual(config.nodePath, ''); }); @@ -42,6 +43,7 @@ suite('VSCodeConfig', () => { config.updateTrace('messages'), config.updateBinPathOxlint('./binary'), config.updateBinPathOxfmt('./formatter'), + config.updateBinPathTsGoLint('./tsgolint'), config.updateNodePath('./node'), ]); @@ -52,6 +54,7 @@ suite('VSCodeConfig', () => { strictEqual(wsConfig.get('trace.server'), 'messages'); strictEqual(wsConfig.get('path.oxlint'), './binary'); strictEqual(wsConfig.get('path.oxfmt'), './formatter'); + strictEqual(wsConfig.get('path.tsgolint'), './tsgolint'); strictEqual(wsConfig.get('path.node'), './node'); }); });