Skip to content

Commit 4d56147

Browse files
committed
chore(vscode): introduce oxc.path.oxlint and deprecate oxc.path.server (#16072)
Preparing to remove the language server binary, renaming the setting. related #15740
1 parent a4b70c3 commit 4d56147

File tree

4 files changed

+35
-16
lines changed

4 files changed

+35
-16
lines changed

editors/vscode/client/ConfigService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export class ConfigService implements IDisposable {
6262
}
6363

6464
public getUserServerBinPath(): string | undefined {
65-
let bin = this.vsCodeConfig.binPath;
65+
let bin = this.vsCodeConfig.binPathOxlint;
6666
if (!bin) {
6767
return;
6868
}

editors/vscode/client/VSCodeConfig.ts

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { ConfigService } from "./ConfigService";
44
export class VSCodeConfig implements VSCodeConfigInterface {
55
private _enable!: boolean;
66
private _trace!: TraceLevel;
7-
private _binPath: string | undefined;
7+
private _binPathOxlint: string | undefined;
88
private _nodePath: string | undefined;
99
private _requireConfig!: boolean;
1010

@@ -17,9 +17,14 @@ export class VSCodeConfig implements VSCodeConfigInterface {
1717
}
1818

1919
public refresh(): void {
20+
let binPathOxlint = this.configuration.get<string>("path.oxlint");
21+
// fallback to deprecated 'path.server' setting
22+
if (!binPathOxlint) {
23+
binPathOxlint = this.configuration.get<string>("path.server");
24+
}
2025
this._enable = this.configuration.get<boolean>("enable") ?? true;
2126
this._trace = this.configuration.get<TraceLevel>("trace.server") || "off";
22-
this._binPath = this.configuration.get<string>("path.server");
27+
this._binPathOxlint = binPathOxlint;
2328
this._nodePath = this.configuration.get<string>("path.node");
2429
this._requireConfig = this.configuration.get<boolean>("requireConfig") ?? false;
2530
}
@@ -42,13 +47,13 @@ export class VSCodeConfig implements VSCodeConfigInterface {
4247
return this.configuration.update("trace.server", value);
4348
}
4449

45-
get binPath(): string | undefined {
46-
return this._binPath;
50+
get binPathOxlint(): string | undefined {
51+
return this._binPathOxlint;
4752
}
4853

49-
updateBinPath(value: string | undefined): PromiseLike<void> {
50-
this._binPath = value;
51-
return this.configuration.update("path.server", value);
54+
updateBinPathOxlint(value: string | undefined): PromiseLike<void> {
55+
this._binPathOxlint = value;
56+
return this.configuration.update("path.oxlint", value);
5257
}
5358

5459
get nodePath(): string | undefined {
@@ -90,11 +95,11 @@ interface VSCodeConfigInterface {
9095
*/
9196
trace: TraceLevel;
9297
/**
93-
* Path to LSP binary
94-
* `oxc.path.server`
98+
* Path to the `oxlint` binary
99+
* `oxc.path.oxlint`
95100
* @default undefined
96101
*/
97-
binPath: string | undefined;
102+
binPathOxlint: string | undefined;
98103

99104
/**
100105
* Path to Node.js

editors/vscode/package.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,14 @@
195195
"oxc.path.server": {
196196
"type": "string",
197197
"scope": "window",
198-
"markdownDescription": "Path to Oxc language server binary. Mostly for testing the language server."
198+
"markdownDescription": "Path to Oxc language server binary. Mostly for testing the language server.",
199+
"deprecated": true,
200+
"markdownDeprecationMessage": "Use `oxc.path.oxlint` instead, targeting the `oxlint` binary."
201+
},
202+
"oxc.path.oxlint": {
203+
"type": "string",
204+
"scope": "window",
205+
"markdownDescription": "Path to an Oxc linter binary. Will be used by the language server instead of the bundled one."
199206
},
200207
"oxc.path.node": {
201208
"type": "string",

editors/vscode/tests/VSCodeConfig.spec.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { testSingleFolderMode } from './test-helpers.js';
66
const conf = workspace.getConfiguration('oxc');
77

88
suite('VSCodeConfig', () => {
9-
const keys = ['enable', 'requireConfig', 'trace.server', 'path.server', 'path.node'];
9+
const keys = ['enable', 'requireConfig', 'trace.server', 'path.server', 'path.oxlint', 'path.node'];
1010
setup(async () => {
1111
await Promise.all(keys.map(key => conf.update(key, undefined)));
1212
});
@@ -21,18 +21,25 @@ suite('VSCodeConfig', () => {
2121
strictEqual(config.enable, true);
2222
strictEqual(config.requireConfig, false);
2323
strictEqual(config.trace, 'off');
24-
strictEqual(config.binPath, '');
24+
strictEqual(config.binPathOxlint, '');
2525
strictEqual(config.nodePath, '');
2626
});
2727

28+
testSingleFolderMode('deprecated values are respected', async () => {
29+
await conf.update('path.server', './deprecatedBinary');
30+
const config = new VSCodeConfig();
31+
32+
strictEqual(config.binPathOxlint, './deprecatedBinary');
33+
});
34+
2835
testSingleFolderMode('updating values updates the workspace configuration', async () => {
2936
const config = new VSCodeConfig();
3037

3138
await Promise.all([
3239
config.updateEnable(false),
3340
config.updateRequireConfig(true),
3441
config.updateTrace('messages'),
35-
config.updateBinPath('./binary'),
42+
config.updateBinPathOxlint('./binary'),
3643
config.updateNodePath('./node'),
3744
]);
3845

@@ -41,7 +48,7 @@ suite('VSCodeConfig', () => {
4148
strictEqual(wsConfig.get('enable'), false);
4249
strictEqual(wsConfig.get('requireConfig'), true);
4350
strictEqual(wsConfig.get('trace.server'), 'messages');
44-
strictEqual(wsConfig.get('path.server'), './binary');
51+
strictEqual(wsConfig.get('path.oxlint'), './binary');
4552
strictEqual(wsConfig.get('path.node'), './node');
4653
});
4754
});

0 commit comments

Comments
 (0)