diff --git a/.github/workflows/ci_vscode.yml b/.github/workflows/ci_vscode.yml index a76bbe2ad14b9..fc493e0013d01 100644 --- a/.github/workflows/ci_vscode.yml +++ b/.github/workflows/ci_vscode.yml @@ -94,6 +94,12 @@ jobs: working-directory: editors/vscode run: xvfb-run -a pnpm run test:oxlint && xvfb-run -a pnpm run test:oxlint-multi-root + - name: VSCode oxlint plugin test (flaky) + if: steps.oxlint.outputs.src == 'true' + working-directory: editors/vscode + continue-on-error: true + run: xvfb-run -a pnpm run test:oxlint-js + - name: VSCode oxfmt tests if: steps.oxfmt.outputs.src == 'true' working-directory: editors/vscode diff --git a/editors/vscode/.vscode-test.mjs b/editors/vscode/.vscode-test.mjs index adf0a6069dee6..d0bb184b3ac38 100644 --- a/editors/vscode/.vscode-test.mjs +++ b/editors/vscode/.vscode-test.mjs @@ -59,6 +59,20 @@ const allTestSuites = new Map([ }, }, ], + [ + "oxlint-js", + { + ...baseTest, + workspaceFolder: multiRootWorkspaceFile, + files: "out_test/integration/e2e_server_linter-js.spec.js", + env: { + SINGLE_FOLDER_WORKSPACE: "true", + OXLINT_JS_PLUGIN: "true", + SERVER_PATH_DEV: path.resolve(import.meta.dirname, `../../apps/oxlint/dist/cli.js`), + SKIP_FORMATTER_TEST: "true", + }, + }, + ], [ "oxfmt-lsp", { diff --git a/editors/vscode/package.json b/editors/vscode/package.json index 31eb233b12aca..f1c268d4be270 100644 --- a/editors/vscode/package.json +++ b/editors/vscode/package.json @@ -43,6 +43,7 @@ "test": "cross-env TEST=true pnpm run compile && vscode-test", "test:unit": "cross-env TEST=true pnpm run compile && cross-env TEST_SUITE=unit vscode-test", "test:oxlint": "cross-env TEST=true pnpm run compile && cross-env TEST_SUITE=oxlint-lsp vscode-test", + "test:oxlint-js": "cross-env TEST=true pnpm run compile && cross-env TEST_SUITE=oxlint-js vscode-test", "test:oxlint-multi-root": "cross-env TEST=true pnpm run compile && cross-env TEST_SUITE=oxlint-lsp-multi-root vscode-test", "test:oxfmt": "cross-env TEST=true pnpm run compile && cross-env TEST_SUITE=oxfmt-lsp vscode-test" }, diff --git a/editors/vscode/tests/integration/code_actions.spec.ts b/editors/vscode/tests/integration/code_actions.spec.ts index 8699ddd8955d8..72de8cf7fc689 100644 --- a/editors/vscode/tests/integration/code_actions.spec.ts +++ b/editors/vscode/tests/integration/code_actions.spec.ts @@ -197,6 +197,8 @@ suite("code actions", () => { strictEqual(quickFixesNoFix.length, 0); await workspace.getConfiguration("oxc").update("unusedDisableDirectives", "warn"); await workspace.saveAll(); + await sleep(500); + const codeActionsWithFix: ProviderResult> = await commands.executeCommand( "vscode.executeCodeActionProvider", fileUri, diff --git a/editors/vscode/tests/integration/e2e_server_linter-js.spec.ts b/editors/vscode/tests/integration/e2e_server_linter-js.spec.ts new file mode 100644 index 0000000000000..51384410a5b42 --- /dev/null +++ b/editors/vscode/tests/integration/e2e_server_linter-js.spec.ts @@ -0,0 +1,45 @@ +import { strictEqual } from "assert"; +import { DiagnosticSeverity, workspace } from "vscode"; +import { activateExtension, getDiagnosticsWithoutClose, loadFixture, sleep } from "../test-helpers"; +import assert = require("assert"); + +suiteSetup(async () => { + await activateExtension(); +}); + +teardown(async () => { + await workspace.getConfiguration("oxc").update("fixKind", undefined); + await workspace.getConfiguration("oxc").update("tsConfigPath", undefined); + await workspace.getConfiguration("oxc").update("typeAware", undefined); + await workspace.getConfiguration("oxc").update("fmt.experimental", undefined); + await workspace.getConfiguration("oxc").update("fmt.configPath", undefined); + await workspace.getConfiguration("editor").update("defaultFormatter", undefined); + await workspace.saveAll(); +}); + +suite("E2E Server Linter", () => { + // Skip tests if linter tests are disabled + if (process.env.SKIP_LINTER_TEST === "true") { + return; + } + + test("js plugin support", async () => { + // Flaky test; JS plugin support is a work in progress. + // this test is allowed to fail in CI until then. + // Make sure to run the test in CI multiple times before marking it as fixed. + // Move the test into `e2e_server_linter.spec.ts` once stable. + if (process.env.OXLINT_JS_PLUGIN !== "true") { + return; + } + await loadFixture("js_plugins"); + await sleep(500); + + const diagnostics = await getDiagnosticsWithoutClose("index.js"); + strictEqual(diagnostics.length, 1); + + assert(typeof diagnostics[0].code == "string"); + strictEqual(diagnostics[0].code, "js-plugin(test-rule)"); + strictEqual(diagnostics[0].message, "Custom name JS Plugin Test Rule."); + strictEqual(diagnostics[0].severity, DiagnosticSeverity.Error); + }); +}); diff --git a/editors/vscode/tests/integration/e2e_server_linter.spec.ts b/editors/vscode/tests/integration/e2e_server_linter.spec.ts index 40bc42f9e1a53..38f0cc8ae77db 100644 --- a/editors/vscode/tests/integration/e2e_server_linter.spec.ts +++ b/editors/vscode/tests/integration/e2e_server_linter.spec.ts @@ -343,17 +343,4 @@ suite("E2E Server Linter", () => { await workspace.saveAll(); await sleep(500); }); - - test("js plugin support", async () => { - await loadFixture("js_plugins"); - await sleep(500); - - const diagnostics = await getDiagnosticsWithoutClose("index.js"); - strictEqual(diagnostics.length, 1); - - assert(typeof diagnostics[0].code == "string"); - strictEqual(diagnostics[0].code, "js-plugin(test-rule)"); - strictEqual(diagnostics[0].message, "Custom name JS Plugin Test Rule."); - strictEqual(diagnostics[0].severity, DiagnosticSeverity.Error); - }); });