Lint more redundant activation events (#173186)

* `onWalkthrough`
* `onTerminalQuickFixRequest`
* `onTerminalProfile`
* `onRenderer`
This commit is contained in:
Joyce Er 2023-02-02 11:18:11 -08:00 committed by GitHub
parent 8922a506d6
commit b42443093a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -17,7 +17,7 @@ const allowedBadgeProviders: string[] = (product.extensionAllowedBadgeProviders
const allowedBadgeProvidersRegex: RegExp[] = (product.extensionAllowedBadgeProvidersRegex || []).map((r: string) => new RegExp(r));
const extensionEnabledApiProposals: Record<string, string[]> = product.extensionEnabledApiProposals ?? {};
const reservedImplicitActivationEventPrefixes = ['onNotebookSerializer:'];
const redundantImplicitActivationEventPrefixes = ['onLanguage:', 'onView:', 'onAuthenticationRequest:', 'onCommand:', 'onCustomEditor:'];
const redundantImplicitActivationEventPrefixes = ['onLanguage:', 'onView:', 'onAuthenticationRequest:', 'onCommand:', 'onCustomEditor:', 'onTerminalProfile:', 'onRenderer:', 'onTerminalQuickFixRequest:', 'onWalkthrough:'];
function isTrustedSVGSource(uri: Uri): boolean {
return allowedBadgeProviders.includes(uri.authority.toLowerCase()) || allowedBadgeProvidersRegex.some(r => r.test(uri.toString()));
@ -453,5 +453,41 @@ function parseImplicitActivationEvents(tree: JsonNode): Set<string> {
});
});
// walkthroughs
const walkthroughs = findNodeAtLocation(tree, ['contributes', 'walkthroughs']);
walkthroughs?.children?.forEach(child => {
const id = findNodeAtLocation(child, ['id']);
if (id && id.type === 'string') {
activationEvents.add(`onWalkthrough:${id.value}`);
}
});
// notebookRenderers
const notebookRenderers = findNodeAtLocation(tree, ['contributes', 'notebookRenderer']);
notebookRenderers?.children?.forEach(child => {
const id = findNodeAtLocation(child, ['id']);
if (id && id.type === 'string') {
activationEvents.add(`onRenderer:${id.value}`);
}
});
// terminalProfiles
const terminalProfiles = findNodeAtLocation(tree, ['contributes', 'terminal', 'profiles']);
terminalProfiles?.children?.forEach(child => {
const id = findNodeAtLocation(child, ['id']);
if (id && id.type === 'string') {
activationEvents.add(`onTerminalProfile:${id.value}`);
}
});
// terminalQuickFixes
const terminalQuickFixes = findNodeAtLocation(tree, ['contributes', 'terminal', 'quickFixes']);
terminalQuickFixes?.children?.forEach(child => {
const id = findNodeAtLocation(child, ['id']);
if (id && id.type === 'string') {
activationEvents.add(`onTerminalQuickFixRequest:${id.value}`);
}
});
return activationEvents;
}