Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ package-lock.json
.config/
img/
node_modules/
!node_modules/vscode-webhint/dist/src/server.js
!node_modules/@vscode/codicons/dist/codicon.css
!node_modules/@vscode/codicons/dist/codicon.ttf
out/edge/
Expand Down
101 changes: 0 additions & 101 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 1 addition & 24 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,7 @@
"main": "./out/extension",
"sideEffects": false,
"activationEvents": [
"onStartupFinished",
"onLanguage:css",
"onLanguage:html",
"onLanguage:javascript",
"onLanguage:javascriptreact",
"onLanguage:json",
"onLanguage:jsonc",
"onLanguage:less",
"onLanguage:sass",
"onLanguage:scss",
"onLanguage:typescript",
"onLanguage:typescriptreact"
"onStartupFinished"
],
"capabilities": {
"untrustedWorkspaces": {
Expand Down Expand Up @@ -273,16 +262,6 @@
"Microsoft Edge Tools for VS Code will use Microsoft Edge Dev version",
"Microsoft Edge Tools for VS Code will use Microsoft Edge Canary version"
]
},
"vscode-edge-devtools.webhint": {
"type": "boolean",
"default": true,
"description": "Enable feedback from webhint on source files to improve accessibility, compatibility, security and more."
},
"vscode-edge-devtools.webhintInstallNotification": {
"type": "boolean",
"default": false,
"description": "Turn off notification for webhint installation failures."
}
}
},
Expand Down Expand Up @@ -686,7 +665,6 @@
"puppeteer-core": "25.9.0",
"utf-8-validate": "6.0.6",
"vscode-chrome-debug-core": "6.8.11",
"vscode-webhint": "2.1.15",
"ws": "8.21.3",
"xmlhttprequest": "1.8.0"
},
Expand All @@ -713,7 +691,6 @@
"uglify-js": "3.19.3",
"unzipper": "0.12.5",
"jest-environment-jsdom": "^30.5.1",
"vscode-languageclient": "10.1.1",
"webpack": "5.110.3",
"webpack-cli": "7.2.3"
}
Expand Down
150 changes: 0 additions & 150 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@ import { LaunchDebugProvider } from './launchDebugProvider';
import { sendTaxonomyErrorEvent, sendTaxonomyEvent } from './telemetryTaxonomy';
import {
buttonCode,
checkWithinHoverRange,
createTelemetryReporter,
fixRemoteWebSocket,
getBrowserPath,
getListOfTargets,
getRemoteEndpointSettings,
getRuntimeConfig,
getSupportedStaticAnalysisFileTypes,
IRemoteTargetJson,
IUserConfig,
launchBrowser,
Expand All @@ -41,43 +39,16 @@ import {
import { LaunchConfigManager, providedHeadlessDebugConfig, providedLaunchDevToolsConfig } from './launchConfigManager';
import { ErrorReporter } from './errorReporter';
import { ErrorCodes } from './common/errorCodes';
import type {
LanguageClientOptions,
ServerOptions,
} from 'vscode-languageclient/node';
import {
LanguageClient,
TransportKind,
} from 'vscode-languageclient/node';
import type { installFailed, showOutput } from 'vscode-webhint/dist/src/utils/notifications';

let telemetryReporter: Readonly<TelemetryReporter>;
let browserInstance: Browser;
let cdpTargetsProvider: CDPTargetsProvider;

// Keep a reference to the client to stop it when deactivating.
let client: LanguageClient;
const languageServerName = 'Microsoft Edge Tools';

type DiagnosticCodeType = { value: string; target: vscode.Uri; };

export function activate(context: vscode.ExtensionContext): void {
if (!telemetryReporter) {
telemetryReporter = createTelemetryReporter(context);
}

vscode.languages.registerHoverProvider(getSupportedStaticAnalysisFileTypes(), {
provideHover(document, position) {
const documentDiagnostics = vscode.languages.getDiagnostics(document.uri);
for (const diagnostic of documentDiagnostics) {
if (diagnostic.source === languageServerName && checkWithinHoverRange(position, diagnostic.range) && diagnostic.code as DiagnosticCodeType) {
sendTaxonomyEvent(telemetryReporter, { area: 'user', feature: 'webhint', action: 'hover' }, { 'hint': (diagnostic.code as DiagnosticCodeType).value });
}
}
return null;
},
});

// Check if launch.json exists and has supported config to populate side pane welcome message
LaunchConfigManager.instance.updateLaunchConfig();
context.subscriptions.push(vscode.commands.registerCommand(`${SETTINGS_STORE_NAME}.attach`, (): void => {
Expand Down Expand Up @@ -265,20 +236,6 @@ export function activate(context: vscode.ExtensionContext): void {
void reportFileExtensionTypes(telemetryReporter);
reportExtensionSettings(telemetryReporter);
vscode.workspace.onDidChangeConfiguration(event => reportChangedExtensionSetting(event, telemetryReporter));

const settingsConfig = vscode.workspace.getConfiguration(SETTINGS_STORE_NAME);
if (settingsConfig.get('webhint')) {
void startWebhint(context);
}
vscode.workspace.onDidChangeConfiguration(event => {
if (event.affectsConfiguration(`${SETTINGS_STORE_NAME}.webhint`)) {
if (vscode.workspace.getConfiguration(SETTINGS_STORE_NAME).get('webhint')) {
void startWebhint(context);
} else {
void stopWebhint();
}
}
});
}

export async function launchHtml(fileUri: vscode.Uri): Promise<void> {
Expand Down Expand Up @@ -314,113 +271,6 @@ export async function launchScreencast(context: vscode.ExtensionContext, fileUri
}
}

async function startWebhint(context: vscode.ExtensionContext): Promise<void> {
const args = [context.globalStoragePath, languageServerName];
const module = context.asAbsolutePath('node_modules/vscode-webhint/dist/src/server.js');
const transport = TransportKind.ipc;
const serverOptions: ServerOptions = {
debug: {
args,
module,
options: { execArgv: ['--nolazy', '--inspect=6009'] },
transport,
},
run: {
args,
module,
transport,
},
};

const clientOptions: LanguageClientOptions = {
documentSelector: getSupportedStaticAnalysisFileTypes(),
synchronize: {
// Notify the server if a webhint-related configuration changes.
fileEvents: vscode.workspace.createFileSystemWatcher('**/.hintrc'),
},
middleware: {
executeCommand: (command, args, next) => {
const hintName = args[0] as string;
const featureName = args[1] as string;

if (!telemetryReporter) {
telemetryReporter = createTelemetryReporter(context);
}

switch (command) {
case 'vscode-webhint/ignore-hint-project': {
sendTaxonomyEvent(telemetryReporter, { area: 'user', feature: 'webhint', action: 'quickfix', detail: 'disable-hint' }, { hint: hintName });
break;
}
case 'vscode-webhint/ignore-feature-project': {
sendTaxonomyEvent(telemetryReporter, { area: 'user', feature: 'webhint', action: 'quickfix', detail: 'disable-rule' }, { hint: hintName, value: featureName });
break;
}
case 'vscode-webhint/edit-hintrc-project': {
sendTaxonomyEvent(telemetryReporter, { area: 'user', feature: 'webhint', action: 'quickfix', detail: 'edit-hintrc' });
break;
}
case 'vscode-webhint/ignore-browsers-project': {
if (args.length > 1) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const browserList = args[2]['browsers'] as any[]; // eslint-disable-line @typescript-eslint/no-unsafe-member-access
sendTaxonomyEvent(telemetryReporter, { area: 'user', feature: 'webhint', action: 'quickfix', detail: 'ignore-browsers' }, { hint: hintName, value: browserList.join(',') });
}
break;
}
case 'vscode-webhint/apply-code-fix': {
sendTaxonomyEvent(telemetryReporter, { area: 'user', feature: 'webhint', action: 'quickfix', detail: 'apply-code-fix' }, {value: featureName });
break;
}
}

return next(command, args); // eslint-disable-line @typescript-eslint/no-unsafe-return
},
},
};

// Create and start the client (also starts the server).
client = new LanguageClient('Microsoft Edge Tools', serverOptions, clientOptions);
// Listen for notification that the webhint install failed.
const installFailedNotification: typeof installFailed = 'vscode-webhint/install-failed';
const disableInstallFailedNotification = vscode.workspace.getConfiguration(SETTINGS_STORE_NAME).get('webhintInstallNotification');
client.onNotification(installFailedNotification, () => {
if (!telemetryReporter) {
telemetryReporter = createTelemetryReporter(context);
}
sendTaxonomyEvent(telemetryReporter, { area: 'user', feature: 'webhint', action: 'install', outcome: 'error' });
if (!disableInstallFailedNotification) {
const message = 'Ensure `node` and `npm` are installed to enable automatically reporting issues in source files pertaining to accessibility, compatibility, security, and more.';
void vscode.window.showInformationMessage(message, 'Remind me Later', 'Don\'t show again', 'Disable Extension').then(button => {
if (button === 'Disable Extension') {
void vscode.workspace.getConfiguration(SETTINGS_STORE_NAME).update('webhint', false, vscode.ConfigurationTarget.Global);
}
if (button === 'Don\'t show again') {
void vscode.workspace.getConfiguration(SETTINGS_STORE_NAME).update('webhintInstallNotification', true, vscode.ConfigurationTarget.Global);
}
});
}
});

// Listen for requests to show the output panel for this extension.
const showOutputNotification: typeof showOutput = 'vscode-webhint/show-output';
client.onNotification(showOutputNotification, () => {
client.outputChannel.clear();
client.outputChannel.show(true);
});
await client.start();
}

async function stopWebhint(): Promise<void> {
if (client) {
await client.stop();
}
}

export const deactivate = (): Thenable<void> => {
return stopWebhint();
};

export async function attach(
context: vscode.ExtensionContext, attachUrl?: string, config?: Partial<IUserConfig>, useRetry?: boolean, screencastOnly?: boolean): Promise<void> {
if (!telemetryReporter) {
Expand Down
Loading
Loading