Fix browser launch crash and stale ES2023 hint - #4836
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes two user-facing issues in the Edge DevTools VS Code extension: (1) command-palette browser launch crashing when invoked without a file URI, and (2) a stale webhint typescript-config/is-valid diagnostic incorrectly flagging ES2023 in tsconfig*.json.
Changes:
- Allow
launchHtml/launchScreencastcommands to be invoked without afileUri, falling back to the configured default URL. - Add a
handleDiagnosticsmiddleware filter to suppress the specific stale ES2023 webhint diagnostic only fortsconfig*.json. - Add Jest coverage for both behaviors.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/extension.ts |
Makes launch commands accept optional URIs and adds webhint diagnostics filtering middleware. |
src/webhintDiagnostics.ts |
Introduces a helper to identify/suppress the stale ES2023 typescript-config/is-valid diagnostic for tsconfig files. |
test/extension.test.ts |
Adds a regression test ensuring default URL fallback works when no file URI is provided. |
test/webhintDiagnostics.test.ts |
Adds tests verifying ES2023 suppression is scoped to tsconfig files and doesn’t suppress other diagnostics. |
Comments suppressed due to low confidence (4)
src/extension.ts:314
- Same issue here:
file://${fileUri.fsPath}can generate an invalid file URL on Windows, which may preventattach()from matching the launched target. PreferfileUri.toString(true)for a correct, encoded file URL.
const url = fileUri ? `file://${fileUri.fsPath}` : defaultUrl;
edgeDebugConfig.url = url;
void vscode.debug.startDebugging(undefined, edgeDebugConfig).then(() => attach(context, url, undefined, true, true));
test/webhintDiagnostics.test.ts:21
- Casting the diagnostic object to
neversidesteps type-checking. Cast toimport('vscode').Diagnostic(type-only) so the test stays type-safe without introducing a runtime VS Code dependency.
expect(shouldSuppressWebhintDiagnostic(tsConfigUri, {
source: 'Microsoft Edge Tools',
message: "'compilerOptions/target' must be equal to one of the allowed values 'ES3, ES5, ES6, ES2015, ES2016, ES2017, ES2018, ES2019, ES2020, ES2021, ES2022, ESNext'. Value found '\"ES2023\"'.",
code: { value: 'typescript-config/is-valid' },
} as never)).toBe(true);
test/webhintDiagnostics.test.ts:37
- Same issue here:
as neverremoves type safety in the test. Switch to a type-only cast toimport('vscode').Diagnostic.
expect(shouldSuppressWebhintDiagnostic(appConfigUri, {
source: 'Microsoft Edge Tools',
message: "'compilerOptions/target' must be equal to one of the allowed values 'ES3, ES5, ES6, ES2015, ES2016, ES2017, ES2018, ES2019, ES2020, ES2021, ES2022, ESNext'. Value found '\"ES2023\"'.",
code: { value: 'typescript-config/is-valid' },
} as never)).toBe(false);
test/webhintDiagnostics.test.ts:29
- Same issue here:
as neverremoves type safety in the test. Switch to a type-only cast toimport('vscode').Diagnostic.
expect(shouldSuppressWebhintDiagnostic(tsConfigUri, {
source: 'Microsoft Edge Tools',
message: "'compilerOptions/target' must be equal to one of the allowed values 'ES3, ES5, ES6, ES2015, ES2016, ES2017, ES2018, ES2019, ES2020, ES2021, ES2022, ESNext'. Value found '\"ES2022\"'.",
code: { value: 'typescript-config/is-valid' },
} as never)).toBe(false);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@microsoft-github-policy-service agree |
1 similar comment
|
@microsoft-github-policy-service agree |
|
@microsoft-github-policy-service the CLA is complete and the review comments have been addressed. Could someone with write access please take a look and approve when convenient? The PR is otherwise ready apart from the maintainer-side workflow approvals. |
|
@DhruvilThummar the command you issued was incorrect. Please try again. Examples are: and |
This PR addresses two Edge Tools issues:
fsPathfromundefined.typescript-config/is-validfalse positive forES2023intsconfig*.jsonwhile leaving other diagnostics intact.Validation:
npx jest --config package.json --runInBand test/extension.test.ts -t "can launch the browser with the default url when no file uri is provided"npx jest --config package.json --runInBand test/webhintDiagnostics.test.ts