From 2dba1d3adeb80567a2f89517edd1959eb664f350 Mon Sep 17 00:00:00 2001 From: Ian Clanton-Thuon Date: Thu, 25 Jun 2026 19:46:28 -0700 Subject: [PATCH 1/3] Add local-vscode-extension-rig and migrate VS Code extensions to it Switch the VS Code extension projects from the public heft-vscode-extension-rig to a new local-vscode-extension-rig. The new rig no longer enables skipLibCheck, which surfaced several pre-existing declaration-file type errors plus one source bug. rush-vscode-extension: override tsconfig 'types' to ['mocha','node'] so the rig's default Jest globals no longer collide with @types/mocha (TS2403). rush-vscode-command-webview: extract IFromExtensionMessage into a DOM-free module so the Node-based extension can consume it without the DOM-generic MessageEvent (TS2315). playwright-local-browser-server: add lib 'DOM' for playwright-core's DOM-referencing type definitions (TS2304). Also includes eslint --fix import-order and node: protocol cleanups. --- .../rush/nonbrowser-approved-packages.json | 12 ++--- .../config/subspaces/default/pnpm-lock.yaml | 54 +++++++++++++------ rigs/local-vscode-extension-rig/README.md | 6 +++ rigs/local-vscode-extension-rig/package.json | 21 ++++++++ .../default/config/api-extractor-base.json | 5 ++ .../default/config/api-extractor-task.json | 5 ++ .../profiles/default/config/heft.json | 25 +++++++++ .../profiles/default/config/jest.config.json | 3 ++ .../profiles/default/config/rush-project.json | 3 ++ .../profiles/default/config/typescript.json | 5 ++ .../eslint/flat/mixins/friendly-locals.js | 6 +++ .../includes/eslint/flat/mixins/packlets.js | 6 +++ .../includes/eslint/flat/mixins/react.js | 6 +++ .../includes/eslint/flat/mixins/tsdoc.js | 6 +++ .../flat/patch/eslint-bulk-suppressions.js | 4 ++ .../eslint/flat/profile/node-trusted-tool.js | 6 +++ .../includes/eslint/flat/profile/node.js | 6 +++ .../profiles/default/tsconfig-base.json | 4 ++ .../profiles/default/webpack.config.base.js | 1 + rush.json | 6 +++ .../config/heft.json | 2 +- .../config/rig.json | 2 +- .../config/rush-project.json | 2 +- .../eslint.config.js | 4 +- .../package.json | 4 +- .../src/certificates.ts | 3 +- .../src/config.ts | 8 +-- .../src/constants.ts | 1 + .../src/extension.ts | 8 +-- .../tsconfig.json | 2 +- .../webpack.config.js | 9 ++-- .../config/heft.json | 2 +- .../config/rig.json | 2 +- .../config/rush-project.json | 2 +- .../eslint.config.js | 4 +- .../package.json | 4 +- .../src/extension.ts | 7 ++- .../src/utils/getNormalizedErrorString.ts | 3 ++ .../tsconfig.json | 7 ++- .../webpack.config.js | 7 +-- .../src/Message/IFromExtensionMessage.ts | 17 ++++++ .../src/Message/fromExtension.ts | 10 +--- .../rush-vscode-command-webview/src/index.ts | 2 +- .../rush-vscode-extension/config/heft.json | 2 +- .../rush-vscode-extension/config/rig.json | 2 +- .../config/rush-project.json | 2 +- .../rush-vscode-extension/eslint.config.js | 4 +- .../rush-vscode-extension/package.json | 5 +- .../rush-vscode-extension/src/extension.ts | 1 + .../src/logic/RushCommandWebViewPanel.ts | 5 +- .../src/logic/RushWorkspace.ts | 6 +-- .../src/providers/RushCommandsProvider.ts | 5 +- .../src/providers/RushProjectsProvider.ts | 8 +-- .../src/providers/TaskProvider.ts | 1 + .../rush-vscode-extension/src/test/runTest.ts | 10 ++-- .../src/test/suite/extension.test.ts | 2 +- .../src/test/suite/index.ts | 36 +++---------- .../rush-vscode-extension/tsconfig.json | 7 ++- .../rush-vscode-extension/webpack.config.js | 9 ++-- 59 files changed, 279 insertions(+), 128 deletions(-) create mode 100644 rigs/local-vscode-extension-rig/README.md create mode 100644 rigs/local-vscode-extension-rig/package.json create mode 100644 rigs/local-vscode-extension-rig/profiles/default/config/api-extractor-base.json create mode 100644 rigs/local-vscode-extension-rig/profiles/default/config/api-extractor-task.json create mode 100644 rigs/local-vscode-extension-rig/profiles/default/config/heft.json create mode 100644 rigs/local-vscode-extension-rig/profiles/default/config/jest.config.json create mode 100644 rigs/local-vscode-extension-rig/profiles/default/config/rush-project.json create mode 100644 rigs/local-vscode-extension-rig/profiles/default/config/typescript.json create mode 100644 rigs/local-vscode-extension-rig/profiles/default/includes/eslint/flat/mixins/friendly-locals.js create mode 100644 rigs/local-vscode-extension-rig/profiles/default/includes/eslint/flat/mixins/packlets.js create mode 100644 rigs/local-vscode-extension-rig/profiles/default/includes/eslint/flat/mixins/react.js create mode 100644 rigs/local-vscode-extension-rig/profiles/default/includes/eslint/flat/mixins/tsdoc.js create mode 100644 rigs/local-vscode-extension-rig/profiles/default/includes/eslint/flat/patch/eslint-bulk-suppressions.js create mode 100644 rigs/local-vscode-extension-rig/profiles/default/includes/eslint/flat/profile/node-trusted-tool.js create mode 100644 rigs/local-vscode-extension-rig/profiles/default/includes/eslint/flat/profile/node.js create mode 100644 rigs/local-vscode-extension-rig/profiles/default/tsconfig-base.json create mode 100644 rigs/local-vscode-extension-rig/profiles/default/webpack.config.base.js create mode 100644 vscode-extensions/rush-vscode-command-webview/src/Message/IFromExtensionMessage.ts diff --git a/common/config/rush/nonbrowser-approved-packages.json b/common/config/rush/nonbrowser-approved-packages.json index e507208c2f3..c955a2cfe8f 100644 --- a/common/config/rush/nonbrowser-approved-packages.json +++ b/common/config/rush/nonbrowser-approved-packages.json @@ -276,7 +276,7 @@ }, { "name": "@rushstack/heft-vscode-extension-rig", - "allowedCategories": [ "vscode-extensions" ] + "allowedCategories": [ "libraries" ] }, { "name": "@rushstack/heft-web-rig", @@ -700,7 +700,7 @@ }, { "name": "fast-glob", - "allowedCategories": [ "libraries" ] + "allowedCategories": [ "libraries", "vscode-extensions" ] }, { "name": "fastify", @@ -718,10 +718,6 @@ "name": "git-repo-info", "allowedCategories": [ "libraries" ] }, - { - "name": "glob", - "allowedCategories": [ "libraries", "vscode-extensions" ] - }, { "name": "heft-action-plugin", "allowedCategories": [ "tests" ] @@ -862,6 +858,10 @@ "name": "local-node-rig", "allowedCategories": [ "libraries", "tests", "vscode-extensions" ] }, + { + "name": "local-vscode-extension-rig", + "allowedCategories": [ "vscode-extensions" ] + }, { "name": "local-web-rig", "allowedCategories": [ "libraries", "tests", "vscode-extensions" ] diff --git a/common/config/subspaces/default/pnpm-lock.yaml b/common/config/subspaces/default/pnpm-lock.yaml index c7f7ad87712..208aa94611a 100644 --- a/common/config/subspaces/default/pnpm-lock.yaml +++ b/common/config/subspaces/default/pnpm-lock.yaml @@ -4819,6 +4819,33 @@ importers: specifier: ~5.8.2 version: 5.8.2 + ../../../rigs/local-vscode-extension-rig: + dependencies: + '@rushstack/heft': + specifier: workspace:* + version: link:../../apps/heft + '@rushstack/heft-vscode-extension-plugin': + specifier: workspace:* + version: link:../../heft-plugins/heft-vscode-extension-plugin + '@rushstack/heft-vscode-extension-rig': + specifier: workspace:* + version: link:../heft-vscode-extension-rig + '@rushstack/webpack-preserve-dynamic-require-plugin': + specifier: workspace:* + version: link:../../webpack/preserve-dynamic-require-plugin + eslint: + specifier: ~9.37.0 + version: 9.37.0 + local-eslint-config: + specifier: workspace:* + version: link:../../eslint/local-eslint-config + local-node-rig: + specifier: workspace:* + version: link:../local-node-rig + typescript: + specifier: ~5.8.2 + version: 5.8.2 + ../../../rigs/local-web-rig: dependencies: '@microsoft/api-extractor': @@ -5211,9 +5238,6 @@ importers: '@rushstack/heft': specifier: workspace:* version: link:../../apps/heft - '@rushstack/heft-vscode-extension-rig': - specifier: workspace:* - version: link:../../rigs/heft-vscode-extension-rig '@types/node': specifier: 20.17.19 version: 20.17.19 @@ -5223,6 +5247,9 @@ importers: '@types/webpack-env': specifier: 1.18.8 version: 1.18.8 + local-vscode-extension-rig: + specifier: workspace:* + version: link:../../rigs/local-vscode-extension-rig ../../../vscode-extensions/playwright-local-browser-server-vscode-extension: dependencies: @@ -5251,9 +5278,6 @@ importers: '@rushstack/heft-node-rig': specifier: workspace:* version: link:../../rigs/heft-node-rig - '@rushstack/heft-vscode-extension-rig': - specifier: workspace:* - version: link:../../rigs/heft-vscode-extension-rig '@types/node': specifier: 20.17.19 version: 20.17.19 @@ -5263,6 +5287,9 @@ importers: '@types/webpack-env': specifier: 1.18.8 version: 1.18.8 + local-vscode-extension-rig: + specifier: workspace:* + version: link:../../rigs/local-vscode-extension-rig ../../../vscode-extensions/rush-vscode-command-webview: dependencies: @@ -5352,12 +5379,6 @@ importers: '@rushstack/heft': specifier: workspace:* version: link:../../apps/heft - '@rushstack/heft-vscode-extension-rig': - specifier: workspace:* - version: link:../../rigs/heft-vscode-extension-rig - '@types/glob': - specifier: 7.1.1 - version: 7.1.1 '@types/mocha': specifier: 10.0.6 version: 10.0.6 @@ -5373,9 +5394,12 @@ importers: eslint: specifier: ~9.37.0 version: 9.37.0 - glob: - specifier: ~7.0.5 - version: 7.0.6 + fast-glob: + specifier: ~3.3.1 + version: 3.3.3 + local-vscode-extension-rig: + specifier: workspace:* + version: link:../../rigs/local-vscode-extension-rig mocha: specifier: ^10.1.0 version: 10.8.2 diff --git a/rigs/local-vscode-extension-rig/README.md b/rigs/local-vscode-extension-rig/README.md new file mode 100644 index 00000000000..8f258ce8cf3 --- /dev/null +++ b/rigs/local-vscode-extension-rig/README.md @@ -0,0 +1,6 @@ +# local-vscode-extension-rig + +A rig package for VSCode Extension projects that build using Heft inside the RushStack repository. This +package extends `local-node-rig` and adds some options that are specific to VScode extensions. + +Note that this rig is not published to the NPM registry. \ No newline at end of file diff --git a/rigs/local-vscode-extension-rig/package.json b/rigs/local-vscode-extension-rig/package.json new file mode 100644 index 00000000000..cdbc415a624 --- /dev/null +++ b/rigs/local-vscode-extension-rig/package.json @@ -0,0 +1,21 @@ +{ + "name": "local-vscode-extension-rig", + "version": "1.0.0", + "description": "A rig package for VSCode extension projects that build using Heft inside the RushStack repository.", + "license": "MIT", + "private": true, + "scripts": { + "build": "", + "_phase:build": "" + }, + "dependencies": { + "@rushstack/heft-vscode-extension-plugin": "workspace:*", + "@rushstack/heft-vscode-extension-rig": "workspace:*", + "@rushstack/heft": "workspace:*", + "@rushstack/webpack-preserve-dynamic-require-plugin": "workspace:*", + "eslint": "~9.37.0", + "local-eslint-config": "workspace:*", + "local-node-rig": "workspace:*", + "typescript": "~5.8.2" + } +} diff --git a/rigs/local-vscode-extension-rig/profiles/default/config/api-extractor-base.json b/rigs/local-vscode-extension-rig/profiles/default/config/api-extractor-base.json new file mode 100644 index 00000000000..7830fa6ca2b --- /dev/null +++ b/rigs/local-vscode-extension-rig/profiles/default/config/api-extractor-base.json @@ -0,0 +1,5 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", + + "extends": "local-node-rig/profiles/default/config/api-extractor-base.json" +} diff --git a/rigs/local-vscode-extension-rig/profiles/default/config/api-extractor-task.json b/rigs/local-vscode-extension-rig/profiles/default/config/api-extractor-task.json new file mode 100644 index 00000000000..b062efb5d86 --- /dev/null +++ b/rigs/local-vscode-extension-rig/profiles/default/config/api-extractor-task.json @@ -0,0 +1,5 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/heft/v0/api-extractor-task.schema.json", + + "extends": "local-node-rig/profiles/default/config/api-extractor-task.json" +} diff --git a/rigs/local-vscode-extension-rig/profiles/default/config/heft.json b/rigs/local-vscode-extension-rig/profiles/default/config/heft.json new file mode 100644 index 00000000000..c328d4c1c57 --- /dev/null +++ b/rigs/local-vscode-extension-rig/profiles/default/config/heft.json @@ -0,0 +1,25 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/heft/v0/heft.schema.json", + + "extends": "@rushstack/heft-vscode-extension-rig/profiles/default/config/heft.json", + + "phasesByName": { + "build": { + "cleanFiles": [{ "includeGlobs": ["lib-esnext"] }], + + "tasksByName": { + "lint": { + "taskPlugin": { + "options": { + "sarifLogPath": "temp/build/lint/lint.sarif" + } + } + } + } + }, + + "test": { + "cleanFiles": [{ "includeGlobs": ["coverage"] }] + } + } +} diff --git a/rigs/local-vscode-extension-rig/profiles/default/config/jest.config.json b/rigs/local-vscode-extension-rig/profiles/default/config/jest.config.json new file mode 100644 index 00000000000..d1749681d90 --- /dev/null +++ b/rigs/local-vscode-extension-rig/profiles/default/config/jest.config.json @@ -0,0 +1,3 @@ +{ + "extends": "local-node-rig/profiles/default/config/jest.config.json" +} diff --git a/rigs/local-vscode-extension-rig/profiles/default/config/rush-project.json b/rigs/local-vscode-extension-rig/profiles/default/config/rush-project.json new file mode 100644 index 00000000000..924e18197e1 --- /dev/null +++ b/rigs/local-vscode-extension-rig/profiles/default/config/rush-project.json @@ -0,0 +1,3 @@ +{ + "extends": "local-node-rig/profiles/default/config/rush-project.json" +} diff --git a/rigs/local-vscode-extension-rig/profiles/default/config/typescript.json b/rigs/local-vscode-extension-rig/profiles/default/config/typescript.json new file mode 100644 index 00000000000..477c135633e --- /dev/null +++ b/rigs/local-vscode-extension-rig/profiles/default/config/typescript.json @@ -0,0 +1,5 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/heft/v0/typescript.schema.json", + + "extends": "local-node-rig/profiles/default/config/typescript.json" +} diff --git a/rigs/local-vscode-extension-rig/profiles/default/includes/eslint/flat/mixins/friendly-locals.js b/rigs/local-vscode-extension-rig/profiles/default/includes/eslint/flat/mixins/friendly-locals.js new file mode 100644 index 00000000000..fa55581f566 --- /dev/null +++ b/rigs/local-vscode-extension-rig/profiles/default/includes/eslint/flat/mixins/friendly-locals.js @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +const friendlyLocalsMixin = require('local-eslint-config/flat/mixins/friendly-locals'); + +module.exports = [...friendlyLocalsMixin]; diff --git a/rigs/local-vscode-extension-rig/profiles/default/includes/eslint/flat/mixins/packlets.js b/rigs/local-vscode-extension-rig/profiles/default/includes/eslint/flat/mixins/packlets.js new file mode 100644 index 00000000000..4291377cb4d --- /dev/null +++ b/rigs/local-vscode-extension-rig/profiles/default/includes/eslint/flat/mixins/packlets.js @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +const packletsMixin = require('local-eslint-config/flat/mixins/packlets'); + +module.exports = [...packletsMixin]; diff --git a/rigs/local-vscode-extension-rig/profiles/default/includes/eslint/flat/mixins/react.js b/rigs/local-vscode-extension-rig/profiles/default/includes/eslint/flat/mixins/react.js new file mode 100644 index 00000000000..e8ce9b16050 --- /dev/null +++ b/rigs/local-vscode-extension-rig/profiles/default/includes/eslint/flat/mixins/react.js @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +const reactMixin = require('local-eslint-config/flat/mixins/react'); + +module.exports = [...reactMixin]; diff --git a/rigs/local-vscode-extension-rig/profiles/default/includes/eslint/flat/mixins/tsdoc.js b/rigs/local-vscode-extension-rig/profiles/default/includes/eslint/flat/mixins/tsdoc.js new file mode 100644 index 00000000000..e5cb903f6cd --- /dev/null +++ b/rigs/local-vscode-extension-rig/profiles/default/includes/eslint/flat/mixins/tsdoc.js @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +const tsdocMixin = require('local-eslint-config/flat/mixins/tsdoc'); + +module.exports = [...tsdocMixin]; diff --git a/rigs/local-vscode-extension-rig/profiles/default/includes/eslint/flat/patch/eslint-bulk-suppressions.js b/rigs/local-vscode-extension-rig/profiles/default/includes/eslint/flat/patch/eslint-bulk-suppressions.js new file mode 100644 index 00000000000..12c37b253da --- /dev/null +++ b/rigs/local-vscode-extension-rig/profiles/default/includes/eslint/flat/patch/eslint-bulk-suppressions.js @@ -0,0 +1,4 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +require('@rushstack/eslint-patch/eslint-bulk-suppressions'); diff --git a/rigs/local-vscode-extension-rig/profiles/default/includes/eslint/flat/profile/node-trusted-tool.js b/rigs/local-vscode-extension-rig/profiles/default/includes/eslint/flat/profile/node-trusted-tool.js new file mode 100644 index 00000000000..aa7fc56fae1 --- /dev/null +++ b/rigs/local-vscode-extension-rig/profiles/default/includes/eslint/flat/profile/node-trusted-tool.js @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +const nodeTrustedToolProfile = require('local-eslint-config/flat/profile/node-trusted-tool'); + +module.exports = [...nodeTrustedToolProfile]; diff --git a/rigs/local-vscode-extension-rig/profiles/default/includes/eslint/flat/profile/node.js b/rigs/local-vscode-extension-rig/profiles/default/includes/eslint/flat/profile/node.js new file mode 100644 index 00000000000..753ef86ecb6 --- /dev/null +++ b/rigs/local-vscode-extension-rig/profiles/default/includes/eslint/flat/profile/node.js @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +const nodeProfile = require('local-eslint-config/flat/profile/node'); + +module.exports = [...nodeProfile]; diff --git a/rigs/local-vscode-extension-rig/profiles/default/tsconfig-base.json b/rigs/local-vscode-extension-rig/profiles/default/tsconfig-base.json new file mode 100644 index 00000000000..77368467e50 --- /dev/null +++ b/rigs/local-vscode-extension-rig/profiles/default/tsconfig-base.json @@ -0,0 +1,4 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "../../node_modules/local-node-rig/profiles/default/tsconfig-base.json" +} diff --git a/rigs/local-vscode-extension-rig/profiles/default/webpack.config.base.js b/rigs/local-vscode-extension-rig/profiles/default/webpack.config.base.js new file mode 100644 index 00000000000..b190dcd4dbe --- /dev/null +++ b/rigs/local-vscode-extension-rig/profiles/default/webpack.config.base.js @@ -0,0 +1 @@ +module.exports = require('@rushstack/heft-vscode-extension-rig/profiles/default/webpack.config.base'); diff --git a/rush.json b/rush.json index ec010e2b515..d1df5813422 100644 --- a/rush.json +++ b/rush.json @@ -1413,6 +1413,12 @@ "reviewCategory": "libraries", "shouldPublish": false }, + { + "packageName": "local-vscode-extension-rig", + "projectFolder": "rigs/local-vscode-extension-rig", + "reviewCategory": "libraries", + "shouldPublish": false + }, { "packageName": "local-web-rig", "projectFolder": "rigs/local-web-rig", diff --git a/vscode-extensions/debug-certificate-manager-vscode-extension/config/heft.json b/vscode-extensions/debug-certificate-manager-vscode-extension/config/heft.json index 7def96a81f3..f4216364205 100644 --- a/vscode-extensions/debug-certificate-manager-vscode-extension/config/heft.json +++ b/vscode-extensions/debug-certificate-manager-vscode-extension/config/heft.json @@ -1,7 +1,7 @@ { "$schema": "https://developer.microsoft.com/json-schemas/heft/v0/heft.schema.json", - "extends": "@rushstack/heft-vscode-extension-rig/profiles/default/config/heft.json", + "extends": "local-vscode-extension-rig/profiles/default/config/heft.json", "phasesByName": { "build": { diff --git a/vscode-extensions/debug-certificate-manager-vscode-extension/config/rig.json b/vscode-extensions/debug-certificate-manager-vscode-extension/config/rig.json index ec33a848348..1a7ec21fb70 100644 --- a/vscode-extensions/debug-certificate-manager-vscode-extension/config/rig.json +++ b/vscode-extensions/debug-certificate-manager-vscode-extension/config/rig.json @@ -1,5 +1,5 @@ { "$schema": "https://developer.microsoft.com/json-schemas/rig-package/rig.schema.json", - "rigPackageName": "@rushstack/heft-vscode-extension-rig" + "rigPackageName": "local-vscode-extension-rig" } diff --git a/vscode-extensions/debug-certificate-manager-vscode-extension/config/rush-project.json b/vscode-extensions/debug-certificate-manager-vscode-extension/config/rush-project.json index b2453d544bc..4396c1324ec 100644 --- a/vscode-extensions/debug-certificate-manager-vscode-extension/config/rush-project.json +++ b/vscode-extensions/debug-certificate-manager-vscode-extension/config/rush-project.json @@ -1,4 +1,4 @@ { "$schema": "https://developer.microsoft.com/json-schemas/rush/v5/rush-project.schema.json", - "extends": "@rushstack/heft-vscode-extension-rig/profiles/default/config/rush-project.json" + "extends": "local-vscode-extension-rig/profiles/default/config/rush-project.json" } diff --git a/vscode-extensions/debug-certificate-manager-vscode-extension/eslint.config.js b/vscode-extensions/debug-certificate-manager-vscode-extension/eslint.config.js index eac79367926..b97a237b568 100644 --- a/vscode-extensions/debug-certificate-manager-vscode-extension/eslint.config.js +++ b/vscode-extensions/debug-certificate-manager-vscode-extension/eslint.config.js @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. // See LICENSE in the project root for license information. -const nodeTrustedToolProfile = require('@rushstack/heft-vscode-extension-rig/profiles/default/includes/eslint/flat/profile/node-trusted-tool'); -const friendlyLocalsMixin = require('@rushstack/heft-vscode-extension-rig/profiles/default/includes/eslint/flat/mixins/friendly-locals'); +const nodeTrustedToolProfile = require('local-vscode-extension-rig/profiles/default/includes/eslint/flat/profile/node-trusted-tool'); +const friendlyLocalsMixin = require('local-vscode-extension-rig/profiles/default/includes/eslint/flat/mixins/friendly-locals'); module.exports = [...nodeTrustedToolProfile, ...friendlyLocalsMixin]; diff --git a/vscode-extensions/debug-certificate-manager-vscode-extension/package.json b/vscode-extensions/debug-certificate-manager-vscode-extension/package.json index aa5924cbaaa..11d8e7b137c 100644 --- a/vscode-extensions/debug-certificate-manager-vscode-extension/package.json +++ b/vscode-extensions/debug-certificate-manager-vscode-extension/package.json @@ -122,11 +122,11 @@ "tslib": "~2.8.1" }, "devDependencies": { - "@rushstack/heft-vscode-extension-rig": "workspace:*", "@rushstack/heft": "workspace:*", "@types/node": "20.17.19", "@types/vscode": "1.103.0", - "@types/webpack-env": "1.18.8" + "@types/webpack-env": "1.18.8", + "local-vscode-extension-rig": "workspace:*" }, "sideEffects": false } diff --git a/vscode-extensions/debug-certificate-manager-vscode-extension/src/certificates.ts b/vscode-extensions/debug-certificate-manager-vscode-extension/src/certificates.ts index b918be65368..03bb42618ce 100644 --- a/vscode-extensions/debug-certificate-manager-vscode-extension/src/certificates.ts +++ b/vscode-extensions/debug-certificate-manager-vscode-extension/src/certificates.ts @@ -1,10 +1,11 @@ // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. // See LICENSE in the project root for license information. -import { getConfig } from './config'; import { CertificateManager, CertificateStore } from '@rushstack/debug-certificate-manager'; import type { ITerminal } from '@rushstack/terminal'; +import { getConfig } from './config'; + export function getCertificateManager(terminal: ITerminal): CertificateManager { const { caCertificateFilename, keyFilename, certificateFilename, storePath } = getConfig(terminal); const certificateManager: CertificateManager = new CertificateManager({ diff --git a/vscode-extensions/debug-certificate-manager-vscode-extension/src/config.ts b/vscode-extensions/debug-certificate-manager-vscode-extension/src/config.ts index e0723471b50..b3f64ea39be 100644 --- a/vscode-extensions/debug-certificate-manager-vscode-extension/src/config.ts +++ b/vscode-extensions/debug-certificate-manager-vscode-extension/src/config.ts @@ -1,10 +1,13 @@ // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. // See LICENSE in the project root for license information. -import * as vscode from 'vscode'; import * as path from 'node:path'; + +import * as vscode from 'vscode'; + import type { ITerminal } from '@rushstack/terminal'; import type { ICertificateStoreOptions } from '@rushstack/debug-certificate-manager'; + import { CONFIG_AUTOSYNC, CONFIG_SECTION, @@ -29,8 +32,7 @@ export function getConfig(terminal: ITerminal): IExtensionConfig { config.get(CONFIG_CERTIFICATE_FILENAME) || 'rushstack-serve.pem'; const keyFilename: string | undefined = config.get(CONFIG_KEY_FILENAME) || 'rushstack-serve.key'; const autoSync: boolean = config.get(CONFIG_AUTOSYNC) ?? false; - const homeDirectory: string | undefined = - config.get(CONFIG_HOME_DIRECTORY) || undefined; + const homeDirectory: string | undefined = config.get(CONFIG_HOME_DIRECTORY) || undefined; let storePath: string | undefined = undefined; const platformMap: Record = { diff --git a/vscode-extensions/debug-certificate-manager-vscode-extension/src/constants.ts b/vscode-extensions/debug-certificate-manager-vscode-extension/src/constants.ts index e0a725e1fd8..0c79d27d425 100644 --- a/vscode-extensions/debug-certificate-manager-vscode-extension/src/constants.ts +++ b/vscode-extensions/debug-certificate-manager-vscode-extension/src/constants.ts @@ -1,5 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. // See LICENSE in the project root for license information. + import packageJson from '../package.json'; export const EXTENSION_DISPLAY_NAME: string = 'Debug Certificate Manager'; diff --git a/vscode-extensions/debug-certificate-manager-vscode-extension/src/extension.ts b/vscode-extensions/debug-certificate-manager-vscode-extension/src/extension.ts index 90b436a69c3..69f0111517c 100644 --- a/vscode-extensions/debug-certificate-manager-vscode-extension/src/extension.ts +++ b/vscode-extensions/debug-certificate-manager-vscode-extension/src/extension.ts @@ -5,15 +5,15 @@ import * as vscode from 'vscode'; import { Async } from '@rushstack/node-core-library/lib/Async'; import { Terminal } from '@rushstack/terminal'; -import { +import type { CertificateManager, ICertificateStoreOptions, ICertificateValidationResult, - type ICertificate + ICertificate } from '@rushstack/debug-certificate-manager'; - import { runWorkspaceCommandAsync } from '@rushstack/vscode-shared/lib/runWorkspaceCommandAsync'; import { VScodeOutputChannelTerminalProvider } from '@rushstack/vscode-shared/lib/VScodeOutputChannelTerminalProvider'; + import { getCertificateManager } from './certificates'; import { getConfig } from './config'; import { @@ -229,7 +229,7 @@ export function activate(context: vscode.ExtensionContext): void { throw new Error('Failed to parse home directory from command output'); } } else { - homeDir = require('os').homedir(); + homeDir = require('node:os').homedir(); } terminal.writeLine(`Resolved home directory: ${homeDir}`); diff --git a/vscode-extensions/debug-certificate-manager-vscode-extension/tsconfig.json b/vscode-extensions/debug-certificate-manager-vscode-extension/tsconfig.json index 09607819d38..b0a334bf680 100644 --- a/vscode-extensions/debug-certificate-manager-vscode-extension/tsconfig.json +++ b/vscode-extensions/debug-certificate-manager-vscode-extension/tsconfig.json @@ -1,4 +1,4 @@ { "$schema": "http://json.schemastore.org/tsconfig", - "extends": "./node_modules/@rushstack/heft-vscode-extension-rig/profiles/default/tsconfig-base.json" + "extends": "./node_modules/local-vscode-extension-rig/profiles/default/tsconfig-base.json" } diff --git a/vscode-extensions/debug-certificate-manager-vscode-extension/webpack.config.js b/vscode-extensions/debug-certificate-manager-vscode-extension/webpack.config.js index c12db6ac9df..80f54a68bb5 100644 --- a/vscode-extensions/debug-certificate-manager-vscode-extension/webpack.config.js +++ b/vscode-extensions/debug-certificate-manager-vscode-extension/webpack.config.js @@ -3,19 +3,16 @@ 'use strict'; -const { - createExtensionConfig -} = require('@rushstack/heft-vscode-extension-rig/profiles/default/webpack.config.base'); -const path = require('node:path'); +const { createExtensionConfig } = require('local-vscode-extension-rig/profiles/default/webpack.config.base'); function createConfig({ production, webpack }) { const config = createExtensionConfig({ production: false, webpack, entry: { - extension: './lib/extension.js' + extension: './lib-esm/extension.js' }, - outputPath: path.resolve(__dirname, 'dist', 'vsix', 'unpacked') + outputPath: `${__dirname}/dist/vsix/unpacked` }); return config; } diff --git a/vscode-extensions/playwright-local-browser-server-vscode-extension/config/heft.json b/vscode-extensions/playwright-local-browser-server-vscode-extension/config/heft.json index 77eedd9bac4..1e9d56bd467 100644 --- a/vscode-extensions/playwright-local-browser-server-vscode-extension/config/heft.json +++ b/vscode-extensions/playwright-local-browser-server-vscode-extension/config/heft.json @@ -1,4 +1,4 @@ { "$schema": "https://developer.microsoft.com/json-schemas/heft/v0/heft.schema.json", - "extends": "@rushstack/heft-vscode-extension-rig/profiles/default/config/heft.json" + "extends": "local-vscode-extension-rig/profiles/default/config/heft.json" } diff --git a/vscode-extensions/playwright-local-browser-server-vscode-extension/config/rig.json b/vscode-extensions/playwright-local-browser-server-vscode-extension/config/rig.json index ec33a848348..1a7ec21fb70 100644 --- a/vscode-extensions/playwright-local-browser-server-vscode-extension/config/rig.json +++ b/vscode-extensions/playwright-local-browser-server-vscode-extension/config/rig.json @@ -1,5 +1,5 @@ { "$schema": "https://developer.microsoft.com/json-schemas/rig-package/rig.schema.json", - "rigPackageName": "@rushstack/heft-vscode-extension-rig" + "rigPackageName": "local-vscode-extension-rig" } diff --git a/vscode-extensions/playwright-local-browser-server-vscode-extension/config/rush-project.json b/vscode-extensions/playwright-local-browser-server-vscode-extension/config/rush-project.json index b2453d544bc..4396c1324ec 100644 --- a/vscode-extensions/playwright-local-browser-server-vscode-extension/config/rush-project.json +++ b/vscode-extensions/playwright-local-browser-server-vscode-extension/config/rush-project.json @@ -1,4 +1,4 @@ { "$schema": "https://developer.microsoft.com/json-schemas/rush/v5/rush-project.schema.json", - "extends": "@rushstack/heft-vscode-extension-rig/profiles/default/config/rush-project.json" + "extends": "local-vscode-extension-rig/profiles/default/config/rush-project.json" } diff --git a/vscode-extensions/playwright-local-browser-server-vscode-extension/eslint.config.js b/vscode-extensions/playwright-local-browser-server-vscode-extension/eslint.config.js index eac79367926..b97a237b568 100644 --- a/vscode-extensions/playwright-local-browser-server-vscode-extension/eslint.config.js +++ b/vscode-extensions/playwright-local-browser-server-vscode-extension/eslint.config.js @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. // See LICENSE in the project root for license information. -const nodeTrustedToolProfile = require('@rushstack/heft-vscode-extension-rig/profiles/default/includes/eslint/flat/profile/node-trusted-tool'); -const friendlyLocalsMixin = require('@rushstack/heft-vscode-extension-rig/profiles/default/includes/eslint/flat/mixins/friendly-locals'); +const nodeTrustedToolProfile = require('local-vscode-extension-rig/profiles/default/includes/eslint/flat/profile/node-trusted-tool'); +const friendlyLocalsMixin = require('local-vscode-extension-rig/profiles/default/includes/eslint/flat/mixins/friendly-locals'); module.exports = [...nodeTrustedToolProfile, ...friendlyLocalsMixin]; diff --git a/vscode-extensions/playwright-local-browser-server-vscode-extension/package.json b/vscode-extensions/playwright-local-browser-server-vscode-extension/package.json index 4afa8c79323..892aa008826 100644 --- a/vscode-extensions/playwright-local-browser-server-vscode-extension/package.json +++ b/vscode-extensions/playwright-local-browser-server-vscode-extension/package.json @@ -103,12 +103,12 @@ "tslib": "~2.8.1" }, "devDependencies": { - "@rushstack/heft-vscode-extension-rig": "workspace:*", "@rushstack/heft-node-rig": "workspace:*", "@rushstack/heft": "workspace:*", "@types/node": "20.17.19", "@types/vscode": "1.103.0", - "@types/webpack-env": "1.18.8" + "@types/webpack-env": "1.18.8", + "local-vscode-extension-rig": "workspace:*" }, "sideEffects": false } diff --git a/vscode-extensions/playwright-local-browser-server-vscode-extension/src/extension.ts b/vscode-extensions/playwright-local-browser-server-vscode-extension/src/extension.ts index 6701d15d097..214c9b60920 100644 --- a/vscode-extensions/playwright-local-browser-server-vscode-extension/src/extension.ts +++ b/vscode-extensions/playwright-local-browser-server-vscode-extension/src/extension.ts @@ -3,6 +3,7 @@ import * as os from 'node:os'; import * as path from 'node:path'; + import * as vscode from 'vscode'; import type { @@ -11,19 +12,16 @@ import type { ILaunchOptionsAllowlist, ILaunchOptionsValidationResult } from '@rushstack/playwright-browser-tunnel'; - import { PlaywrightTunnel } from '@rushstack/playwright-browser-tunnel/lib/PlaywrightBrowserTunnel'; - import { EXTENSION_INSTALLED_FILENAME, getNormalizedErrorString } from '@rushstack/playwright-browser-tunnel/lib/utilities'; import { LaunchOptionsValidator } from '@rushstack/playwright-browser-tunnel/lib/LaunchOptionsValidator'; - import { Terminal, type ITerminal, type ITerminalProvider } from '@rushstack/terminal'; - import { runWorkspaceCommandAsync } from '@rushstack/vscode-shared/lib/runWorkspaceCommandAsync'; import { VScodeOutputChannelTerminalProvider } from '@rushstack/vscode-shared/lib/VScodeOutputChannelTerminalProvider'; + import packageJson from '../package.json'; const EXTENSION_DISPLAY_NAME: string = 'Playwright Local Browser Server'; @@ -348,6 +346,7 @@ export async function activate(context: vscode.ExtensionContext): Promise outputChannel.appendLine(`Tunnel status changed: ${status}`); updateStatusBar(status); }, + // eslint-disable-next-line @typescript-eslint/naming-convention onBeforeLaunch: async (handshake: IHandshake) => { // Validate launch options against the allowlist const validationResult: ILaunchOptionsValidationResult = diff --git a/vscode-extensions/playwright-local-browser-server-vscode-extension/src/utils/getNormalizedErrorString.ts b/vscode-extensions/playwright-local-browser-server-vscode-extension/src/utils/getNormalizedErrorString.ts index 6198434cf09..36876840657 100644 --- a/vscode-extensions/playwright-local-browser-server-vscode-extension/src/utils/getNormalizedErrorString.ts +++ b/vscode-extensions/playwright-local-browser-server-vscode-extension/src/utils/getNormalizedErrorString.ts @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + export function getNormalizedErrorString(error: unknown): string { if (error instanceof Error) { if (error.stack) { diff --git a/vscode-extensions/playwright-local-browser-server-vscode-extension/tsconfig.json b/vscode-extensions/playwright-local-browser-server-vscode-extension/tsconfig.json index 09607819d38..487fd08000c 100644 --- a/vscode-extensions/playwright-local-browser-server-vscode-extension/tsconfig.json +++ b/vscode-extensions/playwright-local-browser-server-vscode-extension/tsconfig.json @@ -1,4 +1,9 @@ { "$schema": "http://json.schemastore.org/tsconfig", - "extends": "./node_modules/@rushstack/heft-vscode-extension-rig/profiles/default/tsconfig-base.json" + "extends": "./node_modules/local-vscode-extension-rig/profiles/default/tsconfig-base.json", + "compilerOptions": { + // playwright-core's type definitions reference DOM types (Node, HTMLElement, SVGElement, etc.), + // so include the DOM lib to satisfy them, matching apps/playwright-browser-tunnel. + "lib": ["DOM"] + } } diff --git a/vscode-extensions/playwright-local-browser-server-vscode-extension/webpack.config.js b/vscode-extensions/playwright-local-browser-server-vscode-extension/webpack.config.js index 13af5df6482..8c94c76cfe2 100644 --- a/vscode-extensions/playwright-local-browser-server-vscode-extension/webpack.config.js +++ b/vscode-extensions/playwright-local-browser-server-vscode-extension/webpack.config.js @@ -3,17 +3,14 @@ 'use strict'; -const { - createExtensionConfig -} = require('@rushstack/heft-vscode-extension-rig/profiles/default/webpack.config.base'); -const path = require('node:path'); +const { createExtensionConfig } = require('local-vscode-extension-rig/profiles/default/webpack.config.base'); function createConfig({ production, webpack }) { const config = createExtensionConfig({ production: false, webpack, entry: { - extension: './lib/extension.js' + extension: './lib-esm/extension.js' }, outputPath: `${__dirname}/dist/vsix/unpacked` }); diff --git a/vscode-extensions/rush-vscode-command-webview/src/Message/IFromExtensionMessage.ts b/vscode-extensions/rush-vscode-command-webview/src/Message/IFromExtensionMessage.ts new file mode 100644 index 00000000000..320ede42485 --- /dev/null +++ b/vscode-extensions/rush-vscode-command-webview/src/Message/IFromExtensionMessage.ts @@ -0,0 +1,17 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +import type { IProjectState } from '../store/slices/project'; + +// This message contract is intentionally kept in its own DOM-free module so it can be re-exported from +// the package barrel (index.ts) and consumed by the Node-based `rush-vscode-extension` project. The +// sibling `fromExtension.ts` declares `fromExtensionListener` using the browser's generic +// `MessageEvent`, which is only available with the DOM lib. If this type lived there, importing it +// from a Node project (which resolves `MessageEvent` to the non-generic `@types/node` declaration) +// would fail to type-check with "Type 'MessageEvent' is not generic" (TS2315). +export type IFromExtensionMessage = IFromExtensionMessageInitialize; + +interface IFromExtensionMessageInitialize { + command: string; + state: IProjectState; +} diff --git a/vscode-extensions/rush-vscode-command-webview/src/Message/fromExtension.ts b/vscode-extensions/rush-vscode-command-webview/src/Message/fromExtension.ts index a88b8c5eeb3..a71ab90537d 100644 --- a/vscode-extensions/rush-vscode-command-webview/src/Message/fromExtension.ts +++ b/vscode-extensions/rush-vscode-command-webview/src/Message/fromExtension.ts @@ -2,14 +2,8 @@ // See LICENSE in the project root for license information. import { store } from '../store'; -import { type IProjectState, initializeProjectInfo, onChangeProject } from '../store/slices/project'; - -export type IFromExtensionMessage = IFromExtensionMessageInitialize; - -interface IFromExtensionMessageInitialize { - command: string; - state: IProjectState; -} +import { initializeProjectInfo, onChangeProject } from '../store/slices/project'; +import type { IFromExtensionMessage } from './IFromExtensionMessage'; export const fromExtensionListener: (event: MessageEvent) => void = ( event: MessageEvent diff --git a/vscode-extensions/rush-vscode-command-webview/src/index.ts b/vscode-extensions/rush-vscode-command-webview/src/index.ts index 33fb5f7b7b1..9cbece25380 100644 --- a/vscode-extensions/rush-vscode-command-webview/src/index.ts +++ b/vscode-extensions/rush-vscode-command-webview/src/index.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. // See LICENSE in the project root for license information. -export type { IFromExtensionMessage } from './Message/fromExtension'; +export type { IFromExtensionMessage } from './Message/IFromExtensionMessage'; export type { IRootState } from './store'; export type { IToExtensionMessage } from './Message/toExtension'; export type { ICommandLineParameter } from './store/slices/parameter'; diff --git a/vscode-extensions/rush-vscode-extension/config/heft.json b/vscode-extensions/rush-vscode-extension/config/heft.json index af08cae80ee..c839bdff9ad 100644 --- a/vscode-extensions/rush-vscode-extension/config/heft.json +++ b/vscode-extensions/rush-vscode-extension/config/heft.json @@ -1,7 +1,7 @@ { "$schema": "https://developer.microsoft.com/json-schemas/heft/v0/heft.schema.json", - "extends": "@rushstack/heft-vscode-extension-rig/profiles/default/config/heft.json", + "extends": "local-vscode-extension-rig/profiles/default/config/heft.json", "aliasesByName": { "start": { diff --git a/vscode-extensions/rush-vscode-extension/config/rig.json b/vscode-extensions/rush-vscode-extension/config/rig.json index ec33a848348..1a7ec21fb70 100644 --- a/vscode-extensions/rush-vscode-extension/config/rig.json +++ b/vscode-extensions/rush-vscode-extension/config/rig.json @@ -1,5 +1,5 @@ { "$schema": "https://developer.microsoft.com/json-schemas/rig-package/rig.schema.json", - "rigPackageName": "@rushstack/heft-vscode-extension-rig" + "rigPackageName": "local-vscode-extension-rig" } diff --git a/vscode-extensions/rush-vscode-extension/config/rush-project.json b/vscode-extensions/rush-vscode-extension/config/rush-project.json index f4ca51150ee..5ccdba07e01 100644 --- a/vscode-extensions/rush-vscode-extension/config/rush-project.json +++ b/vscode-extensions/rush-vscode-extension/config/rush-project.json @@ -1,6 +1,6 @@ { "$schema": "https://developer.microsoft.com/json-schemas/rush/v5/rush-project.schema.json", - "extends": "@rushstack/heft-vscode-extension-rig/profiles/default/config/rush-project.json", + "extends": "local-vscode-extension-rig/profiles/default/config/rush-project.json", "operationSettings": [ { "operationName": "_phase:build", diff --git a/vscode-extensions/rush-vscode-extension/eslint.config.js b/vscode-extensions/rush-vscode-extension/eslint.config.js index eac79367926..b97a237b568 100644 --- a/vscode-extensions/rush-vscode-extension/eslint.config.js +++ b/vscode-extensions/rush-vscode-extension/eslint.config.js @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. // See LICENSE in the project root for license information. -const nodeTrustedToolProfile = require('@rushstack/heft-vscode-extension-rig/profiles/default/includes/eslint/flat/profile/node-trusted-tool'); -const friendlyLocalsMixin = require('@rushstack/heft-vscode-extension-rig/profiles/default/includes/eslint/flat/mixins/friendly-locals'); +const nodeTrustedToolProfile = require('local-vscode-extension-rig/profiles/default/includes/eslint/flat/profile/node-trusted-tool'); +const friendlyLocalsMixin = require('local-vscode-extension-rig/profiles/default/includes/eslint/flat/mixins/friendly-locals'); module.exports = [...nodeTrustedToolProfile, ...friendlyLocalsMixin]; diff --git a/vscode-extensions/rush-vscode-extension/package.json b/vscode-extensions/rush-vscode-extension/package.json index cc524ace78e..b030daed3ce 100644 --- a/vscode-extensions/rush-vscode-extension/package.json +++ b/vscode-extensions/rush-vscode-extension/package.json @@ -302,14 +302,13 @@ "devDependencies": { "@microsoft/rush-lib": "workspace:*", "@rushstack/heft": "workspace:*", - "@types/glob": "7.1.1", "@types/mocha": "10.0.6", "@types/vscode": "1.103.0", "@types/webpack-env": "1.18.8", "@vscode/test-electron": "^1.6.2", "eslint": "~9.37.0", - "glob": "~7.0.5", - "@rushstack/heft-vscode-extension-rig": "workspace:*", + "fast-glob": "~3.3.1", + "local-vscode-extension-rig": "workspace:*", "mocha": "^10.1.0" }, "engines": { diff --git a/vscode-extensions/rush-vscode-extension/src/extension.ts b/vscode-extensions/rush-vscode-extension/src/extension.ts index 9b72eb220f0..2819bb175ae 100644 --- a/vscode-extensions/rush-vscode-extension/src/extension.ts +++ b/vscode-extensions/rush-vscode-extension/src/extension.ts @@ -4,6 +4,7 @@ // The module 'vscode' contains the VS Code extensibility API // Import the module and reference it with the alias vscode in your code below import * as vscode from 'vscode'; + import { type LogLevel, setLogLevel, terminal } from './logic/logger'; import { RushWorkspace } from './logic/RushWorkspace'; import { RushProjectsProvider } from './providers/RushProjectsProvider'; diff --git a/vscode-extensions/rush-vscode-extension/src/logic/RushCommandWebViewPanel.ts b/vscode-extensions/rush-vscode-extension/src/logic/RushCommandWebViewPanel.ts index 5a66d982b5b..84e3c8ebc68 100644 --- a/vscode-extensions/rush-vscode-extension/src/logic/RushCommandWebViewPanel.ts +++ b/vscode-extensions/rush-vscode-extension/src/logic/RushCommandWebViewPanel.ts @@ -1,10 +1,11 @@ // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. // See LICENSE in the project root for license information. +import * as path from 'node:path'; + import * as vscode from 'vscode'; -import * as path from 'path'; -import { FileSystem } from '@rushstack/node-core-library'; +import { FileSystem } from '@rushstack/node-core-library'; import type { IFromExtensionMessage, IRootState } from '@rushstack/rush-vscode-command-webview'; export class RushCommandWebViewPanel { diff --git a/vscode-extensions/rush-vscode-extension/src/logic/RushWorkspace.ts b/vscode-extensions/rush-vscode-extension/src/logic/RushWorkspace.ts index bbff82b77f2..5da5715b89a 100644 --- a/vscode-extensions/rush-vscode-extension/src/logic/RushWorkspace.ts +++ b/vscode-extensions/rush-vscode-extension/src/logic/RushWorkspace.ts @@ -1,15 +1,15 @@ // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. // See LICENSE in the project root for license information. -import { RushSdkLoader, type ISdkCallbackEvent } from '@rushstack/rush-sdk/loader'; - import * as vscode from 'vscode'; -import { terminal } from './logger'; +import { RushSdkLoader, type ISdkCallbackEvent } from '@rushstack/rush-sdk/loader'; import type { CommandLineAction } from '@rushstack/rush-vscode-command-webview'; import type * as RushLib from '@rushstack/rush-sdk'; import type * as RushCommandLine from '@rushstack/ts-command-line'; +import { terminal } from './logger'; + // eslint-disable-next-line @typescript-eslint/naming-convention declare let ___DEV___: boolean; declare const global: NodeJS.Global & diff --git a/vscode-extensions/rush-vscode-extension/src/providers/RushCommandsProvider.ts b/vscode-extensions/rush-vscode-extension/src/providers/RushCommandsProvider.ts index faf0080814f..a9b5feae96a 100644 --- a/vscode-extensions/rush-vscode-extension/src/providers/RushCommandsProvider.ts +++ b/vscode-extensions/rush-vscode-extension/src/providers/RushCommandsProvider.ts @@ -2,11 +2,12 @@ // See LICENSE in the project root for license information. import * as vscode from 'vscode'; -import { terminal } from '../logic/logger'; -import { RushWorkspace } from '../logic/RushWorkspace'; import type { CommandLineAction } from '@rushstack/rush-vscode-command-webview'; +import { terminal } from '../logic/logger'; +import { RushWorkspace } from '../logic/RushWorkspace'; + interface IRushCommandParams { label: string; collapsibleState: vscode.TreeItemCollapsibleState; diff --git a/vscode-extensions/rush-vscode-extension/src/providers/RushProjectsProvider.ts b/vscode-extensions/rush-vscode-extension/src/providers/RushProjectsProvider.ts index f1df1b8f240..e7ff5df6cf7 100644 --- a/vscode-extensions/rush-vscode-extension/src/providers/RushProjectsProvider.ts +++ b/vscode-extensions/rush-vscode-extension/src/providers/RushProjectsProvider.ts @@ -1,14 +1,16 @@ // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. // See LICENSE in the project root for license information. +import path from 'node:path'; + import * as vscode from 'vscode'; -import * as path from 'path'; + import { JsonFile, type JsonObject } from '@rushstack/node-core-library'; +import type { RushConfiguration, RushConfigurationProject } from '@rushstack/rush-sdk'; + import { RushTaskProvider } from './TaskProvider'; import { terminal } from '../logic/logger'; import { RushWorkspace } from '../logic/RushWorkspace'; - -import type { RushConfiguration, RushConfigurationProject } from '@rushstack/rush-sdk'; import { RushCommandWebViewPanel } from '../logic/RushCommandWebViewPanel'; interface IRushProjectParams { diff --git a/vscode-extensions/rush-vscode-extension/src/providers/TaskProvider.ts b/vscode-extensions/rush-vscode-extension/src/providers/TaskProvider.ts index fc96d2ffe1a..d0e9adc0621 100644 --- a/vscode-extensions/rush-vscode-extension/src/providers/TaskProvider.ts +++ b/vscode-extensions/rush-vscode-extension/src/providers/TaskProvider.ts @@ -2,6 +2,7 @@ // See LICENSE in the project root for license information. import * as vscode from 'vscode'; + import { terminal } from '../logic/logger'; let rushTaskProvider: RushTaskProvider | undefined; diff --git a/vscode-extensions/rush-vscode-extension/src/test/runTest.ts b/vscode-extensions/rush-vscode-extension/src/test/runTest.ts index 80f8cb2b5af..5370afacc23 100644 --- a/vscode-extensions/rush-vscode-extension/src/test/runTest.ts +++ b/vscode-extensions/rush-vscode-extension/src/test/runTest.ts @@ -1,11 +1,11 @@ // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. // See LICENSE in the project root for license information. -import * as path from 'path'; +import path from 'node:path'; import { runTests } from '@vscode/test-electron'; -async function main(): Promise { +async function mainAsync(): Promise { try { // The folder containing the Extension Manifest package.json // Passed to `--extensionDevelopmentPath` @@ -13,7 +13,7 @@ async function main(): Promise { // The path to test runner // Passed to --extensionTestsPath - const extensionTestsPath: string = path.resolve(__dirname, './suite/index'); + const extensionTestsPath: string = `${__dirname}./suite/index`; // Download VS Code, unzip it and run the integration test await runTests({ extensionDevelopmentPath, extensionTestsPath }); @@ -24,5 +24,5 @@ async function main(): Promise { } } -// eslint-disable-next-line @typescript-eslint/no-floating-promises -main(); +// eslint-disable-next-line no-console +void mainAsync().catch(console.error); diff --git a/vscode-extensions/rush-vscode-extension/src/test/suite/extension.test.ts b/vscode-extensions/rush-vscode-extension/src/test/suite/extension.test.ts index 4cd31bc277f..bc603b44daf 100644 --- a/vscode-extensions/rush-vscode-extension/src/test/suite/extension.test.ts +++ b/vscode-extensions/rush-vscode-extension/src/test/suite/extension.test.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. // See LICENSE in the project root for license information. -import * as assert from 'assert'; +import * as assert from 'node:assert'; // You can import and use all API from the 'vscode' module // as well as import your extension to test it diff --git a/vscode-extensions/rush-vscode-extension/src/test/suite/index.ts b/vscode-extensions/rush-vscode-extension/src/test/suite/index.ts index a4527237b66..7d0bbf83ffd 100644 --- a/vscode-extensions/rush-vscode-extension/src/test/suite/index.ts +++ b/vscode-extensions/rush-vscode-extension/src/test/suite/index.ts @@ -1,11 +1,12 @@ // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. // See LICENSE in the project root for license information. -import * as path from 'path'; +import path from 'node:path'; +import { promisify } from 'node:util'; import Mocha from 'mocha'; -import glob from 'glob'; +import glob from 'fast-glob'; -export function run(): Promise { +export async function run(): Promise { // Create the mocha test const mocha: Mocha = new Mocha({ ui: 'tdd', @@ -14,29 +15,8 @@ export function run(): Promise { const testsRoot: string = path.resolve(__dirname, '..'); - return new Promise((resolve, reject) => { - glob('**/**.test.js', { cwd: testsRoot }, (err1, files) => { - if (err1) { - return reject(err1); - } - - // Add files to the test suite - files.forEach((f) => mocha.addFile(path.resolve(testsRoot, f))); - - try { - // Run the mocha test - mocha.run((failures) => { - if (failures > 0) { - reject(new Error(`${failures} tests failed.`)); - } else { - resolve(); - } - }); - } catch (err2) { - // eslint-disable-next-line no-console - console.error(err2); - reject(err2); - } - }); - }); + const files: string[] = await glob('**/**.test.js', { cwd: testsRoot }); + // Add files to the test suite + files.forEach((f) => mocha.addFile(path.resolve(testsRoot, f))); + await promisify(mocha.run.bind(mocha)); } diff --git a/vscode-extensions/rush-vscode-extension/tsconfig.json b/vscode-extensions/rush-vscode-extension/tsconfig.json index 1226387ecf8..a46c9ae0fa3 100644 --- a/vscode-extensions/rush-vscode-extension/tsconfig.json +++ b/vscode-extensions/rush-vscode-extension/tsconfig.json @@ -1,3 +1,8 @@ { - "extends": "./node_modules/@rushstack/heft-vscode-extension-rig/profiles/default/tsconfig-base.json" + "extends": "./node_modules/local-vscode-extension-rig/profiles/default/tsconfig-base.json", + "compilerOptions": { + // This project provides VS Code integration tests that run under Mocha (via @vscode/test-electron), + // so override the rig's default Jest typings to avoid colliding ambient test globals (describe/it/beforeEach). + "types": ["mocha", "node"] + } } diff --git a/vscode-extensions/rush-vscode-extension/webpack.config.js b/vscode-extensions/rush-vscode-extension/webpack.config.js index 54f783e08c3..40b16161fe0 100644 --- a/vscode-extensions/rush-vscode-extension/webpack.config.js +++ b/vscode-extensions/rush-vscode-extension/webpack.config.js @@ -3,19 +3,16 @@ 'use strict'; -const { - createExtensionConfig -} = require('@rushstack/heft-vscode-extension-rig/profiles/default/webpack.config.base'); -const path = require('node:path'); +const { createExtensionConfig } = require('local-vscode-extension-rig/profiles/default/webpack.config.base'); function createConfig({ production, webpack }) { const config = createExtensionConfig({ production, webpack, entry: { - extension: './lib/extension.js' + extension: './lib-esm/extension.js' }, - outputPath: path.resolve(__dirname, 'dist', 'vsix', 'unpacked') + outputPath: `${__dirname}/dist/vsix/unpacked` }); if (!config.externals) { From cdf08f9233b7ae27f68dd2f28da4ed9514b6b859 Mon Sep 17 00:00:00 2001 From: Ian Clanton-Thuon Date: Thu, 25 Jun 2026 20:00:09 -0700 Subject: [PATCH 2/3] Clean up rush-vscode-extension tree data providers and webview panel Use async file IO and the rush-sdk packageJson API instead of synchronous reads, mark immutable fields readonly, and return plain arrays from TreeDataProvider.getChildren implementations. --- .../src/logic/RushCommandWebViewPanel.ts | 24 +++++++------- .../src/providers/RushCommandsProvider.ts | 13 ++++---- .../src/providers/RushProjectsProvider.ts | 32 +++++++++---------- 3 files changed, 36 insertions(+), 33 deletions(-) diff --git a/vscode-extensions/rush-vscode-extension/src/logic/RushCommandWebViewPanel.ts b/vscode-extensions/rush-vscode-extension/src/logic/RushCommandWebViewPanel.ts index 84e3c8ebc68..5dbb279345e 100644 --- a/vscode-extensions/rush-vscode-extension/src/logic/RushCommandWebViewPanel.ts +++ b/vscode-extensions/rush-vscode-extension/src/logic/RushCommandWebViewPanel.ts @@ -12,8 +12,9 @@ export class RushCommandWebViewPanel { private static _instance: RushCommandWebViewPanel | undefined; private _panel: vscode.WebviewView | undefined; private _webViewProvider: vscode.WebviewViewProvider | undefined; - private _context: vscode.ExtensionContext; - private _extensionPath: string; + private readonly _context: vscode.ExtensionContext; + private readonly _extensionPath: string; + private constructor(context: vscode.ExtensionContext) { this._extensionPath = context.extensionPath; this._context = context; @@ -59,11 +60,11 @@ export class RushCommandWebViewPanel { } }; - const resolveWebviewView = ( + const resolveWebviewView = async ( thisWebview: vscode.WebviewView, thisWebviewContext: vscode.WebviewViewResolveContext, thisToken: vscode.CancellationToken - ): void => { + ): Promise => { this._panel = thisWebview; const message: IFromExtensionMessage = { @@ -73,9 +74,9 @@ export class RushCommandWebViewPanel { // eslint-disable-next-line no-console console.log('message', message); thisWebview.webview.options = { enableScripts: true }; - thisWebview.webview.html = this._getWebviewContent(); - // eslint-disable-next-line @typescript-eslint/no-floating-promises - thisWebview.webview.postMessage(message); + // eslint-disable-next-line require-atomic-updates + thisWebview.webview.html = await this._getWebviewContentAsync(); + await thisWebview.webview.postMessage(message); }; const provider: vscode.WebviewViewProvider = { @@ -153,17 +154,18 @@ export class RushCommandWebViewPanel { // } } - private _setWebviewContent(state: IRootState): void { + private async _setWebviewContentAsync(state: IRootState): Promise { if (!this._panel) { return; } - this._panel.webview.html = this._getWebviewContent(state); + + this._panel.webview.html = await this._getWebviewContentAsync(state); } - private _getWebviewContent(state: unknown = {}): string { + private async _getWebviewContentAsync(state: unknown = {}): Promise { // eslint-disable-next-line no-console console.log('loading rush command webview html and bundle'); - let html: string = FileSystem.readFile( + let html: string = await FileSystem.readFileAsync( path.join(this._extensionPath, 'webview/rush-command-webview/index.html') ); const scriptSrc: vscode.Uri = this._panel!.webview.asWebviewUri( diff --git a/vscode-extensions/rush-vscode-extension/src/providers/RushCommandsProvider.ts b/vscode-extensions/rush-vscode-extension/src/providers/RushCommandsProvider.ts index a9b5feae96a..97b80f026db 100644 --- a/vscode-extensions/rush-vscode-extension/src/providers/RushCommandsProvider.ts +++ b/vscode-extensions/rush-vscode-extension/src/providers/RushCommandsProvider.ts @@ -113,7 +113,8 @@ export class RushCommandsProvider implements vscode.TreeDataProvider { + // eslint-disable-next-line @typescript-eslint/naming-convention + public async getChildren(element?: vscode.TreeItem): Promise { // eslint-disable-next-line no-console console.log('children: ', this._commandLineActions); // eslint-disable-next-line no-console @@ -121,10 +122,10 @@ export class RushCommandsProvider implements vscode.TreeDataProvider // new RushCommand({ @@ -153,6 +154,6 @@ export class RushCommandsProvider implements vscode.TreeDataProvider { + ): Promise { if (!this._rushConfiguration) { // eslint-disable-next-line @typescript-eslint/no-floating-promises vscode.window.showInformationMessage('No RushProjects in empty workspace'); - return Promise.resolve([]); + return []; } // top-level @@ -167,31 +165,33 @@ export class RushProjectsProvider implements vscode.TreeDataProvider + const { + projectFolder, + projectRelativeFolder, + packageJson: { scripts = {} } + } = element.rushConfigurationProject; + const rushProjectScriptTreeItems: RushProjectScript[] = Object.entries(scripts).map( + ([scriptName, scriptValue]) => new RushProjectScript({ label: scriptName, collapsibleState: vscode.TreeItemCollapsibleState.None, projectFolder, projectRelativeFolder, scriptName, - scriptValue: packageJson.scripts[scriptName] + scriptValue }) ); - return Promise.resolve(rushProjectScriptTreeItems); + return rushProjectScriptTreeItems; } catch { - return Promise.resolve([]); + return []; } } - return Promise.resolve([]); + return []; } } From 68256f34cbf6e6b31ffea884418d49bb858adb6d Mon Sep 17 00:00:00 2001 From: Ian Clanton-Thuon Date: Thu, 25 Jun 2026 20:02:43 -0700 Subject: [PATCH 3/3] Clean up some path concatenations. --- .../rush-vscode-command-webview/webpack.config.js | 9 ++++----- .../src/logic/RushCommandWebViewPanel.ts | 6 ++---- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/vscode-extensions/rush-vscode-command-webview/webpack.config.js b/vscode-extensions/rush-vscode-command-webview/webpack.config.js index d729dd7a999..cd03e88ef97 100644 --- a/vscode-extensions/rush-vscode-command-webview/webpack.config.js +++ b/vscode-extensions/rush-vscode-command-webview/webpack.config.js @@ -1,5 +1,4 @@ /* eslint-env es6 */ -const path = require('path'); const HtmlWebpackPlugin = require('html-webpack-plugin'); const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer'); @@ -16,10 +15,10 @@ function createWebpackConfig({ production }) { } }, entry: { - bundle: path.join(__dirname, 'lib-esm', 'entry.js') + bundle: `${__dirname}/lib-esm/entry.js` }, output: { - path: path.join(__dirname, 'dist'), + path: `${__dirname}/dist`, filename: '[name].js' }, module: { @@ -58,9 +57,9 @@ function createWebpackConfig({ production }) { new BundleAnalyzerPlugin({ openAnalyzer: false, analyzerMode: 'static', - reportFilename: path.resolve(__dirname, 'temp', 'stats.html'), + reportFilename: `${__dirname}/temp/stats.html`, generateStatsFile: true, - statsFilename: path.resolve(__dirname, 'temp', 'stats.json'), + statsFilename: `${__dirname}/temp/stats.json`, logLevel: 'info' }) ].filter(Boolean) diff --git a/vscode-extensions/rush-vscode-extension/src/logic/RushCommandWebViewPanel.ts b/vscode-extensions/rush-vscode-extension/src/logic/RushCommandWebViewPanel.ts index 5dbb279345e..ae1966c3b49 100644 --- a/vscode-extensions/rush-vscode-extension/src/logic/RushCommandWebViewPanel.ts +++ b/vscode-extensions/rush-vscode-extension/src/logic/RushCommandWebViewPanel.ts @@ -1,8 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. // See LICENSE in the project root for license information. -import * as path from 'node:path'; - import * as vscode from 'vscode'; import { FileSystem } from '@rushstack/node-core-library'; @@ -166,10 +164,10 @@ export class RushCommandWebViewPanel { // eslint-disable-next-line no-console console.log('loading rush command webview html and bundle'); let html: string = await FileSystem.readFileAsync( - path.join(this._extensionPath, 'webview/rush-command-webview/index.html') + `${this._extensionPath}/webview/rush-command-webview/index.html` ); const scriptSrc: vscode.Uri = this._panel!.webview.asWebviewUri( - vscode.Uri.file(path.join(this._extensionPath, 'webview/rush-command-webview/bundle.js')) + vscode.Uri.file(`${this._extensionPath}/webview/rush-command-webview/bundle.js`) ); // replace bundled js with the correct path