-
-
Notifications
You must be signed in to change notification settings - Fork 930
fix(vscode): search for oxlint and oxfmt in every workspace directory
#17760
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
graphite-app
merged 1 commit into
main
from
01-07-fix_vscode_search_for_oxlint_and_oxfmt_in_every_workspace_directory
Jan 8, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,153 +1,173 @@ | ||
| import { strictEqual } from 'assert'; | ||
| import { workspace } from 'vscode'; | ||
| import { ConfigService } from '../../client/ConfigService.js'; | ||
| import { WORKSPACE_FOLDER } from '../test-helpers.js'; | ||
| import { strictEqual } from "assert"; | ||
| import { workspace } from "vscode"; | ||
| import { ConfigService } from "../../client/ConfigService.js"; | ||
| import { WORKSPACE_FOLDER, WORKSPACE_SECOND_FOLDER } from "../test-helpers.js"; | ||
|
|
||
| const conf = workspace.getConfiguration('oxc'); | ||
| const conf = workspace.getConfiguration("oxc"); | ||
|
|
||
| suite('ConfigService', () => { | ||
| suite("ConfigService", () => { | ||
| setup(async () => { | ||
| const keys = ['path.server', 'path.oxlint', 'path.oxfmt', 'path.tsgolint']; | ||
| const keys = ["path.server", "path.oxlint", "path.oxfmt", "path.tsgolint"]; | ||
|
|
||
| await Promise.all(keys.map(key => conf.update(key, undefined))); | ||
| await Promise.all(keys.map((key) => conf.update(key, undefined))); | ||
| }); | ||
|
|
||
| teardown(async () => { | ||
| const keys = ['path.server', 'path.oxlint', 'path.oxfmt', 'path.tsgolint']; | ||
| const keys = ["path.server", "path.oxlint", "path.oxfmt", "path.tsgolint"]; | ||
|
|
||
| await Promise.all(keys.map(key => conf.update(key, undefined))); | ||
| await Promise.all(keys.map((key) => conf.update(key, undefined))); | ||
| }); | ||
|
|
||
| const getWorkspaceFolderPlatformSafe = () => { | ||
| let workspace_path = WORKSPACE_FOLDER.uri.path; | ||
| if (process.platform === 'win32') { | ||
| workspace_path = workspace_path.replaceAll('/', '\\'); | ||
| if (workspace_path.startsWith('\\')) { | ||
| const getWorkspaceFolderPlatformSafe = (folder = WORKSPACE_FOLDER) => { | ||
| let workspace_path = folder.uri.path; | ||
| if (process.platform === "win32") { | ||
| workspace_path = workspace_path.replaceAll("/", "\\"); | ||
| if (workspace_path.startsWith("\\")) { | ||
| workspace_path = workspace_path.slice(1); | ||
| } | ||
| } | ||
| return workspace_path; | ||
| }; | ||
|
|
||
| const createWorkspaceFolderFileUri = async (relativePath: string) => { | ||
| const workspace_path = getWorkspaceFolderPlatformSafe(); | ||
| const path = process.platform === 'win32' | ||
| ? `${workspace_path}\\${relativePath}` | ||
| : `${workspace_path}/${relativePath}`; | ||
|
|
||
| await workspace.fs.writeFile( | ||
| WORKSPACE_FOLDER.uri.with({ path }), | ||
| new Uint8Array(), | ||
| ); | ||
| } | ||
|
|
||
| const deleteWorkspaceFolderFileUri = async (relativePath: string) => { | ||
| const workspace_path = getWorkspaceFolderPlatformSafe(); | ||
| const path = process.platform === 'win32' | ||
| ? `${workspace_path}\\${relativePath}` | ||
| : `${workspace_path}/${relativePath}`; | ||
|
|
||
| await workspace.fs.delete( | ||
| WORKSPACE_FOLDER.uri.with({ path }), | ||
| ); | ||
| } | ||
|
|
||
| suite('getOxfmtServerBinPath', () => { | ||
| test('resolves relative server path with workspace folder', async () => { | ||
| const createWorkspaceFolderFileUri = async (relativePath: string, folder = WORKSPACE_FOLDER) => { | ||
| const workspace_path = getWorkspaceFolderPlatformSafe(folder); | ||
| const path = | ||
| process.platform === "win32" | ||
| ? `${workspace_path}\\${relativePath}` | ||
| : `${workspace_path}/${relativePath}`; | ||
|
|
||
| await workspace.fs.writeFile(folder.uri.with({ path }), new Uint8Array()); | ||
| }; | ||
|
|
||
| const deleteWorkspaceFolderFileUri = async (relativePath: string, folder = WORKSPACE_FOLDER) => { | ||
| const workspace_path = getWorkspaceFolderPlatformSafe(folder); | ||
| const path = | ||
| process.platform === "win32" | ||
| ? `${workspace_path}\\${relativePath}` | ||
| : `${workspace_path}/${relativePath}`; | ||
|
|
||
| await workspace.fs.delete(folder.uri.with({ path })); | ||
| }; | ||
Sysix marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| suite("getOxfmtServerBinPath", () => { | ||
| test("resolves relative server path with workspace folder", async () => { | ||
| const service = new ConfigService(); | ||
| const workspace_path = getWorkspaceFolderPlatformSafe(); | ||
| const nonDefinedServerPath = await service.getOxfmtServerBinPath(); | ||
|
|
||
| await createWorkspaceFolderFileUri('absolute/oxfmt'); | ||
| await createWorkspaceFolderFileUri('relative/oxfmt'); | ||
| await createWorkspaceFolderFileUri("absolute/oxfmt"); | ||
| await createWorkspaceFolderFileUri("relative/oxfmt"); | ||
|
|
||
| strictEqual(nonDefinedServerPath, undefined); | ||
|
|
||
| await conf.update('path.oxfmt', `${workspace_path}/absolute/oxfmt`); | ||
| await conf.update("path.oxfmt", `${workspace_path}/absolute/oxfmt`); | ||
| const absoluteServerPath = await service.getOxfmtServerBinPath(); | ||
|
|
||
| strictEqual(absoluteServerPath, `${workspace_path}/absolute/oxfmt`); | ||
|
|
||
| await conf.update('path.oxfmt', './relative/oxfmt'); | ||
| await conf.update("path.oxfmt", "./relative/oxfmt"); | ||
| const relativeServerPath = await service.getOxfmtServerBinPath(); | ||
|
|
||
| strictEqual(relativeServerPath, `${workspace_path}/relative/oxfmt`); | ||
|
|
||
| await deleteWorkspaceFolderFileUri('absolute/oxfmt'); | ||
| await deleteWorkspaceFolderFileUri('relative/oxfmt'); | ||
| await deleteWorkspaceFolderFileUri("absolute/oxfmt"); | ||
| await deleteWorkspaceFolderFileUri("relative/oxfmt"); | ||
| }); | ||
|
|
||
| test('returns undefined for unsafe server path', async () => { | ||
| await createWorkspaceFolderFileUri('../unsafe/oxfmt'); | ||
| test("returns undefined for unsafe server path", async () => { | ||
| await createWorkspaceFolderFileUri("../unsafe/oxfmt"); | ||
| const service = new ConfigService(); | ||
| await conf.update('path.oxfmt', '../unsafe/oxfmt'); | ||
| await conf.update("path.oxfmt", "../unsafe/oxfmt"); | ||
| const unsafeServerPath = await service.getOxfmtServerBinPath(); | ||
|
|
||
| strictEqual(unsafeServerPath, undefined); | ||
| await deleteWorkspaceFolderFileUri('../unsafe/oxfmt'); | ||
| await deleteWorkspaceFolderFileUri("../unsafe/oxfmt"); | ||
| }); | ||
|
|
||
| test('returns backslashes path on Windows', async () => { | ||
| if (process.platform !== 'win32') { | ||
| test("returns backslashes path on Windows", async () => { | ||
| if (process.platform !== "win32") { | ||
| return; | ||
| } | ||
| const service = new ConfigService(); | ||
| await conf.update('path.oxfmt', './relative/oxfmt'); | ||
| await conf.update("path.oxfmt", "./relative/oxfmt"); | ||
| const relativeServerPath = await service.getOxfmtServerBinPath(); | ||
| const workspace_path = getWorkspaceFolderPlatformSafe(); | ||
|
|
||
| strictEqual(workspace_path[1], ':', 'The test workspace folder must be an absolute path with a drive letter on Windows'); | ||
| strictEqual( | ||
| workspace_path[1], | ||
| ":", | ||
| "The test workspace folder must be an absolute path with a drive letter on Windows", | ||
| ); | ||
| strictEqual(relativeServerPath, `${workspace_path}\\relative\\oxfmt`); | ||
| }); | ||
| }); | ||
|
|
||
| suite('getOxlintServerBinPath', () => { | ||
| test('resolves relative server path with workspace folder', async () => { | ||
| suite("getOxlintServerBinPath", () => { | ||
| test("resolves relative server path with workspace folder", async () => { | ||
| const service = new ConfigService(); | ||
| const nonDefinedServerPath = await service.getOxlintServerBinPath(); | ||
| const workspace_path = getWorkspaceFolderPlatformSafe(); | ||
|
|
||
| await createWorkspaceFolderFileUri('absolute/oxlint'); | ||
| await createWorkspaceFolderFileUri('relative/oxlint'); | ||
| await createWorkspaceFolderFileUri("absolute/oxlint"); | ||
| await createWorkspaceFolderFileUri("relative/oxlint"); | ||
|
|
||
| strictEqual(nonDefinedServerPath, undefined); | ||
|
|
||
| await conf.update('path.oxlint', `${workspace_path}/absolute/oxlint`); | ||
| await conf.update("path.oxlint", `${workspace_path}/absolute/oxlint`); | ||
| const absoluteServerPath = await service.getOxlintServerBinPath(); | ||
|
|
||
| strictEqual(absoluteServerPath, `${workspace_path}/absolute/oxlint`); | ||
|
|
||
| await conf.update('path.oxlint', './relative/oxlint'); | ||
| await conf.update("path.oxlint", "./relative/oxlint"); | ||
| const relativeServerPath = await service.getOxlintServerBinPath(); | ||
|
|
||
| strictEqual(relativeServerPath, `${workspace_path}/relative/oxlint`); | ||
|
|
||
|
|
||
| await deleteWorkspaceFolderFileUri('absolute/oxlint'); | ||
| await deleteWorkspaceFolderFileUri('relative/oxlint'); | ||
| await deleteWorkspaceFolderFileUri("absolute/oxlint"); | ||
| await deleteWorkspaceFolderFileUri("relative/oxlint"); | ||
| }); | ||
|
|
||
| test('returns undefined for unsafe server path', async () => { | ||
| await createWorkspaceFolderFileUri('../unsafe/oxlint'); | ||
| test("returns undefined for unsafe server path", async () => { | ||
| await createWorkspaceFolderFileUri("../unsafe/oxlint"); | ||
| const service = new ConfigService(); | ||
| await conf.update('path.oxlint', '../unsafe/oxlint'); | ||
| await conf.update("path.oxlint", "../unsafe/oxlint"); | ||
| const unsafeServerPath = await service.getOxlintServerBinPath(); | ||
|
|
||
| strictEqual(unsafeServerPath, undefined); | ||
| await deleteWorkspaceFolderFileUri('../unsafe/oxlint'); | ||
| await deleteWorkspaceFolderFileUri("../unsafe/oxlint"); | ||
| }); | ||
|
|
||
| test('returns backslashes path on Windows', async () => { | ||
| if (process.platform !== 'win32') { | ||
| test("returns backslashes path on Windows", async () => { | ||
| if (process.platform !== "win32") { | ||
| return; | ||
| } | ||
| const service = new ConfigService(); | ||
| await conf.update('path.oxlint', './relative/oxlint'); | ||
| await conf.update("path.oxlint", "./relative/oxlint"); | ||
| const relativeServerPath = await service.getOxlintServerBinPath(); | ||
| const workspace_path = getWorkspaceFolderPlatformSafe(); | ||
|
|
||
| strictEqual(workspace_path[1], ':', 'The test workspace folder must be an absolute path with a drive letter on Windows'); | ||
| strictEqual( | ||
| workspace_path[1], | ||
| ":", | ||
| "The test workspace folder must be an absolute path with a drive letter on Windows", | ||
| ); | ||
| strictEqual(relativeServerPath, `${workspace_path}\\relative\\oxlint`); | ||
| }); | ||
|
|
||
| // Skipped due to Test API limitation? | ||
| test.skip("resolves binary path in multi-folder workspace", async () => { | ||
| const service = new ConfigService(); | ||
| const workspace_path = getWorkspaceFolderPlatformSafe(); | ||
|
|
||
| await createWorkspaceFolderFileUri("node_modules/.bin/oxlint"); | ||
| await createWorkspaceFolderFileUri("node_modules/.bin/oxlint", WORKSPACE_SECOND_FOLDER); | ||
| const absoluteServerPath = await service.getOxlintServerBinPath(); | ||
|
|
||
| // returns undefined, but it should search with glob and return the first found binary | ||
| strictEqual(absoluteServerPath, `${workspace_path}/node_modules/.bin/oxlint`); | ||
|
|
||
| await deleteWorkspaceFolderFileUri("node_modules/.bin/oxlint"); | ||
| await deleteWorkspaceFolderFileUri("node_modules/.bin/oxlint", WORKSPACE_SECOND_FOLDER); | ||
| }); | ||
| }); | ||
| }); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.