diff --git a/eslint.config.mjs b/eslint.config.mjs index 37f031fe43f4b..c50a980813f03 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -156,6 +156,10 @@ export default ts.config( }, ], '@typescript-eslint/consistent-type-imports': ['error', { disallowTypeAnnotations: false }], + '@typescript-eslint/explicit-module-boundary-types': [ + 'error', + { allowArgumentsExplicitlyTypedAsAny: true }, + ], '@typescript-eslint/naming-convention': [ 'error', { @@ -414,6 +418,7 @@ export default ts.config( }, }, rules: { + '@typescript-eslint/explicit-module-boundary-types': 'off', '@typescript-eslint/no-restricted-imports': [ 'error', { diff --git a/src/ai/aiProviderService.ts b/src/ai/aiProviderService.ts index c8f05798f07c7..74d3443b96424 100644 --- a/src/ai/aiProviderService.ts +++ b/src/ai/aiProviderService.ts @@ -98,11 +98,11 @@ export class AIProviderService implements Disposable { constructor(private readonly container: Container) {} - dispose() { + dispose(): void { this._provider?.dispose(); } - get currentProviderId() { + get currentProviderId(): AIProviders | undefined { return this._provider?.id; } @@ -486,7 +486,7 @@ export class AIProviderService implements Disposable { } } - async reset(all?: boolean) { + async reset(all?: boolean): Promise { let { _provider: provider } = this; if (provider == null) { // If we have no provider, try to get the current model (which will load the provider) @@ -540,11 +540,11 @@ export class AIProviderService implements Disposable { } } - supports(provider: AIProviders | string) { + supports(provider: AIProviders | string): boolean { return _supportedProviderTypes.has(provider as AIProviders); } - async switchModel() { + async switchModel(): Promise { void (await this.getModel({ force: true })); } } @@ -702,7 +702,7 @@ function splitMessageIntoSummaryAndBody(message: string): AIResult { }; } -export function showDiffTruncationWarning(maxCodeCharacters: number, model: AIModel) { +export function showDiffTruncationWarning(maxCodeCharacters: number, model: AIModel): void { void window.showWarningMessage( `The diff of the changes had to be truncated to ${maxCodeCharacters} characters to fit within the ${getPossessiveForm( model.provider.name, diff --git a/src/ai/geminiProvider.ts b/src/ai/geminiProvider.ts index 893ff6c860ef8..c17f2d640bbb5 100644 --- a/src/ai/geminiProvider.ts +++ b/src/ai/geminiProvider.ts @@ -1,4 +1,5 @@ import type { CancellationToken } from 'vscode'; +import type { Response } from '@env/fetch'; import type { AIModel } from './aiProviderService'; import { OpenAICompatibleProvider } from './openAICompatibleProvider'; @@ -71,7 +72,7 @@ export class GeminiProvider extends OpenAICompatibleProvider apiKey: string, request: object, cancellation: CancellationToken | undefined, - ) { + ): Promise { if ('max_completion_tokens' in request) { const { max_completion_tokens: _, ...rest } = request; request = rest; diff --git a/src/ai/openAICompatibleProvider.ts b/src/ai/openAICompatibleProvider.ts index 0eaf10390561b..338d7e7261269 100644 --- a/src/ai/openAICompatibleProvider.ts +++ b/src/ai/openAICompatibleProvider.ts @@ -1,4 +1,5 @@ import type { CancellationToken } from 'vscode'; +import type { Response } from '@env/fetch'; import { fetch } from '@env/fetch'; import type { AIProviders } from '../constants.ai'; import type { TelemetryEvents } from '../constants.telemetry'; @@ -30,7 +31,7 @@ export interface AIProviderConfig { export abstract class OpenAICompatibleProvider implements AIProvider { constructor(protected readonly container: Container) {} - dispose() {} + dispose(): void {} abstract readonly id: T; abstract readonly name: string; @@ -261,7 +262,7 @@ export abstract class OpenAICompatibleProvider implements apiKey: string, request: object, cancellation: CancellationToken | undefined, - ) { + ): Promise { let aborter: AbortController | undefined; if (cancellation != null) { aborter = new AbortController(); diff --git a/src/ai/vscodeProvider.ts b/src/ai/vscodeProvider.ts index 4d923c5fe2851..2c88381b108e3 100644 --- a/src/ai/vscodeProvider.ts +++ b/src/ai/vscodeProvider.ts @@ -28,13 +28,13 @@ export class VSCodeAIProvider implements AIProvider { readonly id = provider.id; private _name: string | undefined; - get name() { + get name(): string { return this._name ?? provider.name; } constructor(private readonly container: Container) {} - dispose() {} + dispose(): void {} async getModels(): Promise[]> { const models = await lm.selectChatModels(); diff --git a/src/annotations/annotationProvider.ts b/src/annotations/annotationProvider.ts index 4680691b5a82e..9d16b6731a163 100644 --- a/src/annotations/annotationProvider.ts +++ b/src/annotations/annotationProvider.ts @@ -52,7 +52,7 @@ export abstract class AnnotationProviderBase { if (this._computing?.pending) { await this._computing.promise; } @@ -156,7 +156,7 @@ export abstract class AnnotationProviderBase; - refresh(replaceDecorationTypes: Map) { + refresh(replaceDecorationTypes: Map): void { if (this.editor == null || !this.decorations?.length) return; const decorations = []; @@ -175,7 +175,7 @@ export abstract class AnnotationProviderBase; validate?(): boolean | Promise; - protected setDecorations(decorations: Decoration[]) { + protected setDecorations(decorations: Decoration[]): void { if (this.decorations?.length) { // If we have no new decorations, just completely clear the old ones if (!decorations?.length) { diff --git a/src/annotations/annotations.ts b/src/annotations/annotations.ts index 37c6a77730295..ae466f47e410d 100644 --- a/src/annotations/annotations.ts +++ b/src/annotations/annotations.ts @@ -64,8 +64,12 @@ const defaultHeatmapColors = [ '#0a60f6', ]; -let heatmapColors: { hot: string[]; cold: string[] } | undefined; -export function getHeatmapColors() { +interface HeatmapColors { + hot: string[]; + cold: string[]; +} +let heatmapColors: HeatmapColors | undefined; +export function getHeatmapColors(): HeatmapColors { if (heatmapColors == null) { const { coldColor, hotColor } = configuration.get('heatmap'); @@ -91,7 +95,7 @@ export function getHeatmapColors() { return heatmapColors; } -export function applyHeatmap(decoration: Partial, date: Date, heatmap: ComputedHeatmap) { +export function applyHeatmap(decoration: Partial, date: Date, heatmap: ComputedHeatmap): void { const [r, g, b, a] = getHeatmapColor(date, heatmap); decoration.renderOptions!.before!.borderColor = `rgba(${r},${g},${b},${a})`; } @@ -101,7 +105,7 @@ export function addOrUpdateGutterHeatmapDecoration( heatmap: ComputedHeatmap, range: Range, map: Map>, -) { +): TextEditorDecorationType { const [r, g, b, a] = getHeatmapColor(date, heatmap); const { fadeLines, locations } = configuration.get('heatmap'); diff --git a/src/annotations/blameAnnotationProvider.ts b/src/annotations/blameAnnotationProvider.ts index 0d59824031ff7..d00c07a3e19da 100644 --- a/src/annotations/blameAnnotationProvider.ts +++ b/src/annotations/blameAnnotationProvider.ts @@ -36,7 +36,7 @@ export abstract class BlameAnnotationProviderBase extends AnnotationProviderBase } } - override clear() { + override clear(): Promise { if (this.hoverProviderDisposable != null) { this.hoverProviderDisposable.dispose(); this.hoverProviderDisposable = undefined; @@ -140,7 +140,7 @@ export abstract class BlameAnnotationProviderBase extends AnnotationProviderBase }; } - registerHoverProviders(providers: { details: boolean; changes: boolean }) { + registerHoverProviders(providers: { details: boolean; changes: boolean }): void { const cfg = configuration.get('hovers'); if (!cfg.enabled || !cfg.annotations.enabled || (!providers.details && !providers.changes)) { return; diff --git a/src/annotations/fileAnnotationController.ts b/src/annotations/fileAnnotationController.ts index c5a705595739e..f8a5d7208f9dd 100644 --- a/src/annotations/fileAnnotationController.ts +++ b/src/annotations/fileAnnotationController.ts @@ -81,7 +81,7 @@ export class FileAnnotationController implements Disposable { this._toggleModes = new Map(); } - dispose() { + dispose(): void { void this.clearAll(); Decorations.gutterBlameAnnotation?.dispose(); @@ -280,7 +280,7 @@ export class FileAnnotationController implements Disposable { } @log({ args: { 0: e => e?.document.uri.toString(true) } }) - clear(editor: TextEditor | undefined) { + clear(editor: TextEditor | undefined): Promise | undefined { if (this.isInWindowToggle()) return this.clearAll(); if (editor == null) return; @@ -288,7 +288,7 @@ export class FileAnnotationController implements Disposable { } @log() - async clearAll() { + async clearAll(): Promise { this._windowAnnotationType = undefined; for (const [key] of this._annotationProviders) { @@ -335,7 +335,10 @@ export class FileAnnotationController implements Disposable { private readonly _annotatedUris = new UriSet(); private readonly _computingUris = new UriSet(); - async onProviderEditorStatusChanged(editor: TextEditor | undefined, status: AnnotationStatus | undefined) { + async onProviderEditorStatusChanged( + editor: TextEditor | undefined, + status: AnnotationStatus | undefined, + ): Promise { if (editor == null) return; let changed = false; @@ -530,13 +533,13 @@ export class FileAnnotationController implements Disposable { } @log() - nextChange() { + nextChange(): void { const provider = this.getProvider(window.activeTextEditor); provider?.nextChange?.(); } @log() - previousChange() { + previousChange(): void { const provider = this.getProvider(window.activeTextEditor); provider?.previousChange?.(); } diff --git a/src/annotations/gutterBlameAnnotationProvider.ts b/src/annotations/gutterBlameAnnotationProvider.ts index 52d0d7fc6ecf5..ce3ceaeecc527 100644 --- a/src/annotations/gutterBlameAnnotationProvider.ts +++ b/src/annotations/gutterBlameAnnotationProvider.ts @@ -39,7 +39,7 @@ export class GutterBlameAnnotationProvider extends BlameAnnotationProviderBase { super(container, onDidChangeStatus, 'blame', editor, trackedDocument); } - override async clear() { + override async clear(): Promise { await super.clear(); if (Decorations.gutterBlameHighlight != null) { diff --git a/src/annotations/gutterChangesAnnotationProvider.ts b/src/annotations/gutterChangesAnnotationProvider.ts index 09ded4afb68da..b455377d2d559 100644 --- a/src/annotations/gutterChangesAnnotationProvider.ts +++ b/src/annotations/gutterChangesAnnotationProvider.ts @@ -40,7 +40,7 @@ export class GutterChangesAnnotationProvider extends AnnotationProviderBase { this.state = undefined; if (this.hoverProviderDisposable != null) { this.hoverProviderDisposable.dispose(); @@ -49,7 +49,7 @@ export class GutterChangesAnnotationProvider extends AnnotationProviderBase { this._enabled = !(this._enabled && !this.suspended); if (this._enabled) { diff --git a/src/api/actionRunners.ts b/src/api/actionRunners.ts index 85a9c5cde1329..8d959de747444 100644 --- a/src/api/actionRunners.ts +++ b/src/api/actionRunners.ts @@ -68,7 +68,7 @@ class RegisteredActionRunner implements this.id = runnerIdGenerator.next(); } - dispose() { + dispose(): void { this.unregister(); } @@ -146,7 +146,7 @@ export class ActionRunners implements Disposable { this._disposable = Disposable.from(...subscriptions); } - dispose() { + dispose(): void { this._disposable.dispose(); for (const runners of this._actionRunners.values()) { @@ -238,7 +238,7 @@ export class ActionRunners implements Disposable { ); } - async run(context: T, runnerId?: number) { + async run(context: T, runnerId?: number): Promise { let runners = this.get(context.type); if (runners == null || runners.length === 0) return; diff --git a/src/api/api.ts b/src/api/api.ts index b2ea2c6e18dfa..7131bd219c533 100644 --- a/src/api/api.ts +++ b/src/api/api.ts @@ -32,7 +32,7 @@ export class Api implements GitLensApi { } export function preview() { - return (_target: any, _key: string, descriptor: PropertyDescriptor) => { + return (_target: any, _key: string, descriptor: PropertyDescriptor): void => { // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type let fn: Function | undefined; if (typeof descriptor.value === 'function') { diff --git a/src/autolinks/autolinks.ts b/src/autolinks/autolinks.ts index 95acf7ff33016..e7c234db5b286 100644 --- a/src/autolinks/autolinks.ts +++ b/src/autolinks/autolinks.ts @@ -45,7 +45,7 @@ export class Autolinks implements Disposable { this.setAutolinksFromConfig(); } - dispose() { + dispose(): void { this._disposable?.dispose(); } diff --git a/src/autolinks/autolinks.utils.ts b/src/autolinks/autolinks.utils.ts index 1be9c216a6702..6c51d15fe3155 100644 --- a/src/autolinks/autolinks.utils.ts +++ b/src/autolinks/autolinks.utils.ts @@ -141,19 +141,22 @@ function compareAutolinks(a: Autolink, b: Autolink): number { ); } -function ensureCachedRegex( +export function ensureCachedRegex( ref: CacheableAutolinkReference, outputFormat: 'html', ): asserts ref is RequireSome; -function ensureCachedRegex( +export function ensureCachedRegex( ref: CacheableAutolinkReference, outputFormat: 'markdown', ): asserts ref is RequireSome; -function ensureCachedRegex( +export function ensureCachedRegex( ref: CacheableAutolinkReference, outputFormat: 'plaintext', ): asserts ref is RequireSome; -function ensureCachedRegex(ref: CacheableAutolinkReference, outputFormat: 'html' | 'markdown' | 'plaintext') { +export function ensureCachedRegex( + ref: CacheableAutolinkReference, + outputFormat: 'html' | 'markdown' | 'plaintext', +): boolean { // Regexes matches the ref prefix followed by a token (e.g. #1234) if (outputFormat === 'markdown' && ref.messageMarkdownRegex == null) { // Extra `\\\\` in `\\\\\\[` is because the markdown is escaped @@ -184,11 +187,9 @@ function ensureCachedRegex(ref: CacheableAutolinkReference, outputFormat: 'html' return true; } -export { ensureCachedRegex }; - export const numRegex = //g; -export function getAutolinks(message: string, refsets: Readonly) { +export function getAutolinks(message: string, refsets: Readonly): Map { const autolinks = new Map(); let match; @@ -230,7 +231,7 @@ export function getAutolinks(message: string, refsets: Readonly) { return autolinks; } -export function getBranchAutolinks(branchName: string, refsets: Readonly) { +export function getBranchAutolinks(branchName: string, refsets: Readonly): Map { const autolinks = new Map(); let match; diff --git a/src/avatars.ts b/src/avatars.ts index ceaf934dc2875..4a5e924c23d9d 100644 --- a/src/avatars.ts +++ b/src/avatars.ts @@ -276,7 +276,7 @@ const presenceStatusColorMap = new Map([ ['offline', '#cecece'], ]); -export function getPresenceDataUri(status: ContactPresenceStatus) { +export function getPresenceDataUri(status: ContactPresenceStatus): string { let dataUri = presenceCache.get(status); if (dataUri == null) { const contents = base64(` @@ -290,7 +290,7 @@ export function getPresenceDataUri(status: ContactPresenceStatus) { return dataUri; } -export function resetAvatarCache(reset: 'all' | 'failed' | 'fallback') { +export function resetAvatarCache(reset: 'all' | 'failed' | 'fallback'): void { switch (reset) { case 'all': void Container.instance.storage.delete('avatars'); @@ -324,7 +324,7 @@ function getDefaultGravatarStyle() { return defaultGravatarsStyle; } -export function setDefaultGravatarsStyle(style: GravatarDefaultStyle) { +export function setDefaultGravatarsStyle(style: GravatarDefaultStyle): void { defaultGravatarsStyle = style; resetAvatarCache('fallback'); } diff --git a/src/cache.ts b/src/cache.ts index 91b0cbaad9080..a24f6125ed8ea 100644 --- a/src/cache.ts +++ b/src/cache.ts @@ -50,11 +50,11 @@ export class CacheProvider implements Disposable { // eslint-disable-next-line @typescript-eslint/no-useless-constructor constructor(_container: Container) {} - dispose() { + dispose(): void { this._cache.clear(); } - delete(cache: T, key: CacheKey) { + delete(cache: T, key: CacheKey): void { this._cache.delete(`${cache}:${key}`); } diff --git a/src/codelens/codeLensController.ts b/src/codelens/codeLensController.ts index d3de563606aee..863de871e1208 100644 --- a/src/codelens/codeLensController.ts +++ b/src/codelens/codeLensController.ts @@ -23,7 +23,7 @@ export class GitCodeLensController implements Disposable { ); } - dispose() { + dispose(): void { this._providerDisposable?.dispose(); this._disposable?.dispose(); } @@ -76,7 +76,7 @@ export class GitCodeLensController implements Disposable { } @log() - toggleCodeLens() { + toggleCodeLens(): void { const scope = getLogScope(); if (!this._canToggle) { diff --git a/src/codelens/codeLensProvider.ts b/src/codelens/codeLensProvider.ts index ec1d5ad8b32bb..775b0012f278d 100644 --- a/src/codelens/codeLensProvider.ts +++ b/src/codelens/codeLensProvider.ts @@ -85,7 +85,7 @@ export class GitCodeLensProvider implements CodeLensProvider { constructor(private readonly container: Container) {} - reset() { + reset(): void { this._onDidChangeCodeLenses.fire(); } diff --git a/src/commands/addAuthors.ts b/src/commands/addAuthors.ts index cb7945741a25b..f18f3b2e5ae7c 100644 --- a/src/commands/addAuthors.ts +++ b/src/commands/addAuthors.ts @@ -11,7 +11,7 @@ export class AddAuthorsCommand extends GlCommandBase { super(GlCommand.AddAuthors); } - execute(sourceControl: SourceControl) { + execute(sourceControl: SourceControl): Promise { let repo; if (sourceControl?.rootUri != null) { repo = this.container.git.getRepository(sourceControl.rootUri); diff --git a/src/commands/browseRepoAtRevision.ts b/src/commands/browseRepoAtRevision.ts index 4fcf35fbdd711..a6621c3c593ea 100644 --- a/src/commands/browseRepoAtRevision.ts +++ b/src/commands/browseRepoAtRevision.ts @@ -29,7 +29,7 @@ export class BrowseRepoAtRevisionCommand extends ActiveEditorCommand { ]); } - protected override preExecute(context: CommandContext, args?: BrowseRepoAtRevisionCommandArgs) { + protected override preExecute(context: CommandContext, args?: BrowseRepoAtRevisionCommandArgs): Promise { switch (context.command) { case GlCommand.BrowseRepoAtRevisionInNewWindow: args = { ...args, before: false, openInNewWindow: true }; @@ -45,7 +45,7 @@ export class BrowseRepoAtRevisionCommand extends ActiveEditorCommand { return this.execute(context.editor, context.uri, args); } - async execute(editor: TextEditor | undefined, uri?: Uri, args?: BrowseRepoAtRevisionCommandArgs) { + async execute(editor: TextEditor | undefined, uri?: Uri, args?: BrowseRepoAtRevisionCommandArgs): Promise { args = { ...args }; try { diff --git a/src/commands/closeUnchangedFiles.ts b/src/commands/closeUnchangedFiles.ts index c478f107c682b..1041d252284ff 100644 --- a/src/commands/closeUnchangedFiles.ts +++ b/src/commands/closeUnchangedFiles.ts @@ -19,7 +19,7 @@ export class CloseUnchangedFilesCommand extends GlCommandBase { super(GlCommand.CloseUnchangedFiles); } - async execute(args?: CloseUnchangedFilesCommandArgs) { + async execute(args?: CloseUnchangedFilesCommandArgs): Promise { args = { ...args }; try { diff --git a/src/commands/cloudIntegrations.ts b/src/commands/cloudIntegrations.ts index be31a5e9713b3..d02daf096e116 100644 --- a/src/commands/cloudIntegrations.ts +++ b/src/commands/cloudIntegrations.ts @@ -18,7 +18,7 @@ export class ManageCloudIntegrationsCommand extends GlCommandBase { super(GlCommand.PlusManageCloudIntegrations); } - async execute(args?: ManageCloudIntegrationsCommandArgs) { + async execute(args?: ManageCloudIntegrationsCommandArgs): Promise { await this.container.integrations.manageCloudIntegrations( args?.source ? { source: args.source, detail: args?.detail } : undefined, ); @@ -38,7 +38,7 @@ export class ConnectCloudIntegrationsCommand extends GlCommandBase { super(GlCommand.PlusConnectCloudIntegrations); } - async execute(args?: ConnectCloudIntegrationsCommandArgs) { + async execute(args?: ConnectCloudIntegrationsCommandArgs): Promise { await this.container.integrations.connectCloudIntegrations( args?.integrationIds ? { integrationIds: args.integrationIds } : undefined, args?.source ? { source: args.source, detail: args?.detail } : undefined, diff --git a/src/commands/commandBase.ts b/src/commands/commandBase.ts index 1cb8e739dae9a..211ecaf0765b5 100644 --- a/src/commands/commandBase.ts +++ b/src/commands/commandBase.ts @@ -25,7 +25,7 @@ export abstract class GlCommandBase implements Disposable { this._disposable = Disposable.from(...subscriptions); } - dispose() { + dispose(): void { this._disposable.dispose(); } @@ -68,7 +68,7 @@ export abstract class ActiveEditorCommand extends GlCommandBase { } let lastCommand: { command: string; args: any[] } | undefined = undefined; -export function getLastCommand() { +export function getLastCommand(): { command: string; args: any[] } | undefined { return lastCommand; } @@ -107,7 +107,7 @@ export abstract class EditorCommand implements Disposable { this._disposable = Disposable.from(...subscriptions); } - dispose() { + dispose(): void { this._disposable.dispose(); } diff --git a/src/commands/compareWith.ts b/src/commands/compareWith.ts index a1defe36bad1b..ac95729c02572 100644 --- a/src/commands/compareWith.ts +++ b/src/commands/compareWith.ts @@ -26,7 +26,7 @@ export class CompareWithCommand extends ActiveEditorCommand { ]); } - protected override preExecute(context: CommandContext, args?: CompareWithCommandArgs) { + protected override preExecute(context: CommandContext, args?: CompareWithCommandArgs): Promise { switch (context.command) { case GlCommand.CompareWith: args = { ...args }; @@ -48,7 +48,7 @@ export class CompareWithCommand extends ActiveEditorCommand { return this.execute(context.editor, context.uri, args); } - async execute(editor?: TextEditor, uri?: Uri, args?: CompareWithCommandArgs) { + async execute(editor?: TextEditor, uri?: Uri, args?: CompareWithCommandArgs): Promise { uri = getCommandUri(uri, editor); args = { ...args }; diff --git a/src/commands/copyCurrentBranch.ts b/src/commands/copyCurrentBranch.ts index 0e277bcf41c5e..748ac1502c6a9 100644 --- a/src/commands/copyCurrentBranch.ts +++ b/src/commands/copyCurrentBranch.ts @@ -16,7 +16,7 @@ export class CopyCurrentBranchCommand extends ActiveEditorCommand { super(GlCommand.CopyCurrentBranch); } - async execute(editor?: TextEditor, uri?: Uri) { + async execute(editor?: TextEditor, uri?: Uri): Promise { uri = getCommandUri(uri, editor); const gitUri = uri != null ? await GitUri.fromUri(uri) : undefined; diff --git a/src/commands/copyDeepLink.ts b/src/commands/copyDeepLink.ts index 1ba2286517466..716bbe5bb418b 100644 --- a/src/commands/copyDeepLink.ts +++ b/src/commands/copyDeepLink.ts @@ -49,7 +49,7 @@ export class CopyDeepLinkCommand extends ActiveEditorCommand { ]); } - protected override preExecute(context: CommandContext, args?: CopyDeepLinkCommandArgs) { + protected override preExecute(context: CommandContext, args?: CopyDeepLinkCommandArgs): Promise { if (args == null) { if (isCommandContextViewNodeHasCommit(context)) { args = { refOrRepoPath: context.node.commit }; @@ -80,7 +80,7 @@ export class CopyDeepLinkCommand extends ActiveEditorCommand { return this.execute(context.editor, context.uri, args); } - async execute(editor?: TextEditor, uri?: Uri, args?: CopyDeepLinkCommandArgs) { + async execute(editor?: TextEditor, uri?: Uri, args?: CopyDeepLinkCommandArgs): Promise { args = { ...args }; if (args.workspaceId != null) { @@ -185,7 +185,7 @@ export class CopyFileDeepLinkCommand extends ActiveEditorCommand { super([GlCommand.CopyDeepLinkToFile, GlCommand.CopyDeepLinkToFileAtRevision, GlCommand.CopyDeepLinkToLines]); } - protected override preExecute(context: CommandContext, args?: CopyFileDeepLinkCommandArgs) { + protected override preExecute(context: CommandContext, args?: CopyFileDeepLinkCommandArgs): Promise { if (args == null) { args = {}; } @@ -212,7 +212,7 @@ export class CopyFileDeepLinkCommand extends ActiveEditorCommand { return this.execute(context.editor, context.uri, args); } - async execute(editor?: TextEditor, uri?: Uri, args?: CopyFileDeepLinkCommandArgs) { + async execute(editor?: TextEditor, uri?: Uri, args?: CopyFileDeepLinkCommandArgs): Promise { args = { ...args }; const type = DeepLinkType.File; diff --git a/src/commands/copyMessageToClipboard.ts b/src/commands/copyMessageToClipboard.ts index 39bf66da41111..c188b8fef7b0b 100644 --- a/src/commands/copyMessageToClipboard.ts +++ b/src/commands/copyMessageToClipboard.ts @@ -29,7 +29,10 @@ export class CopyMessageToClipboardCommand extends ActiveEditorCommand { super(GlCommand.CopyMessageToClipboard); } - protected override async preExecute(context: CommandContext, args?: CopyMessageToClipboardCommandArgs) { + protected override async preExecute( + context: CommandContext, + args?: CopyMessageToClipboardCommandArgs, + ): Promise { if (isCommandContextViewNodeHasCommit(context)) { args = { ...args }; args.sha = context.node.commit.sha; @@ -55,7 +58,7 @@ export class CopyMessageToClipboardCommand extends ActiveEditorCommand { return this.execute(context.editor, context.uri, args); } - async execute(editor?: TextEditor, uri?: Uri, args?: CopyMessageToClipboardCommandArgs) { + async execute(editor?: TextEditor, uri?: Uri, args?: CopyMessageToClipboardCommandArgs): Promise { uri = getCommandUri(uri, editor); args = { ...args }; diff --git a/src/commands/copyRelativePathToClipboard.ts b/src/commands/copyRelativePathToClipboard.ts index 588d319621b0c..ca6d4cb66192a 100644 --- a/src/commands/copyRelativePathToClipboard.ts +++ b/src/commands/copyRelativePathToClipboard.ts @@ -14,7 +14,7 @@ export class CopyRelativePathToClipboardCommand extends ActiveEditorCommand { super(GlCommand.CopyRelativePathToClipboard); } - protected override preExecute(context: CommandContext) { + protected override preExecute(context: CommandContext): Promise { if (isCommandContextViewNodeHasFileCommit(context)) { return this.execute(context.editor, context.node.commit.file!.uri); } @@ -22,7 +22,7 @@ export class CopyRelativePathToClipboardCommand extends ActiveEditorCommand { return this.execute(context.editor, context.uri); } - async execute(editor?: TextEditor, uri?: Uri) { + async execute(editor?: TextEditor, uri?: Uri): Promise { uri = getCommandUri(uri, editor); let relativePath = ''; if (uri != null) { @@ -33,6 +33,5 @@ export class CopyRelativePathToClipboardCommand extends ActiveEditorCommand { } await env.clipboard.writeText(relativePath); - return undefined; } } diff --git a/src/commands/copyShaToClipboard.ts b/src/commands/copyShaToClipboard.ts index 3b3ddd9024171..855c84b53bacd 100644 --- a/src/commands/copyShaToClipboard.ts +++ b/src/commands/copyShaToClipboard.ts @@ -28,7 +28,7 @@ export class CopyShaToClipboardCommand extends ActiveEditorCommand { super(GlCommand.CopyShaToClipboard); } - protected override preExecute(context: CommandContext, args?: CopyShaToClipboardCommandArgs) { + protected override preExecute(context: CommandContext, args?: CopyShaToClipboardCommandArgs): Promise { if (isCommandContextViewNodeHasCommit(context)) { args = { ...args }; args.sha = context.node.commit.sha; @@ -50,7 +50,7 @@ export class CopyShaToClipboardCommand extends ActiveEditorCommand { return this.execute(context.editor, context.uri, args); } - async execute(editor?: TextEditor, uri?: Uri, args?: CopyShaToClipboardCommandArgs) { + async execute(editor?: TextEditor, uri?: Uri, args?: CopyShaToClipboardCommandArgs): Promise { uri = getCommandUri(uri, editor); args = { ...args }; diff --git a/src/commands/createPullRequestOnRemote.ts b/src/commands/createPullRequestOnRemote.ts index 9fd7881f8ff70..73db3ea546f44 100644 --- a/src/commands/createPullRequestOnRemote.ts +++ b/src/commands/createPullRequestOnRemote.ts @@ -26,7 +26,7 @@ export class CreatePullRequestOnRemoteCommand extends GlCommandBase { super(GlCommand.CreatePullRequestOnRemote); } - async execute(args?: CreatePullRequestOnRemoteCommandArgs) { + async execute(args?: CreatePullRequestOnRemoteCommandArgs): Promise { let repo; if (args?.repoPath != null) { repo = this.container.git.getRepository(args.repoPath); diff --git a/src/commands/diffWithNext.ts b/src/commands/diffWithNext.ts index 815502edd7b27..7f6fee827bdca 100644 --- a/src/commands/diffWithNext.ts +++ b/src/commands/diffWithNext.ts @@ -26,7 +26,7 @@ export class DiffWithNextCommand extends ActiveEditorCommand { super([GlCommand.DiffWithNext, GlCommand.DiffWithNextInDiffLeft, GlCommand.DiffWithNextInDiffRight]); } - protected override preExecute(context: CommandContext, args?: DiffWithNextCommandArgs) { + protected override preExecute(context: CommandContext, args?: DiffWithNextCommandArgs): Promise { if (context.command === GlCommand.DiffWithNextInDiffLeft) { args = { ...args, inDiffLeftEditor: true }; } @@ -34,7 +34,7 @@ export class DiffWithNextCommand extends ActiveEditorCommand { return this.execute(context.editor, context.uri, args); } - async execute(editor?: TextEditor, uri?: Uri, args?: DiffWithNextCommandArgs) { + async execute(editor?: TextEditor, uri?: Uri, args?: DiffWithNextCommandArgs): Promise { uri = getCommandUri(uri, editor); if (uri == null) return; diff --git a/src/commands/diffWithPrevious.ts b/src/commands/diffWithPrevious.ts index be68c5524ad71..2e6dc73cda324 100644 --- a/src/commands/diffWithPrevious.ts +++ b/src/commands/diffWithPrevious.ts @@ -32,7 +32,7 @@ export class DiffWithPreviousCommand extends ActiveEditorCommand { ]); } - protected override preExecute(context: CommandContext, args?: DiffWithPreviousCommandArgs) { + protected override preExecute(context: CommandContext, args?: DiffWithPreviousCommandArgs): Promise { if (context.command === GlCommand.DiffWithPreviousInDiffRight) { args = { ...args, inDiffRightEditor: true }; } @@ -40,7 +40,7 @@ export class DiffWithPreviousCommand extends ActiveEditorCommand { return this.execute(context.editor, context.uri, args); } - async execute(editor?: TextEditor, uri?: Uri, args?: DiffWithPreviousCommandArgs) { + async execute(editor?: TextEditor, uri?: Uri, args?: DiffWithPreviousCommandArgs): Promise { args = { ...args }; if (args.uri == null) { uri = getCommandUri(uri, editor); diff --git a/src/commands/diffWithRevisionFrom.ts b/src/commands/diffWithRevisionFrom.ts index e35c9c5fc75ec..0e5e8783119ee 100644 --- a/src/commands/diffWithRevisionFrom.ts +++ b/src/commands/diffWithRevisionFrom.ts @@ -27,7 +27,7 @@ export class DiffWithRevisionFromCommand extends ActiveEditorCommand { super(GlCommand.DiffWithRevisionFrom); } - async execute(editor?: TextEditor, uri?: Uri, args?: DiffWithRevisionFromCommandArgs) { + async execute(editor?: TextEditor, uri?: Uri, args?: DiffWithRevisionFromCommandArgs): Promise { uri = getCommandUri(uri, editor); if (uri == null) return; diff --git a/src/commands/externalDiff.ts b/src/commands/externalDiff.ts index fac7232d3f3ff..3e099c11917b8 100644 --- a/src/commands/externalDiff.ts +++ b/src/commands/externalDiff.ts @@ -33,7 +33,7 @@ export class ExternalDiffCommand extends GlCommandBase { super([GlCommand.ExternalDiff, GlCommand.ExternalDiffAll]); } - protected override async preExecute(context: CommandContext, args?: ExternalDiffCommandArgs) { + protected override async preExecute(context: CommandContext, args?: ExternalDiffCommandArgs): Promise { args = { ...args }; if (isCommandContextViewNodeHasFileCommit(context)) { @@ -87,11 +87,11 @@ export class ExternalDiffCommand extends GlCommandBase { if (context.command === GlCommand.ExternalDiffAll) { if (args.files == null) { const repository = await getRepositoryOrShowPicker('Open All Changes (difftool)'); - if (repository == null) return undefined; + if (repository == null) return; const status = await this.container.git.status(repository.uri).getStatus(); if (status == null) { - return window.showInformationMessage("The repository doesn't have any changes"); + return void window.showInformationMessage("The repository doesn't have any changes"); } args.files = []; @@ -118,7 +118,7 @@ export class ExternalDiffCommand extends GlCommandBase { ); } - async execute(args?: ExternalDiffCommandArgs) { + async execute(args?: ExternalDiffCommandArgs): Promise { args = { ...args }; try { diff --git a/src/commands/generateCommitMessage.ts b/src/commands/generateCommitMessage.ts index b2064157f446b..0d39ca9c3ea06 100644 --- a/src/commands/generateCommitMessage.ts +++ b/src/commands/generateCommitMessage.ts @@ -23,7 +23,7 @@ export class GenerateCommitMessageCommand extends ActiveEditorCommand { super([GlCommand.GenerateCommitMessage, GlCommand.GenerateCommitMessageScm]); } - protected override preExecute(context: CommandContext, args?: GenerateCommitMessageCommandArgs) { + protected override preExecute(context: CommandContext, args?: GenerateCommitMessageCommandArgs): Promise { let source: Sources | undefined = args?.source; if (source == null && context.command === GlCommand.GenerateCommitMessageScm) { source = 'scm-input'; @@ -32,7 +32,7 @@ export class GenerateCommitMessageCommand extends ActiveEditorCommand { return this.execute(context.editor, context.uri, { ...args, source: source }); } - async execute(editor?: TextEditor, uri?: Uri, args?: GenerateCommitMessageCommandArgs) { + async execute(editor?: TextEditor, uri?: Uri, args?: GenerateCommitMessageCommandArgs): Promise { args = { ...args }; let repository; diff --git a/src/commands/ghpr/openOrCreateWorktree.ts b/src/commands/ghpr/openOrCreateWorktree.ts index 6b9805b700b7f..0e5a29adb16b2 100644 --- a/src/commands/ghpr/openOrCreateWorktree.ts +++ b/src/commands/ghpr/openOrCreateWorktree.ts @@ -50,7 +50,7 @@ export class OpenOrCreateWorktreeCommand extends GlCommandBase { super(GlCommand.OpenOrCreateWorktreeForGHPR); } - async execute(...args: [GHPRPullRequestNode | GHPRPullRequest, ...unknown[]]) { + async execute(...args: [GHPRPullRequestNode | GHPRPullRequest, ...unknown[]]): Promise { const [arg] = args; let pr; if ('pullRequestModel' in arg) { diff --git a/src/commands/git/branch.ts b/src/commands/git/branch.ts index 236e31d3138ab..dbb6c2e5fea74 100644 --- a/src/commands/git/branch.ts +++ b/src/commands/git/branch.ts @@ -231,7 +231,7 @@ export class BranchGitCommand extends QuickCommand { : super.canSkipConfirm; } - override get skipConfirmKey() { + override get skipConfirmKey(): string { return `${this.key}${this.subcommand == null ? '' : `-${this.subcommand}`}:${this.pickedVia}`; } diff --git a/src/commands/git/cherry-pick.ts b/src/commands/git/cherry-pick.ts index 48a87f968f75c..38d82548ba2a1 100644 --- a/src/commands/git/cherry-pick.ts +++ b/src/commands/git/cherry-pick.ts @@ -81,11 +81,11 @@ export class CherryPickGitCommand extends QuickCommand { return false; } - execute(state: CherryPickStepState>) { + private execute(state: CherryPickStepState>) { state.repo.cherryPick(...state.flags, ...state.references.map(c => c.ref).reverse()); } - override isFuzzyMatch(name: string) { + override isFuzzyMatch(name: string): boolean { return super.isFuzzyMatch(name) || name === 'cherry'; } diff --git a/src/commands/git/coauthors.ts b/src/commands/git/coauthors.ts index 69bfa4fb1910d..63a67af5c66f0 100644 --- a/src/commands/git/coauthors.ts +++ b/src/commands/git/coauthors.ts @@ -52,11 +52,11 @@ export class CoAuthorsGitCommand extends QuickCommand { }; } - override get canConfirm() { + override get canConfirm(): boolean { return false; } - async execute(state: CoAuthorStepState) { + private async execute(state: CoAuthorStepState) { const repo = await this.container.git.getOrOpenScmRepository(state.repo.path); if (repo == null) return; diff --git a/src/commands/git/fetch.ts b/src/commands/git/fetch.ts index d55a9c783bed8..03156edc207d3 100644 --- a/src/commands/git/fetch.ts +++ b/src/commands/git/fetch.ts @@ -58,7 +58,7 @@ export class FetchGitCommand extends QuickCommand { }; } - execute(state: FetchStepState) { + private execute(state: FetchStepState) { if (isBranchReference(state.reference)) { return state.repos[0].fetch({ branch: state.reference }); } diff --git a/src/commands/git/log.ts b/src/commands/git/log.ts index c096a45c13853..f5e1feaaad624 100644 --- a/src/commands/git/log.ts +++ b/src/commands/git/log.ts @@ -79,7 +79,7 @@ export class LogGitCommand extends QuickCommand { return false; } - override isFuzzyMatch(name: string) { + override isFuzzyMatch(name: string): boolean { return super.isFuzzyMatch(name) || name === 'log'; } diff --git a/src/commands/git/merge.ts b/src/commands/git/merge.ts index 13cc595b99041..59c121e07eb1d 100644 --- a/src/commands/git/merge.ts +++ b/src/commands/git/merge.ts @@ -80,7 +80,7 @@ export class MergeGitCommand extends QuickCommand { return false; } - execute(state: MergeStepState) { + private execute(state: MergeStepState) { state.repo.merge(...state.flags, state.reference.ref); } diff --git a/src/commands/git/pull.ts b/src/commands/git/pull.ts index eccc952e0a9a1..4988857524028 100644 --- a/src/commands/git/pull.ts +++ b/src/commands/git/pull.ts @@ -63,7 +63,7 @@ export class PullGitCommand extends QuickCommand { }; } - async execute(state: PullStepState) { + private async execute(state: PullStepState) { if (isBranchReference(state.reference)) { // Only resort to a branch fetch if the branch isn't the current one if (!isBranch(state.reference) || !state.reference.current) { diff --git a/src/commands/git/push.ts b/src/commands/git/push.ts index fd548d442a4c7..954372a010fc7 100644 --- a/src/commands/git/push.ts +++ b/src/commands/git/push.ts @@ -65,7 +65,7 @@ export class PushGitCommand extends QuickCommand { }; } - execute(state: State) { + private execute(state: State) { const index = state.flags.indexOf('--set-upstream'); if (index !== -1) { return this.container.git.pushAll(state.repos, { diff --git a/src/commands/git/rebase.ts b/src/commands/git/rebase.ts index 703394adce1d7..4ba955b74d991 100644 --- a/src/commands/git/rebase.ts +++ b/src/commands/git/rebase.ts @@ -82,7 +82,7 @@ export class RebaseGitCommand extends QuickCommand { return false; } - async execute(state: RebaseStepState) { + private async execute(state: RebaseStepState) { let configs: string[] | undefined; if (state.flags.includes('--interactive')) { await this.container.rebaseEditor.enableForNextUse(); diff --git a/src/commands/git/remote.ts b/src/commands/git/remote.ts index 9e42c9a333686..324c7b7c996de 100644 --- a/src/commands/git/remote.ts +++ b/src/commands/git/remote.ts @@ -176,7 +176,7 @@ export class RemoteGitCommand extends QuickCommand { return this.subcommand === 'remove' || this.subcommand === 'prune' ? false : super.canSkipConfirm; } - override get skipConfirmKey() { + override get skipConfirmKey(): string { return `${this.key}${this.subcommand == null ? '' : `-${this.subcommand}`}:${this.pickedVia}`; } diff --git a/src/commands/git/reset.ts b/src/commands/git/reset.ts index 5d68fff6ca81e..971ebe5e04526 100644 --- a/src/commands/git/reset.ts +++ b/src/commands/git/reset.ts @@ -71,7 +71,7 @@ export class ResetGitCommand extends QuickCommand { return this._canSkipConfirm; } - async execute(state: ResetStepState) { + private async execute(state: ResetStepState) { try { await state.repo.git.reset( { diff --git a/src/commands/git/revert.ts b/src/commands/git/revert.ts index d0bb4331e1f29..2ba758a8e75aa 100644 --- a/src/commands/git/revert.ts +++ b/src/commands/git/revert.ts @@ -71,7 +71,7 @@ export class RevertGitCommand extends QuickCommand { return false; } - execute(state: RevertStepState>) { + private execute(state: RevertStepState>) { state.repo.revert(...state.flags, ...state.references.map(c => c.ref).reverse()); } diff --git a/src/commands/git/search.ts b/src/commands/git/search.ts index 7a10293141366..6be54e32a7bfd 100644 --- a/src/commands/git/search.ts +++ b/src/commands/git/search.ts @@ -119,11 +119,11 @@ export class SearchGitCommand extends QuickCommand { return false; } - override isMatch(key: string) { + override isMatch(key: string): boolean { return super.isMatch(key) || key === 'grep'; } - override isFuzzyMatch(name: string) { + override isFuzzyMatch(name: string): boolean { return super.isFuzzyMatch(name) || name === 'grep'; } diff --git a/src/commands/git/show.ts b/src/commands/git/show.ts index 63dd7b8a95376..79be5d60d9951 100644 --- a/src/commands/git/show.ts +++ b/src/commands/git/show.ts @@ -88,7 +88,7 @@ export class ShowGitCommand extends QuickCommand { }; } - override get canConfirm() { + override get canConfirm(): boolean { return false; } diff --git a/src/commands/git/stash.ts b/src/commands/git/stash.ts index 0a5721f96e3c9..61c53871e752f 100644 --- a/src/commands/git/stash.ts +++ b/src/commands/git/stash.ts @@ -180,7 +180,7 @@ export class StashGitCommand extends QuickCommand { return this.subcommand === 'drop' ? false : super.canSkipConfirm; } - override get skipConfirmKey() { + override get skipConfirmKey(): string { return `${this.key}${this.subcommand == null ? '' : `-${this.subcommand}`}:${this.pickedVia}`; } diff --git a/src/commands/git/status.ts b/src/commands/git/status.ts index 48407591d7167..fa1c1a6cb7968 100644 --- a/src/commands/git/status.ts +++ b/src/commands/git/status.ts @@ -47,7 +47,7 @@ export class StatusGitCommand extends QuickCommand { }; } - override get canConfirm() { + override get canConfirm(): boolean { return false; } diff --git a/src/commands/git/switch.ts b/src/commands/git/switch.ts index 0f9d1f30a774c..8c4374da035c5 100644 --- a/src/commands/git/switch.ts +++ b/src/commands/git/switch.ts @@ -85,7 +85,7 @@ export class SwitchGitCommand extends QuickCommand { return this._canConfirmOverride ?? true; } - async execute(state: SwitchStepState) { + private async execute(state: SwitchStepState) { await window.withProgress( { location: ProgressLocation.Notification, @@ -108,11 +108,11 @@ export class SwitchGitCommand extends QuickCommand { } } - override isMatch(key: string) { + override isMatch(key: string): boolean { return super.isMatch(key) || key === 'checkout'; } - override isFuzzyMatch(name: string) { + override isFuzzyMatch(name: string): boolean { return super.isFuzzyMatch(name) || name === 'checkout'; } diff --git a/src/commands/git/tag.ts b/src/commands/git/tag.ts index ef7701460291c..0d3fe899fc72d 100644 --- a/src/commands/git/tag.ts +++ b/src/commands/git/tag.ts @@ -144,7 +144,7 @@ export class TagGitCommand extends QuickCommand { return this.subcommand === 'delete' ? false : super.canSkipConfirm; } - override get skipConfirmKey() { + override get skipConfirmKey(): string { return `${this.key}${this.subcommand == null ? '' : `-${this.subcommand}`}:${this.pickedVia}`; } diff --git a/src/commands/git/worktree.ts b/src/commands/git/worktree.ts index ae8338a50225b..e438a4b0ae37d 100644 --- a/src/commands/git/worktree.ts +++ b/src/commands/git/worktree.ts @@ -256,7 +256,7 @@ export class WorktreeGitCommand extends QuickCommand { return this._canSkipConfirmOverride ?? this.subcommand === 'open'; } - override get skipConfirmKey() { + override get skipConfirmKey(): string { return `${this.key}${this.subcommand == null ? '' : `-${this.subcommand}`}:${this.pickedVia}`; } diff --git a/src/commands/gitWizard.ts b/src/commands/gitWizard.ts index 3a0203cb543f3..6cdd72d740b23 100644 --- a/src/commands/gitWizard.ts +++ b/src/commands/gitWizard.ts @@ -90,7 +90,7 @@ export class GitWizardCommand extends QuickWizardCommandBase { protected override preExecute( context: CommandContext, args?: QuickWizardCommandArgsWithCompletion, - ) { + ): Promise { switch (context.command) { case GlCommand.GitCommandsBranch: return this.execute({ command: 'branch', ...args }); diff --git a/src/commands/inspect.ts b/src/commands/inspect.ts index 3fb37cb2a2b04..23b64b052201e 100644 --- a/src/commands/inspect.ts +++ b/src/commands/inspect.ts @@ -39,7 +39,7 @@ export class InspectCommand extends ActiveEditorCommand { super([GlCommand.ShowCommitInView, GlCommand.ShowInDetailsView, GlCommand.ShowLineCommitInView]); } - protected override preExecute(context: CommandContext, args?: InspectCommandArgs) { + protected override preExecute(context: CommandContext, args?: InspectCommandArgs): Promise { if (context.type === 'viewItem') { args = { ...args }; if (isCommandContextViewNodeHasCommit(context)) { @@ -50,7 +50,7 @@ export class InspectCommand extends ActiveEditorCommand { return this.execute(context.editor, context.uri, args); } - async execute(editor?: TextEditor, uri?: Uri, args?: InspectCommandArgs) { + async execute(editor?: TextEditor, uri?: Uri, args?: InspectCommandArgs): Promise { args = { ...args }; if (args.ref == null) { diff --git a/src/commands/inviteToLiveShare.ts b/src/commands/inviteToLiveShare.ts index f6441b536238a..d84a0e06a07a9 100644 --- a/src/commands/inviteToLiveShare.ts +++ b/src/commands/inviteToLiveShare.ts @@ -1,3 +1,4 @@ +import type { Uri } from 'vscode'; import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { command } from '../system/-webview/command'; @@ -24,7 +25,10 @@ export class InviteToLiveShareCommand extends GlCommandBase { super(GlCommand.InviteToLiveShare); } - protected override preExecute(context: CommandContext, args?: InviteToLiveShareCommandArgs) { + protected override preExecute( + context: CommandContext, + args?: InviteToLiveShareCommandArgs, + ): Promise { if (isCommandContextViewNodeHasContributor(context)) { args = { ...args }; args.email = context.node.contributor.email; @@ -34,7 +38,7 @@ export class InviteToLiveShareCommand extends GlCommandBase { return this.execute(args); } - async execute(args?: InviteToLiveShareCommandArgs) { + async execute(args?: InviteToLiveShareCommandArgs): Promise { if (args?.email) { const contact = await this.container.vsls.getContact(args.email); if (contact != null) { diff --git a/src/commands/logging.ts b/src/commands/logging.ts index 088db90bc072a..e3ab4ceaabb55 100644 --- a/src/commands/logging.ts +++ b/src/commands/logging.ts @@ -10,7 +10,7 @@ export class EnableDebugLoggingCommand extends GlCommandBase { super(GlCommand.EnableDebugLogging); } - async execute() { + async execute(): Promise { await configuration.updateEffective('outputLevel', 'debug'); } } @@ -21,7 +21,7 @@ export class DisableDebugLoggingCommand extends GlCommandBase { super(GlCommand.DisableDebugLogging); } - async execute() { + async execute(): Promise { await configuration.updateEffective('outputLevel', 'error'); } } diff --git a/src/commands/openAssociatedPullRequestOnRemote.ts b/src/commands/openAssociatedPullRequestOnRemote.ts index b65e80d2e8261..8181c9da6f812 100644 --- a/src/commands/openAssociatedPullRequestOnRemote.ts +++ b/src/commands/openAssociatedPullRequestOnRemote.ts @@ -15,7 +15,7 @@ export class OpenAssociatedPullRequestOnRemoteCommand extends ActiveEditorComman super(GlCommand.OpenAssociatedPullRequestOnRemote); } - async execute(editor?: TextEditor, uri?: Uri) { + async execute(editor?: TextEditor, uri?: Uri): Promise { uri = getCommandUri(uri, editor); const gitUri = uri != null ? await GitUri.fromUri(uri) : undefined; diff --git a/src/commands/openBranchOnRemote.ts b/src/commands/openBranchOnRemote.ts index eee8651cfbe27..8e94bffaed574 100644 --- a/src/commands/openBranchOnRemote.ts +++ b/src/commands/openBranchOnRemote.ts @@ -28,7 +28,7 @@ export class OpenBranchOnRemoteCommand extends ActiveEditorCommand { super([GlCommand.OpenBranchOnRemote, GlCommand.Deprecated_OpenBranchInRemote, GlCommand.CopyRemoteBranchUrl]); } - protected override preExecute(context: CommandContext, args?: OpenBranchOnRemoteCommandArgs) { + protected override preExecute(context: CommandContext, args?: OpenBranchOnRemoteCommandArgs): Promise { if (isCommandContextViewNodeHasBranch(context)) { args = { ...args, @@ -44,7 +44,7 @@ export class OpenBranchOnRemoteCommand extends ActiveEditorCommand { return this.execute(context.editor, context.uri, args); } - async execute(editor?: TextEditor, uri?: Uri, args?: OpenBranchOnRemoteCommandArgs) { + async execute(editor?: TextEditor, uri?: Uri, args?: OpenBranchOnRemoteCommandArgs): Promise { uri = getCommandUri(uri, editor); const gitUri = uri != null ? await GitUri.fromUri(uri) : undefined; diff --git a/src/commands/openBranchesOnRemote.ts b/src/commands/openBranchesOnRemote.ts index eb74097973feb..d95199cbb7c5e 100644 --- a/src/commands/openBranchesOnRemote.ts +++ b/src/commands/openBranchesOnRemote.ts @@ -28,7 +28,7 @@ export class OpenBranchesOnRemoteCommand extends ActiveEditorCommand { ]); } - protected override preExecute(context: CommandContext, args?: OpenBranchesOnRemoteCommandArgs) { + protected override preExecute(context: CommandContext, args?: OpenBranchesOnRemoteCommandArgs): Promise { if (isCommandContextViewNodeHasRemote(context)) { args = { ...args, remote: context.node.remote.name }; } @@ -40,7 +40,7 @@ export class OpenBranchesOnRemoteCommand extends ActiveEditorCommand { return this.execute(context.editor, context.uri, args); } - async execute(editor?: TextEditor, uri?: Uri, args?: OpenBranchesOnRemoteCommandArgs) { + async execute(editor?: TextEditor, uri?: Uri, args?: OpenBranchesOnRemoteCommandArgs): Promise { uri = getCommandUri(uri, editor); const gitUri = uri != null ? await GitUri.fromUri(uri) : undefined; diff --git a/src/commands/openChangedFiles.ts b/src/commands/openChangedFiles.ts index 80d4f7ee7b032..5f56694f26145 100644 --- a/src/commands/openChangedFiles.ts +++ b/src/commands/openChangedFiles.ts @@ -20,7 +20,7 @@ export class OpenChangedFilesCommand extends GlCommandBase { super(GlCommand.OpenChangedFiles); } - async execute(args?: OpenChangedFilesCommandArgs) { + async execute(args?: OpenChangedFilesCommandArgs): Promise { args = { ...args }; try { diff --git a/src/commands/openCommitOnRemote.ts b/src/commands/openCommitOnRemote.ts index 1272376b303ed..358d04bf4ee4b 100644 --- a/src/commands/openCommitOnRemote.ts +++ b/src/commands/openCommitOnRemote.ts @@ -39,7 +39,7 @@ export class OpenCommitOnRemoteCommand extends ActiveEditorCommand { super([GlCommand.OpenCommitOnRemote, GlCommand.Deprecated_OpenCommitInRemote, GlCommand.CopyRemoteCommitUrl]); } - protected override preExecute(context: CommandContext, args?: OpenCommitOnRemoteCommandArgs) { + protected override preExecute(context: CommandContext, args?: OpenCommitOnRemoteCommandArgs): Promise { let uri = context.uri; if (context.type === 'editorLine') { @@ -65,7 +65,7 @@ export class OpenCommitOnRemoteCommand extends ActiveEditorCommand { return this.execute(context.editor, uri, args); } - async execute(editor?: TextEditor, uri?: Uri, args?: OpenCommitOnRemoteCommandArgs) { + async execute(editor?: TextEditor, uri?: Uri, args?: OpenCommitOnRemoteCommandArgs): Promise { uri = getCommandUri(uri, editor); let gitUri = uri != null ? await GitUri.fromUri(uri) : undefined; diff --git a/src/commands/openComparisonOnRemote.ts b/src/commands/openComparisonOnRemote.ts index 242b3776deffd..4e998d7a940ff 100644 --- a/src/commands/openComparisonOnRemote.ts +++ b/src/commands/openComparisonOnRemote.ts @@ -22,7 +22,7 @@ export class OpenComparisonOnRemoteCommand extends GlCommandBase { super([GlCommand.OpenComparisonOnRemote, GlCommand.CopyRemoteComparisonUrl]); } - protected override preExecute(context: CommandContext, args?: OpenComparisonOnRemoteCommandArgs) { + protected override preExecute(context: CommandContext, args?: OpenComparisonOnRemoteCommandArgs): Promise { if (context.type === 'viewItem') { if (context.node.isAny('results-commits')) { args = { @@ -55,7 +55,7 @@ export class OpenComparisonOnRemoteCommand extends GlCommandBase { return this.execute(args); } - async execute(args?: OpenComparisonOnRemoteCommandArgs) { + async execute(args?: OpenComparisonOnRemoteCommandArgs): Promise { if (args?.repoPath == null || args.ref1 == null || args.ref2 == null) return; try { diff --git a/src/commands/openCurrentBranchOnRemote.ts b/src/commands/openCurrentBranchOnRemote.ts index 604162fa831d8..a4c9910b2a996 100644 --- a/src/commands/openCurrentBranchOnRemote.ts +++ b/src/commands/openCurrentBranchOnRemote.ts @@ -18,7 +18,7 @@ export class OpenCurrentBranchOnRemoteCommand extends ActiveEditorCommand { super(GlCommand.OpenCurrentBranchOnRemote); } - async execute(editor?: TextEditor, uri?: Uri) { + async execute(editor?: TextEditor, uri?: Uri): Promise { uri = getCommandUri(uri, editor); const gitUri = uri != null ? await GitUri.fromUri(uri) : undefined; diff --git a/src/commands/openDirectoryCompare.ts b/src/commands/openDirectoryCompare.ts index 57076f603cf65..544ee1d2162e6 100644 --- a/src/commands/openDirectoryCompare.ts +++ b/src/commands/openDirectoryCompare.ts @@ -29,7 +29,10 @@ export class OpenDirectoryCompareCommand extends ActiveEditorCommand { ]); } - protected override async preExecute(context: CommandContext, args?: OpenDirectoryCompareCommandArgs) { + protected override async preExecute( + context: CommandContext, + args?: OpenDirectoryCompareCommandArgs, + ): Promise { switch (context.command) { case GlCommand.DiffDirectoryWithHead: args = { ...args }; @@ -56,7 +59,7 @@ export class OpenDirectoryCompareCommand extends ActiveEditorCommand { return this.execute(context.editor, context.uri, args); } - async execute(editor?: TextEditor, uri?: Uri, args?: OpenDirectoryCompareCommandArgs) { + async execute(editor?: TextEditor, uri?: Uri, args?: OpenDirectoryCompareCommandArgs): Promise { uri = getCommandUri(uri, editor); args = { ...args }; diff --git a/src/commands/openFileAtRevision.ts b/src/commands/openFileAtRevision.ts index 702fe9fd00dd2..bb130108daa4f 100644 --- a/src/commands/openFileAtRevision.ts +++ b/src/commands/openFileAtRevision.ts @@ -59,7 +59,7 @@ export class OpenFileAtRevisionCommand extends ActiveEditorCommand { super([GlCommand.OpenFileAtRevision, GlCommand.OpenBlamePriorToChange]); } - protected override async preExecute(context: CommandContext, args?: OpenFileAtRevisionCommandArgs) { + protected override async preExecute(context: CommandContext, args?: OpenFileAtRevisionCommandArgs): Promise { if (context.command === GlCommand.OpenBlamePriorToChange) { args = { ...args, annotationType: 'blame' }; if (args.revisionUri == null && context.editor != null) { @@ -102,7 +102,7 @@ export class OpenFileAtRevisionCommand extends ActiveEditorCommand { return this.execute(context.editor, context.uri, args); } - async execute(editor: TextEditor | undefined, uri?: Uri, args?: OpenFileAtRevisionCommandArgs) { + async execute(editor: TextEditor | undefined, uri?: Uri, args?: OpenFileAtRevisionCommandArgs): Promise { uri = getCommandUri(uri, editor); if (uri == null) return; diff --git a/src/commands/openFileAtRevisionFrom.ts b/src/commands/openFileAtRevisionFrom.ts index 2c139e387be1d..2847efd35fb7e 100644 --- a/src/commands/openFileAtRevisionFrom.ts +++ b/src/commands/openFileAtRevisionFrom.ts @@ -29,7 +29,7 @@ export class OpenFileAtRevisionFromCommand extends ActiveEditorCommand { super(GlCommand.OpenFileAtRevisionFrom); } - async execute(editor: TextEditor | undefined, uri?: Uri, args?: OpenFileAtRevisionFromCommandArgs) { + async execute(editor: TextEditor | undefined, uri?: Uri, args?: OpenFileAtRevisionFromCommandArgs): Promise { uri = getCommandUri(uri, editor); if (uri == null) return; diff --git a/src/commands/openFileFromRemote.ts b/src/commands/openFileFromRemote.ts index 63206dc43abc3..ba1ee49630f9b 100644 --- a/src/commands/openFileFromRemote.ts +++ b/src/commands/openFileFromRemote.ts @@ -11,7 +11,7 @@ export class OpenFileFromRemoteCommand extends GlCommandBase { super(GlCommand.OpenFileFromRemote); } - async execute() { + async execute(): Promise { let clipboard: string | undefined = await env.clipboard.readText(); try { Uri.parse(clipboard, true); diff --git a/src/commands/openFileOnRemote.ts b/src/commands/openFileOnRemote.ts index 544535526055e..5bd46036aa8e5 100644 --- a/src/commands/openFileOnRemote.ts +++ b/src/commands/openFileOnRemote.ts @@ -42,7 +42,7 @@ export class OpenFileOnRemoteCommand extends ActiveEditorCommand { ]); } - protected override async preExecute(context: CommandContext, args?: OpenFileOnRemoteCommandArgs) { + protected override async preExecute(context: CommandContext, args?: OpenFileOnRemoteCommandArgs): Promise { let uri = context.uri; if (context.type === 'editorLine') { @@ -107,7 +107,7 @@ export class OpenFileOnRemoteCommand extends ActiveEditorCommand { return this.execute(context.editor, uri, args); } - async execute(editor?: TextEditor, uri?: Uri, args?: OpenFileOnRemoteCommandArgs) { + async execute(editor?: TextEditor, uri?: Uri, args?: OpenFileOnRemoteCommandArgs): Promise { uri = getCommandUri(uri, editor); if (uri == null) return; diff --git a/src/commands/openOnRemote.ts b/src/commands/openOnRemote.ts index 71e0a05608547..d056d019fb456 100644 --- a/src/commands/openOnRemote.ts +++ b/src/commands/openOnRemote.ts @@ -37,7 +37,7 @@ export class OpenOnRemoteCommand extends GlCommandBase { super([GlCommand.OpenOnRemote, GlCommand.Deprecated_OpenInRemote]); } - async execute(args?: OpenOnRemoteCommandArgs) { + async execute(args?: OpenOnRemoteCommandArgs): Promise { if (args?.resource == null) return; let remotes = diff --git a/src/commands/openOnlyChangedFiles.ts b/src/commands/openOnlyChangedFiles.ts index 8d2841e83c459..b2d6acf906262 100644 --- a/src/commands/openOnlyChangedFiles.ts +++ b/src/commands/openOnlyChangedFiles.ts @@ -21,7 +21,7 @@ export class OpenOnlyChangedFilesCommand extends GlCommandBase { super(GlCommand.OpenOnlyChangedFiles); } - async execute(args?: OpenOnlyChangedFilesCommandArgs) { + async execute(args?: OpenOnlyChangedFilesCommandArgs): Promise { args = { ...args }; try { diff --git a/src/commands/openPullRequestOnRemote.ts b/src/commands/openPullRequestOnRemote.ts index 26ed5537adbe2..a4e15c79d522d 100644 --- a/src/commands/openPullRequestOnRemote.ts +++ b/src/commands/openPullRequestOnRemote.ts @@ -20,7 +20,7 @@ export class OpenPullRequestOnRemoteCommand extends GlCommandBase { super([GlCommand.OpenPullRequestOnRemote, GlCommand.CopyRemotePullRequestUrl]); } - protected override preExecute(context: CommandContext, args?: OpenPullRequestOnRemoteCommandArgs) { + protected override preExecute(context: CommandContext, args?: OpenPullRequestOnRemoteCommandArgs): Promise { if (context.type === 'viewItem' && (context.node.is('pullrequest') || context.node.is('launchpad-item'))) { args = { ...args, @@ -32,7 +32,7 @@ export class OpenPullRequestOnRemoteCommand extends GlCommandBase { return this.execute(args); } - async execute(args?: OpenPullRequestOnRemoteCommandArgs) { + async execute(args?: OpenPullRequestOnRemoteCommandArgs): Promise { if (args?.pr == null) { if (args?.repoPath == null || args?.ref == null) return; diff --git a/src/commands/openRepoOnRemote.ts b/src/commands/openRepoOnRemote.ts index 389617e4fd92a..069fbb92ff916 100644 --- a/src/commands/openRepoOnRemote.ts +++ b/src/commands/openRepoOnRemote.ts @@ -24,7 +24,7 @@ export class OpenRepoOnRemoteCommand extends ActiveEditorCommand { super([GlCommand.OpenRepoOnRemote, GlCommand.Deprecated_OpenRepoInRemote, GlCommand.CopyRemoteRepositoryUrl]); } - protected override preExecute(context: CommandContext, args?: OpenRepoOnRemoteCommandArgs) { + protected override preExecute(context: CommandContext, args?: OpenRepoOnRemoteCommandArgs): Promise { if (isCommandContextViewNodeHasRemote(context)) { args = { ...args, remote: context.node.remote.name }; } @@ -36,7 +36,7 @@ export class OpenRepoOnRemoteCommand extends ActiveEditorCommand { return this.execute(context.editor, context.uri, args); } - async execute(editor?: TextEditor, uri?: Uri, args?: OpenRepoOnRemoteCommandArgs) { + async execute(editor?: TextEditor, uri?: Uri, args?: OpenRepoOnRemoteCommandArgs): Promise { uri = getCommandUri(uri, editor); const gitUri = uri != null ? await GitUri.fromUri(uri) : undefined; diff --git a/src/commands/openRevisionFile.ts b/src/commands/openRevisionFile.ts index 417a80f51ddc6..e685a6d880726 100644 --- a/src/commands/openRevisionFile.ts +++ b/src/commands/openRevisionFile.ts @@ -29,7 +29,7 @@ export class OpenRevisionFileCommand extends ActiveEditorCommand { ]); } - async execute(editor?: TextEditor, uri?: Uri, args?: OpenRevisionFileCommandArgs) { + async execute(editor?: TextEditor, uri?: Uri, args?: OpenRevisionFileCommandArgs): Promise { uri = getCommandUri(uri, editor); if (uri == null) return; diff --git a/src/commands/openWorkingFile.ts b/src/commands/openWorkingFile.ts index d339fb408054b..56bdfbba0ddf8 100644 --- a/src/commands/openWorkingFile.ts +++ b/src/commands/openWorkingFile.ts @@ -24,7 +24,7 @@ export class OpenWorkingFileCommand extends ActiveEditorCommand { super([GlCommand.OpenWorkingFile, GlCommand.OpenWorkingFileInDiffLeft, GlCommand.OpenWorkingFileInDiffRight]); } - async execute(editor: TextEditor, uri?: Uri, args?: OpenWorkingFileCommandArgs) { + async execute(editor: TextEditor, uri?: Uri, args?: OpenWorkingFileCommandArgs): Promise { args = { ...args }; if (args.line == null) { args.line = editor?.selection.active.line; diff --git a/src/commands/patches.ts b/src/commands/patches.ts index 3d16cd5ff0642..4876b2a72fbd5 100644 --- a/src/commands/patches.ts +++ b/src/commands/patches.ts @@ -164,7 +164,7 @@ export class CreatePatchCommand extends CreatePatchCommandBase { super(container, GlCommand.CreatePatch); } - async execute(args?: CreatePatchCommandArgs) { + async execute(args?: CreatePatchCommandArgs): Promise { const diff = await this.getDiff('Create Patch', args); if (diff == null) return; @@ -188,7 +188,7 @@ export class CopyPatchToClipboardCommand extends CreatePatchCommandBase { super(container, GlCommand.CopyPatchToClipboard); } - async execute(args?: CreatePatchCommandArgs) { + async execute(args?: CreatePatchCommandArgs): Promise { const diff = await this.getDiff('Copy as Patch', args); if (diff == null) return; @@ -205,7 +205,7 @@ export class ApplyPatchFromClipboardCommand extends GlCommandBase { super([GlCommand.ApplyPatchFromClipboard, GlCommand.PastePatchFromClipboard]); } - async execute() { + async execute(): Promise { const patch = await env.clipboard.readText(); let repo = this.container.git.highlander; @@ -249,7 +249,7 @@ export class CreateCloudPatchCommand extends CreatePatchCommandBase { super(container, [GlCommand.CreateCloudPatch, GlCommand.ShareAsCloudPatch]); } - async execute(args?: CreatePatchCommandArgs) { + async execute(args?: CreatePatchCommandArgs): Promise { if (args?.repoPath == null) { return showPatchesView({ mode: 'create' }); } @@ -273,7 +273,7 @@ export class OpenPatchCommand extends ActiveEditorCommand { super(GlCommand.OpenPatch); } - async execute(editor?: TextEditor) { + async execute(editor?: TextEditor): Promise { let document; if (editor?.document?.languageId === 'diff') { document = editor.document; @@ -320,7 +320,7 @@ export class OpenCloudPatchCommand extends GlCommandBase { super(GlCommand.OpenCloudPatch); } - async execute(args?: OpenCloudPatchCommandArgs) { + async execute(args?: OpenCloudPatchCommandArgs): Promise { const type = args?.type === 'code_suggestion' ? 'Code Suggestion' : 'Cloud Patch'; if (args?.id == null && args?.draft == null) { void window.showErrorMessage(`Cannot open ${type}; no patch or patch id provided`); diff --git a/src/commands/quickCommand.buttons.ts b/src/commands/quickCommand.buttons.ts index 5afc74056adfe..84d4c33dc1b50 100644 --- a/src/commands/quickCommand.buttons.ts +++ b/src/commands/quickCommand.buttons.ts @@ -30,7 +30,7 @@ export class ToggleQuickInputButton implements QuickInputButton { return this.getToggledState().tooltip; } - get on() { + get on(): boolean { return this._on; } set on(value: boolean) { diff --git a/src/commands/quickCommand.steps.ts b/src/commands/quickCommand.steps.ts index 6d14e6152daad..fc96a40e22864 100644 --- a/src/commands/quickCommand.steps.ts +++ b/src/commands/quickCommand.steps.ts @@ -146,7 +146,7 @@ import type { OpenWalkthroughCommandArgs } from './walkthroughs'; export function appendReposToTitle< State extends { repo: Repository } | { repos: Repository[] }, Context extends { repos: Repository[] }, ->(title: string, state: State, context: Context, additionalContext?: string) { +>(title: string, state: State, context: Context, additionalContext?: string): string { if (context.repos.length === 1) { return additionalContext ? `${title}${truncate(additionalContext, quickPickTitleMaxChars - title.length)}` @@ -493,7 +493,7 @@ export function getValidateGitReferenceFn( repos: Repository | Repository[] | undefined, options?: { buttons?: QuickInputButton[]; ranges?: boolean }, ) { - return async (quickpick: QuickPick, value: string) => { + return async (quickpick: QuickPick, value: string): Promise => { let inRefMode = false; if (value.startsWith('#')) { inRefMode = true; diff --git a/src/commands/quickCommand.ts b/src/commands/quickCommand.ts index 87e93701edff8..e19d755e84abd 100644 --- a/src/commands/quickCommand.ts +++ b/src/commands/quickCommand.ts @@ -170,7 +170,7 @@ export abstract class QuickCommand implements QuickPickItem { } private _picked: boolean = false; - get picked() { + get picked(): boolean { return this._picked; } set picked(value: boolean) { @@ -181,7 +181,7 @@ export abstract class QuickCommand implements QuickPickItem { } private _pickedVia: 'menu' | 'command' = 'menu'; - get pickedVia() { + get pickedVia(): 'menu' | 'command' { return this._pickedVia; } set pickedVia(value: 'menu' | 'command') { @@ -196,7 +196,7 @@ export abstract class QuickCommand implements QuickPickItem { return this._currentStep; } - confirm(override?: boolean) { + confirm(override?: boolean): boolean { if (!this.canConfirm || !this.canSkipConfirm) return true; return override != null @@ -204,17 +204,17 @@ export abstract class QuickCommand implements QuickPickItem { : !configuration.get('gitCommands.skipConfirmations').includes(this.skipConfirmKey); } - isMatch(key: string) { + isMatch(key: string): boolean { return this.key === key; } - isFuzzyMatch(name: string) { + isFuzzyMatch(name: string): boolean { return this.label === name; } protected abstract steps(state: PartialStepState): StepGenerator; - executeSteps() { + executeSteps(): StepGenerator { // When we are chaining steps together, limit backward navigation to feel more natural return this.steps(this.getStepState(true)); } @@ -251,7 +251,7 @@ export abstract class QuickCommand implements QuickPickItem { return this.value; } - protected canStepsContinue(state: PartialStepState) { + protected canStepsContinue(state: PartialStepState): boolean { return state.counter >= (state.startingStep ?? 0); } @@ -283,7 +283,7 @@ export async function canInputStepContinue( step: T, state: PartialStepState, value: Directive | StepItemType, -) { +): Promise { if (!canStepContinue(step, state, value)) return false; const [valid] = (await step.validate?.(value)) ?? [true]; @@ -391,7 +391,7 @@ export function createCustomStep(step: Optional, 'type'>): Cust return { type: 'custom', ...step }; } -export function endSteps(state: PartialStepState) { +export function endSteps(state: PartialStepState): void { state.counter = -1; } diff --git a/src/commands/quickWizard.base.ts b/src/commands/quickWizard.base.ts index f81c9fc4cbf9d..884773155531a 100644 --- a/src/commands/quickWizard.base.ts +++ b/src/commands/quickWizard.base.ts @@ -40,7 +40,7 @@ export abstract class QuickWizardCommandBase extends GlCommandBase { } @log({ args: false, scoped: true, singleLine: true, timed: false }) - async execute(args?: QuickWizardCommandArgsWithCompletion) { + async execute(args?: QuickWizardCommandArgsWithCompletion): Promise { const rootStep = new QuickWizardRootStep(this.container, args); const command = args?.command != null ? rootStep.find(args.command) : undefined; diff --git a/src/commands/quickWizard.ts b/src/commands/quickWizard.ts index c1903bda76a2c..c515588c97922 100644 --- a/src/commands/quickWizard.ts +++ b/src/commands/quickWizard.ts @@ -15,7 +15,7 @@ export class QuickWizardCommand extends QuickWizardCommandBase { super(container, [GlCommand.ShowLaunchpad, GlCommand.StartWork, GlCommand.AssociateIssueWithBranch]); } - protected override preExecute(context: CommandContext, args?: QuickWizardCommandArgsWithCompletion) { + protected override preExecute(context: CommandContext, args?: QuickWizardCommandArgsWithCompletion): Promise { switch (context.command) { case GlCommand.ShowLaunchpad: return this.execute({ command: 'launchpad', ...args }); diff --git a/src/commands/quickWizard.utils.ts b/src/commands/quickWizard.utils.ts index 7b7458688be32..d14bb4b84bb00 100644 --- a/src/commands/quickWizard.utils.ts +++ b/src/commands/quickWizard.utils.ts @@ -1,3 +1,4 @@ +import type { QuickInputButton } from 'vscode'; import type { StoredRecentUsage } from '../constants.storage'; import type { Container } from '../container'; import { LaunchpadCommand } from '../plus/launchpad/launchpad'; @@ -47,7 +48,7 @@ export function getSteps( export class QuickWizardRootStep implements QuickPickStep { readonly type = 'pick'; - readonly buttons = []; + readonly buttons: QuickInputButton[] = []; ignoreFocusOut = false; readonly items: QuickCommand[]; readonly matchOnDescription = true; @@ -128,7 +129,7 @@ export class QuickWizardRootStep implements QuickPickStep { return this._command; } - find(commandName: string, fuzzy: boolean = false) { + find(commandName: string, fuzzy: boolean = false): QuickCommand | undefined { if (fuzzy) { const cmd = commandName.toLowerCase(); return this.items.find(c => c.isFuzzyMatch(cmd)) ?? this.hiddenItems.find(c => c.isFuzzyMatch(cmd)); diff --git a/src/commands/rebaseEditor.ts b/src/commands/rebaseEditor.ts index 55a9458db5899..848fbfcb39d88 100644 --- a/src/commands/rebaseEditor.ts +++ b/src/commands/rebaseEditor.ts @@ -9,7 +9,7 @@ export class DisableRebaseEditorCommand extends GlCommandBase { super(GlCommand.DisableRebaseEditor); } - execute() { + execute(): Promise { return this.container.rebaseEditor.setEnabled(false); } } @@ -20,7 +20,7 @@ export class EnableRebaseEditorCommand extends GlCommandBase { super(GlCommand.EnableRebaseEditor); } - execute() { + execute(): Promise { return this.container.rebaseEditor.setEnabled(true); } } diff --git a/src/commands/refreshHover.ts b/src/commands/refreshHover.ts index daf666365a7de..b8ff4508cb7cc 100644 --- a/src/commands/refreshHover.ts +++ b/src/commands/refreshHover.ts @@ -9,7 +9,7 @@ export class RefreshHoverCommand extends GlCommandBase { super(GlCommand.RefreshHover); } - async execute() { + async execute(): Promise { // TODO@eamodio figure out how to really refresh/update a hover await executeCoreCommand('editor.action.showHover'); } diff --git a/src/commands/remoteProviders.ts b/src/commands/remoteProviders.ts index 30fbe5d7815e3..21d7724c57ff8 100644 --- a/src/commands/remoteProviders.ts +++ b/src/commands/remoteProviders.ts @@ -40,7 +40,7 @@ export class ConnectRemoteProviderCommand extends GlCommandBase { super(GlCommand.ConnectRemoteProvider); } - protected override preExecute(context: CommandContext, args?: ConnectRemoteProviderCommandArgs) { + protected override preExecute(context: CommandContext, args?: ConnectRemoteProviderCommandArgs): Promise { if (isCommandContextViewNodeHasRemote(context)) { args = { ...args, remote: context.node.remote.name, repoPath: context.node.remote.repoPath }; } @@ -135,7 +135,7 @@ export class DisconnectRemoteProviderCommand extends GlCommandBase { super(GlCommand.DisconnectRemoteProvider); } - protected override preExecute(context: CommandContext, args?: DisconnectRemoteProviderCommandArgs) { + protected override preExecute(context: CommandContext, args?: DisconnectRemoteProviderCommandArgs): Promise { if (isCommandContextViewNodeHasRemote(context)) { args = { ...args, remote: context.node.remote.name, repoPath: context.node.remote.repoPath }; } @@ -143,7 +143,7 @@ export class DisconnectRemoteProviderCommand extends GlCommandBase { return this.execute(args); } - async execute(args?: DisconnectRemoteProviderCommandArgs): Promise { + async execute(args?: DisconnectRemoteProviderCommandArgs): Promise { let remote: GitRemote | undefined; let repoPath; if (args?.repoPath == null) { @@ -156,7 +156,7 @@ export class DisconnectRemoteProviderCommand extends GlCommandBase { } } - if (repos.size === 0) return undefined; + if (repos.size === 0) return; if (repos.size === 1) { let repo; [repo, remote] = first(repos)!; @@ -167,7 +167,7 @@ export class DisconnectRemoteProviderCommand extends GlCommandBase { 'Choose which repository to disconnect from the remote provider', [...repos.keys()], ); - if (pick == null) return undefined; + if (pick == null) return; repoPath = pick.path; remote = repos.get(pick)!; @@ -178,14 +178,14 @@ export class DisconnectRemoteProviderCommand extends GlCommandBase { remote = await this.container.git .remotes(repoPath) .getBestRemoteWithIntegration({ includeDisconnected: false }); - if (remote == null) return undefined; + if (remote == null) return; } else { repoPath = args.repoPath; remote = (await this.container.git.remotes(repoPath).getRemotesWithProviders()).find( r => r.name === args.remote, ); - if (!remote?.hasIntegration()) return undefined; + if (!remote?.hasIntegration()) return; } const integration = await this.container.integrations.getByRemote(remote); diff --git a/src/commands/repositories.ts b/src/commands/repositories.ts index e66159da94c80..37b13bf980ebf 100644 --- a/src/commands/repositories.ts +++ b/src/commands/repositories.ts @@ -10,7 +10,7 @@ export class FetchRepositoriesCommand extends GlCommandBase { super(GlCommand.FetchRepositories); } - async execute() { + async execute(): Promise { return executeGitCommand({ command: 'fetch', state: { repos: this.container.git.openRepositories }, @@ -24,7 +24,7 @@ export class PullRepositoriesCommand extends GlCommandBase { super(GlCommand.PullRepositories); } - async execute() { + async execute(): Promise { return executeGitCommand({ command: 'pull', state: { repos: this.container.git.openRepositories }, @@ -38,7 +38,7 @@ export class PushRepositoriesCommand extends GlCommandBase { super(GlCommand.PushRepositories); } - async execute() { + async execute(): Promise { return executeGitCommand({ command: 'push', state: { repos: this.container.git.openRepositories }, diff --git a/src/commands/resetViewsLayout.ts b/src/commands/resetViewsLayout.ts index f9c549e944fff..1097301ce61d4 100644 --- a/src/commands/resetViewsLayout.ts +++ b/src/commands/resetViewsLayout.ts @@ -11,7 +11,7 @@ export class ResetViewsLayoutCommand extends GlCommandBase { super(GlCommand.ResetViewsLayout); } - async execute() { + async execute(): Promise { // Don't use this because it will forcibly show & expand every view // for (const view of viewIds) { // void (await executeCoreCommand(`gitlens.views.${view}.resetViewLocation`)); diff --git a/src/commands/resets.ts b/src/commands/resets.ts index 80e2dc851f6c2..ed0d00659b8d3 100644 --- a/src/commands/resets.ts +++ b/src/commands/resets.ts @@ -27,7 +27,7 @@ export class ResetCommand extends GlCommandBase { constructor(private readonly container: Container) { super(GlCommand.Reset); } - async execute() { + async execute(): Promise { type ResetQuickPickItem = QuickPickItemOfT; const items: ResetQuickPickItem[] = [ @@ -218,7 +218,7 @@ export class ResetAIKeyCommand extends GlCommandBase { super(GlCommand.ResetAIKey); } - async execute() { + async execute(): Promise { await (await this.container.ai)?.reset(); } } diff --git a/src/commands/searchCommits.ts b/src/commands/searchCommits.ts index c875d53942a9d..d8b4ccfc87edf 100644 --- a/src/commands/searchCommits.ts +++ b/src/commands/searchCommits.ts @@ -25,7 +25,7 @@ export class SearchCommitsCommand extends GlCommandBase { super([GlCommand.SearchCommits, GlCommand.SearchCommitsInView]); } - protected override preExecute(context: CommandContext, args?: SearchCommitsCommandArgs) { + protected override preExecute(context: CommandContext, args?: SearchCommitsCommandArgs): Promise { if (context.command === GlCommand.SearchCommitsInView) { args = { ...args }; args.showResultsInSideBar = true; @@ -47,7 +47,7 @@ export class SearchCommitsCommand extends GlCommandBase { return this.execute(args); } - async execute(args?: SearchCommitsCommandArgs) { + async execute(args?: SearchCommitsCommandArgs): Promise { await executeGitCommand({ command: 'search', prefillOnly: args?.prefillOnly, diff --git a/src/commands/showCommitsInView.ts b/src/commands/showCommitsInView.ts index 2185b3e2dac5a..7857a5ad6e3b9 100644 --- a/src/commands/showCommitsInView.ts +++ b/src/commands/showCommitsInView.ts @@ -30,7 +30,7 @@ export class ShowCommitsInViewCommand extends ActiveEditorCommand { super(GlCommand.ShowCommitsInView); } - async execute(editor?: TextEditor, uri?: Uri, args?: ShowCommitsInViewCommandArgs) { + async execute(editor?: TextEditor, uri?: Uri, args?: ShowCommitsInViewCommandArgs): Promise { args = { ...args }; if (args.refs == null) { diff --git a/src/commands/showLastQuickPick.ts b/src/commands/showLastQuickPick.ts index 69fdcf9e020c9..6591d1f70a3fb 100644 --- a/src/commands/showLastQuickPick.ts +++ b/src/commands/showLastQuickPick.ts @@ -12,7 +12,7 @@ export class ShowLastQuickPickCommand extends GlCommandBase { super(GlCommand.ShowLastQuickPick); } - execute() { + execute(): Thenable { const command = getLastCommand(); if (command === undefined) return Promise.resolve(undefined); diff --git a/src/commands/showQuickBranchHistory.ts b/src/commands/showQuickBranchHistory.ts index 84c316fe78f6c..52be719fd859a 100644 --- a/src/commands/showQuickBranchHistory.ts +++ b/src/commands/showQuickBranchHistory.ts @@ -22,7 +22,7 @@ export class ShowQuickBranchHistoryCommand extends ActiveEditorCachedCommand { super([GlCommand.ShowQuickBranchHistory, GlCommand.ShowQuickCurrentBranchHistory]); } - protected override preExecute(context: CommandContext, args?: ShowQuickBranchHistoryCommandArgs) { + protected override preExecute(context: CommandContext, args?: ShowQuickBranchHistoryCommandArgs): Promise { if (context.command === GlCommand.ShowQuickCurrentBranchHistory) { args = { ...args }; args.branch = 'HEAD'; @@ -31,7 +31,7 @@ export class ShowQuickBranchHistoryCommand extends ActiveEditorCachedCommand { return this.execute(context.editor, context.uri, args); } - async execute(editor?: TextEditor, uri?: Uri, args?: ShowQuickBranchHistoryCommandArgs) { + async execute(editor?: TextEditor, uri?: Uri, args?: ShowQuickBranchHistoryCommandArgs): Promise { uri = getCommandUri(uri, editor); const gitUri = uri != null ? await GitUri.fromUri(uri) : undefined; diff --git a/src/commands/showQuickCommit.ts b/src/commands/showQuickCommit.ts index f28e5680f4287..7eb609882b456 100644 --- a/src/commands/showQuickCommit.ts +++ b/src/commands/showQuickCommit.ts @@ -41,7 +41,7 @@ export class ShowQuickCommitCommand extends ActiveEditorCachedCommand { super([GlCommand.RevealCommitInView, GlCommand.ShowQuickCommit]); } - protected override preExecute(context: CommandContext, args?: ShowQuickCommitCommandArgs) { + protected override preExecute(context: CommandContext, args?: ShowQuickCommitCommandArgs): Promise { if (context.command === GlCommand.RevealCommitInView) { args = { ...args }; args.revealInView = true; @@ -59,7 +59,7 @@ export class ShowQuickCommitCommand extends ActiveEditorCachedCommand { return this.execute(context.editor, context.uri, args); } - async execute(editor?: TextEditor, uri?: Uri, args?: ShowQuickCommitCommandArgs) { + async execute(editor?: TextEditor, uri?: Uri, args?: ShowQuickCommitCommandArgs): Promise { let gitUri; let repoPath; if (args?.commit == null) { diff --git a/src/commands/showQuickCommitFile.ts b/src/commands/showQuickCommitFile.ts index 45663e832a7e8..ed685a651e269 100644 --- a/src/commands/showQuickCommitFile.ts +++ b/src/commands/showQuickCommitFile.ts @@ -40,7 +40,7 @@ export class ShowQuickCommitFileCommand extends ActiveEditorCachedCommand { super(GlCommand.ShowQuickCommitFile); } - protected override async preExecute(context: CommandContext, args?: ShowQuickCommitFileCommandArgs) { + protected override async preExecute(context: CommandContext, args?: ShowQuickCommitFileCommandArgs): Promise { if (context.type === 'editorLine') { args = { ...args, line: context.line }; } @@ -56,7 +56,7 @@ export class ShowQuickCommitFileCommand extends ActiveEditorCachedCommand { return this.execute(context.editor, context.uri, args); } - async execute(editor?: TextEditor, uri?: Uri, args?: ShowQuickCommitFileCommandArgs) { + async execute(editor?: TextEditor, uri?: Uri, args?: ShowQuickCommitFileCommandArgs): Promise { uri = getCommandUri(uri, editor); if (uri == null) return; @@ -159,7 +159,7 @@ export class ShowQuickCommitRevisionCommand extends ActiveEditorCachedCommand { ]); } - async execute(editor?: TextEditor, uri?: Uri) { + async execute(editor?: TextEditor, uri?: Uri): Promise { uri = getCommandUri(uri, editor); if (uri == null) return; diff --git a/src/commands/showQuickFileHistory.ts b/src/commands/showQuickFileHistory.ts index 3d0a4220457bc..da4436cd8f530 100644 --- a/src/commands/showQuickFileHistory.ts +++ b/src/commands/showQuickFileHistory.ts @@ -37,7 +37,7 @@ export class ShowQuickFileHistoryCommand extends ActiveEditorCachedCommand { ]); } - protected override preExecute(context: CommandContext, args?: ShowQuickFileHistoryCommandArgs) { + protected override preExecute(context: CommandContext, args?: ShowQuickFileHistoryCommandArgs): Promise { let uri = context.uri; if ( context.command === GlCommand.OpenFileHistory || @@ -56,7 +56,7 @@ export class ShowQuickFileHistoryCommand extends ActiveEditorCachedCommand { return this.execute(context.editor, uri, args); } - async execute(editor?: TextEditor, uri?: Uri, args?: ShowQuickFileHistoryCommandArgs) { + async execute(editor?: TextEditor, uri?: Uri, args?: ShowQuickFileHistoryCommandArgs): Promise { uri = getCommandUri(uri, editor); if (uri == null) return; diff --git a/src/commands/showQuickRepoStatus.ts b/src/commands/showQuickRepoStatus.ts index 9291ebab3b8c0..486ce6b0dc275 100644 --- a/src/commands/showQuickRepoStatus.ts +++ b/src/commands/showQuickRepoStatus.ts @@ -14,7 +14,7 @@ export class ShowQuickRepoStatusCommand extends GlCommandBase { super(GlCommand.ShowQuickRepoStatus); } - async execute(args?: ShowQuickRepoStatusCommandArgs) { + async execute(args?: ShowQuickRepoStatusCommandArgs): Promise { return executeGitCommand({ command: 'status', state: { diff --git a/src/commands/showQuickStashList.ts b/src/commands/showQuickStashList.ts index 8544df4785fca..79a8ebee5197d 100644 --- a/src/commands/showQuickStashList.ts +++ b/src/commands/showQuickStashList.ts @@ -14,7 +14,7 @@ export class ShowQuickStashListCommand extends GlCommandBase { super(GlCommand.ShowQuickStashList); } - execute(args?: ShowQuickStashListCommandArgs) { + execute(args?: ShowQuickStashListCommandArgs): Promise { return executeGitCommand({ command: 'stash', state: { diff --git a/src/commands/showView.ts b/src/commands/showView.ts index 0f544ff1d415b..d38c18ae25539 100644 --- a/src/commands/showView.ts +++ b/src/commands/showView.ts @@ -33,11 +33,11 @@ export class ShowViewCommand extends GlCommandBase { ]); } - protected override preExecute(context: CommandContext, ...args: unknown[]) { + protected override preExecute(context: CommandContext, ...args: unknown[]): Promise { return this.execute(context, ...args); } - async notifyWhenNoRepository(featureName?: string) { + async notifyWhenNoRepository(featureName?: string): Promise { if (this.container.git.openRepositoryCount > 0) { return; } @@ -53,7 +53,7 @@ export class ShowViewCommand extends GlCommandBase { } } - async execute(context: CommandContext, ...args: unknown[]) { + async execute(context: CommandContext, ...args: unknown[]): Promise { const command = context.command; switch (command) { case GlCommand.ShowAccountView: diff --git a/src/commands/stashApply.ts b/src/commands/stashApply.ts index fb71460270104..27530fa746169 100644 --- a/src/commands/stashApply.ts +++ b/src/commands/stashApply.ts @@ -23,7 +23,7 @@ export class StashApplyCommand extends GlCommandBase { super(GlCommand.StashApply); } - protected override async preExecute(context: CommandContext, args?: StashApplyCommandArgs) { + protected override async preExecute(context: CommandContext, args?: StashApplyCommandArgs): Promise { if (isCommandContextViewNodeHasCommit(context)) { if (context.node.commit.message == null) { await context.node.commit.ensureFullDetails(); @@ -36,7 +36,7 @@ export class StashApplyCommand extends GlCommandBase { return this.execute(args); } - async execute(args?: StashApplyCommandArgs) { + async execute(args?: StashApplyCommandArgs): Promise { if (args?.deleteAfter) { return pop(args?.repoPath ?? args?.stashItem?.repoPath, args?.stashItem); } diff --git a/src/commands/stashSave.ts b/src/commands/stashSave.ts index 2adcdca462980..df6455f4ab46d 100644 --- a/src/commands/stashSave.ts +++ b/src/commands/stashSave.ts @@ -31,7 +31,7 @@ export class StashSaveCommand extends GlCommandBase { super([GlCommand.StashSave, GlCommand.StashSaveFiles]); } - protected override async preExecute(context: CommandContext, args?: StashSaveCommandArgs) { + protected override async preExecute(context: CommandContext, args?: StashSaveCommandArgs): Promise { if (isCommandContextViewNodeHasFile(context)) { args = { ...args }; args.repoPath = context.node.file.repoPath ?? context.node.repoPath; @@ -133,7 +133,7 @@ export class StashSaveCommand extends GlCommandBase { return this.execute(args); } - execute(args?: StashSaveCommandArgs) { + execute(args?: StashSaveCommandArgs): Promise { return push( args?.repoPath, args?.uris, diff --git a/src/commands/switchAIModel.ts b/src/commands/switchAIModel.ts index 42cf9840523d7..c10cd401db30f 100644 --- a/src/commands/switchAIModel.ts +++ b/src/commands/switchAIModel.ts @@ -9,7 +9,7 @@ export class SwitchAIModelCommand extends GlCommandBase { super(GlCommand.SwitchAIModel); } - async execute() { + async execute(): Promise { await (await this.container.ai)?.switchModel(); } } diff --git a/src/commands/switchMode.ts b/src/commands/switchMode.ts index 5680b9786407c..bd775d8d93428 100644 --- a/src/commands/switchMode.ts +++ b/src/commands/switchMode.ts @@ -15,7 +15,7 @@ export class SwitchModeCommand extends GlCommandBase { } @log({ args: false, scoped: true, singleLine: true, timed: false }) - async execute() { + async execute(): Promise { const scope = getLogScope(); const pick = await showModePicker(); @@ -49,7 +49,7 @@ export class ToggleReviewModeCommand extends GlCommandBase { } @log({ args: false, singleLine: true, timed: false }) - async execute() { + async execute(): Promise { const modes = configuration.get('modes'); if (modes == null || !Object.keys(modes).includes('review')) return; @@ -65,7 +65,7 @@ export class ToggleZenModeCommand extends GlCommandBase { } @log({ args: false, singleLine: true, timed: false }) - async execute() { + async execute(): Promise { const modes = configuration.get('modes'); if (modes == null || !Object.keys(modes).includes('zen')) return; diff --git a/src/commands/toggleCodeLens.ts b/src/commands/toggleCodeLens.ts index 7df37ac84ec00..9a7043548f79b 100644 --- a/src/commands/toggleCodeLens.ts +++ b/src/commands/toggleCodeLens.ts @@ -9,7 +9,7 @@ export class ToggleCodeLensCommand extends GlCommandBase { super(GlCommand.ToggleCodeLens); } - execute() { + execute(): void { this.container.codeLens.toggleCodeLens(); } } diff --git a/src/commands/walkthroughs.ts b/src/commands/walkthroughs.ts index 7838f98efc5ee..abcef8a0f2f1d 100644 --- a/src/commands/walkthroughs.ts +++ b/src/commands/walkthroughs.ts @@ -13,7 +13,7 @@ export class GetStartedCommand extends GlCommandBase { super(GlCommand.GetStarted); } - execute(extensionIdOrsource?: Sources) { + execute(extensionIdOrsource?: Sources): void { // If the extensionIdOrsource is the same as the current extension, then it came from the extension content menu in the extension view, so don't pass the source const source = extensionIdOrsource !== this.container.context.extension.id ? undefined : extensionIdOrsource; openWalkthrough(this.container, source ? { source: source } : undefined); @@ -30,7 +30,7 @@ export class OpenWalkthroughCommand extends GlCommandBase { super(GlCommand.OpenWalkthrough); } - execute(args?: OpenWalkthroughCommandArgs) { + execute(args?: OpenWalkthroughCommandArgs): void { openWalkthrough(this.container, args); } } @@ -54,7 +54,7 @@ export class WalkthroughOpenWalkthroughCommand extends GlCommandBase { super(GlCommand.WalkthroughOpenWalkthrough); } - execute() { + execute(): void { const command = GlCommand.OpenWalkthrough; this.container.telemetry.sendEvent('walkthrough/action', { type: 'command', @@ -72,7 +72,7 @@ export class WalkthroughPlusUpgradeCommand extends GlCommandBase { super(GlCommand.WalkthroughPlusUpgrade); } - execute() { + execute(): void { const command = GlCommand.PlusUpgrade; this.container.telemetry.sendEvent('walkthrough/action', { type: 'command', @@ -90,7 +90,7 @@ export class WalkthroughOpenHelpCenterCommand extends GlCommandBase { super(GlCommand.WalkthroughOpenHelpCenter); } - execute() { + execute(): void { const url = urls.helpCenter; this.container.telemetry.sendEvent('walkthrough/action', { type: 'url', @@ -108,7 +108,7 @@ export class WalkthroughPlusSignUpCommand extends GlCommandBase { super(GlCommand.WalkthroughPlusSignUp); } - execute() { + execute(): void { const command = GlCommand.PlusSignUp; this.container.telemetry.sendEvent('walkthrough/action', { type: 'command', @@ -125,7 +125,7 @@ export class WalkthroughPlusReactivateCommand extends GlCommandBase { super(GlCommand.WalkthroughPlusReactivate); } - execute() { + execute(): void { const command = GlCommand.PlusReactivateProTrial; this.container.telemetry.sendEvent('walkthrough/action', { type: 'command', @@ -143,7 +143,7 @@ export class WalkthroughOpenCommunityVsProCommand extends GlCommandBase { super(GlCommand.WalkthroughOpenCommunityVsPro); } - execute() { + execute(): void { const url = urls.communityVsPro; this.container.telemetry.sendEvent('walkthrough/action', { type: 'url', @@ -161,7 +161,7 @@ export class WalkthroughShowGraphCommand extends GlCommandBase { super(GlCommand.WalkthroughShowGraph); } - execute() { + execute(): void { const command = GlCommand.ShowGraph; this.container.telemetry.sendEvent('walkthrough/action', { type: 'command', @@ -179,7 +179,7 @@ export class WalkthroughGitLensInspectCommand extends GlCommandBase { super(GlCommand.WalkthroughGitLensInspect); } - execute() { + execute(): void { const command = GlCommand.ShowCommitDetailsView; this.container.telemetry.sendEvent('walkthrough/action', { type: 'command', @@ -197,7 +197,7 @@ export class WalkthroughOpenInteractiveCodeHistoryCommand extends GlCommandBase super(GlCommand.WalkthroughOpenInteractiveCodeHistory); } - execute() { + execute(): void { const url = urls.interactiveCodeHistory; this.container.telemetry.sendEvent('walkthrough/action', { type: 'url', @@ -215,7 +215,7 @@ export class WalkthroughShowLaunchpadCommand extends GlCommandBase { super(GlCommand.WalkthroughShowLaunchpad); } - execute() { + execute(): void { const command = GlCommand.ShowLaunchpad; this.container.telemetry.sendEvent('walkthrough/action', { type: 'command', @@ -233,7 +233,7 @@ export class WalkthroughWorktreeCreateCommand extends GlCommandBase { super(GlCommand.WalkthroughWorktreeCreate); } - execute() { + execute(): void { const command = GlCommand.GitCommandsWorktreeCreate; this.container.telemetry.sendEvent('walkthrough/action', { type: 'command', @@ -250,7 +250,7 @@ export class WalkthroughOpenDevExPlatformCommand extends GlCommandBase { super(GlCommand.WalkthoughOpenDevExPlatform); } - execute() { + execute(): void { const url = urls.platform; this.container.telemetry.sendEvent('walkthrough/action', { type: 'url', @@ -268,7 +268,7 @@ export class WalkthroughOpenAccelereatePrReviewsCommand extends GlCommandBase { super(GlCommand.WalkthroughOpenAcceleratePrReviews); } - execute() { + execute(): void { const url = urls.acceleratePrReviews; this.container.telemetry.sendEvent('walkthrough/action', { type: 'url', @@ -286,7 +286,7 @@ export class WalkthroughShowDraftsViewCommand extends GlCommandBase { super(GlCommand.WalkthroughShowDraftsView); } - execute() { + execute(): void { const command = GlCommand.ShowDraftsView; this.container.telemetry.sendEvent('walkthrough/action', { type: 'command', @@ -304,7 +304,7 @@ export class WalkthroughOpenStreamlineCollaboration extends GlCommandBase { super(GlCommand.WalkthroughOpenStreamlineCollaboration); } - execute() { + execute(): void { const url = urls.streamlineCollaboration; this.container.telemetry.sendEvent('walkthrough/action', { type: 'url', @@ -322,7 +322,7 @@ export class WalkthroughConnectIntegrationsCommand extends GlCommandBase { super(GlCommand.WalkthroughConnectIntegrations); } - execute() { + execute(): void { const command = GlCommand.PlusConnectCloudIntegrations; this.container.telemetry.sendEvent('walkthrough/action', { type: 'command', @@ -340,7 +340,7 @@ export class WalkthroughShowAutolinksCommand extends GlCommandBase { super(GlCommand.WalkthroughShowAutolinks); } - execute() { + execute(): void { const command = GlCommand.ShowSettingsPageAndJumpToAutolinks; this.container.telemetry.sendEvent('walkthrough/action', { type: 'command', @@ -358,7 +358,7 @@ export class WalkthroughOpenStartIntegrations extends GlCommandBase { super(GlCommand.WalkthroughOpenStartIntegrations); } - execute() { + execute(): void { const url = urls.startIntegrations; this.container.telemetry.sendEvent('walkthrough/action', { type: 'url', diff --git a/src/container.ts b/src/container.ts index ed456ee26b82d..fe16296771d6c 100644 --- a/src/container.ts +++ b/src/container.ts @@ -119,7 +119,7 @@ export class Container { dateFormat: undefined! as string | null, dateStyle: undefined! as DateStyle, - reset: () => { + reset: (): void => { this.BranchDateFormatting.dateFormat = configuration.get('defaultDateFormat'); this.BranchDateFormatting.dateStyle = configuration.get('defaultDateStyle'); }, @@ -130,7 +130,7 @@ export class Container { dateSource: 'authored', dateStyle: 'relative', - reset: () => { + reset: (): void => { this.CommitDateFormatting.dateFormat = configuration.get('defaultDateFormat'); this.CommitDateFormatting.dateSource = configuration.get('defaultDateSource'); this.CommitDateFormatting.dateStyle = configuration.get('defaultDateStyle'); @@ -140,7 +140,7 @@ export class Container { readonly CommitShaFormatting = { length: 7, - reset: () => { + reset: (): void => { // Don't allow shas to be shortened to less than 5 characters this.CommitShaFormatting.length = Math.max(5, configuration.get('advanced.abbreviatedShaLength')); }, @@ -150,7 +150,7 @@ export class Container { dateFormat: null as string | null, dateStyle: 'relative', - reset: () => { + reset: (): void => { this.PullRequestDateFormatting.dateFormat = configuration.get('defaultDateFormat'); this.PullRequestDateFormatting.dateStyle = configuration.get('defaultDateStyle'); }, @@ -160,7 +160,7 @@ export class Container { dateFormat: null as string | null, dateStyle: 'relative', - reset: () => { + reset: (): void => { this.TagDateFormatting.dateFormat = configuration.get('defaultDateFormat'); this.TagDateFormatting.dateStyle = configuration.get('defaultDateStyle'); }, diff --git a/src/emojis.ts b/src/emojis.ts index 9784430d16965..8b2866d1440e5 100644 --- a/src/emojis.ts +++ b/src/emojis.ts @@ -4,7 +4,7 @@ import { decompressFromBase64LZString } from './system/string'; const emojiRegex = /(^|\s):([-+_a-z0-9]+):($|\s)/g; let emojis: Record | undefined = undefined; -export function emojify(message: string) { +export function emojify(message: string): string { if (emojis == null) { emojis = JSON.parse(decompressFromBase64LZString(compressed)); } diff --git a/src/env/browser/md5.ts b/src/env/browser/md5.ts index f810492a29895..8413ab1338956 100644 --- a/src/env/browser/md5.ts +++ b/src/env/browser/md5.ts @@ -209,7 +209,7 @@ function hexToBinary(hex: string) { return String.fromCharCode(...bytes); } -export function md5(s: string, encoding: 'base64' | 'hex' = 'hex') { +export function md5(s: string, encoding: 'base64' | 'hex' = 'hex'): string { const h = hex(md51(s)); // eslint-disable-next-line @typescript-eslint/no-deprecated return encoding === 'hex' ? h : globalThis.btoa(hexToBinary(h)); diff --git a/src/env/node/git/commitMessageProvider.ts b/src/env/node/git/commitMessageProvider.ts index 3b0db447f28b2..270f24bec3df0 100644 --- a/src/env/node/git/commitMessageProvider.ts +++ b/src/env/node/git/commitMessageProvider.ts @@ -38,7 +38,7 @@ class AICommitMessageProvider implements CommitMessageProvider, Disposable { } } - dispose() { + dispose(): void { this._subscription?.dispose(); this._disposable.dispose(); } diff --git a/src/env/node/git/git.ts b/src/env/node/git/git.ts index 1cf34b20c017b..173aac4a7c00d 100644 --- a/src/env/node/git/git.ts +++ b/src/env/node/git/git.ts @@ -390,11 +390,11 @@ export class Git { // Git commands - add(repoPath: string | undefined, pathspecs: string[], ...args: string[]) { + add(repoPath: string | undefined, pathspecs: string[], ...args: string[]): Promise { return this.exec({ cwd: repoPath }, 'add', ...args, '--', ...pathspecs); } - apply(repoPath: string | undefined, patch: string, options: { allowConflicts?: boolean } = {}) { + apply(repoPath: string | undefined, patch: string, options: { allowConflicts?: boolean } = {}): Promise { const params = ['apply', '--whitespace=warn']; if (options.allowConflicts) { params.push('-3'); @@ -412,7 +412,7 @@ export class Git { stdin?: string; }, ...args: string[] - ) { + ): Promise { return this.exec( { cwd: repoPath, @@ -440,7 +440,7 @@ export class Git { startLine?: number; endLine?: number; }, - ) { + ): Promise { const [file, root] = splitPath(fileName, repoPath, true); const params = ['blame', '--root', '--incremental']; @@ -549,11 +549,11 @@ export class Git { } } - branch(repoPath: string, ...args: string[]) { + branch(repoPath: string, ...args: string[]): Promise { return this.exec({ cwd: repoPath }, 'branch', ...args); } - branch__set_upstream(repoPath: string, branch: string, remote: string, remoteBranch: string) { + branch__set_upstream(repoPath: string, branch: string, remote: string, remoteBranch: string): Promise { return this.exec({ cwd: repoPath }, 'branch', '--set-upstream-to', `${remote}/${remoteBranch}`, branch); } @@ -567,7 +567,7 @@ export class Git { name?: string; remotes?: boolean; }, - ) { + ): Promise { const params: string[] = [options?.type ?? 'branch']; if (options?.all) { params.push('-a'); @@ -596,7 +596,7 @@ export class Git { return data.length ? parseInt(data.trim(), 10) : 0; } - check_ignore(repoPath: string, ...files: string[]) { + check_ignore(repoPath: string, ...files: string[]): Promise { return this.exec( { cwd: repoPath, errors: GitErrorHandling.Ignore, stdin: files.join('\0') }, 'check-ignore', @@ -605,11 +605,15 @@ export class Git { ); } - check_mailmap(repoPath: string, author: string) { + check_mailmap(repoPath: string, author: string): Promise { return this.exec({ cwd: repoPath, errors: GitErrorHandling.Ignore }, 'check-mailmap', author); } - async check_ref_format(ref: string, repoPath?: string, options: { branch?: boolean } = { branch: true }) { + async check_ref_format( + ref: string, + repoPath?: string, + options: { branch?: boolean } = { branch: true }, + ): Promise { const params = ['check-ref-format']; if (options.branch) { params.push('--branch'); @@ -629,7 +633,11 @@ export class Git { } } - checkout(repoPath: string, ref: string, { createBranch, path }: { createBranch?: string; path?: string } = {}) { + checkout( + repoPath: string, + ref: string, + { createBranch, path }: { createBranch?: string; path?: string } = {}, + ): Promise { const params = ['checkout']; if (createBranch) { params.push('-b', createBranch, ref, '--'); @@ -646,7 +654,11 @@ export class Git { return this.exec({ cwd: repoPath }, ...params); } - async cherrypick(repoPath: string, sha: string, options: { noCommit?: boolean; errors?: GitErrorHandling } = {}) { + async cherrypick( + repoPath: string, + sha: string, + options: { noCommit?: boolean; errors?: GitErrorHandling } = {}, + ): Promise { const params = ['cherry-pick']; if (options?.noCommit) { params.push('-n'); @@ -689,7 +701,7 @@ export class Git { return folderPath; } - async config__get(key: string, repoPath?: string, options?: { local?: boolean }) { + async config__get(key: string, repoPath?: string, options?: { local?: boolean }): Promise { const data = await this.exec( { cwd: repoPath ?? '', errors: GitErrorHandling.Ignore, local: options?.local }, 'config', @@ -699,7 +711,11 @@ export class Git { return data.length === 0 ? undefined : data.trim(); } - async config__get_regex(pattern: string, repoPath?: string, options?: { local?: boolean }) { + async config__get_regex( + pattern: string, + repoPath?: string, + options?: { local?: boolean }, + ): Promise { const data = await this.exec( { cwd: repoPath ?? '', errors: GitErrorHandling.Ignore, local: options?.local }, 'config', @@ -709,7 +725,7 @@ export class Git { return data.length === 0 ? undefined : data.trim(); } - async config__set(key: string, value: string | undefined, repoPath?: string) { + async config__set(key: string, value: string | undefined, repoPath?: string): Promise { const params = ['config', '--local']; if (value == null) { params.push('--unset', key); @@ -792,7 +808,7 @@ export class Git { stdin?: string; }, ...args: string[] - ) { + ): Promise { return this.exec( { cwd: repoPath, @@ -873,7 +889,7 @@ export class Git { ref1?: string, ref2?: string, options?: { filters?: GitDiffFilter[]; path?: string; similarityThreshold?: number }, - ) { + ): Promise { const params = [ 'diff', '--name-status', @@ -899,7 +915,7 @@ export class Git { return this.exec({ cwd: repoPath, configs: gitDiffDefaultConfigs }, ...params); } - async diff__shortstat(repoPath: string, ref?: string) { + async diff__shortstat(repoPath: string, ref?: string): Promise { const params = ['diff', '--shortstat', '--no-ext-diff']; if (ref) { params.push(ref); @@ -922,7 +938,7 @@ export class Git { fileName: string, tool: string, options: { ref1?: string; ref2?: string; staged?: boolean } = {}, - ) { + ): Promise { const params = ['difftool', '--no-prompt', `--tool=${tool}`]; if (options.staged) { params.push('--staged'); @@ -937,7 +953,7 @@ export class Git { return this.exec({ cwd: repoPath }, ...params, '--', fileName); } - difftool__dir_diff(repoPath: string, tool: string, ref1: string, ref2?: string) { + difftool__dir_diff(repoPath: string, tool: string, ref1: string, ref2?: string): Promise { const params = ['difftool', '--dir-diff', `--tool=${tool}`, ref1]; if (ref2) { params.push(ref2); @@ -1121,7 +1137,7 @@ export class Git { } } - for_each_ref__branch(repoPath: string, options: { all: boolean } = { all: false }) { + for_each_ref__branch(repoPath: string, options: { all: boolean } = { all: false }): Promise { const params = ['for-each-ref', `--format=${parseGitBranchesDefaultFormat}`, 'refs/heads']; if (options.all) { params.push('refs/remotes'); @@ -1140,7 +1156,7 @@ export class Git { stdin?: string; }, ...args: string[] - ) { + ): Promise { return this.exec( { cwd: repoPath, @@ -1270,7 +1286,7 @@ export class Git { startLine?: number; endLine?: number; } = {}, - ) { + ): Promise { const [file, root] = splitPath(fileName, repoPath, true); if (argsOrFormat == null) { @@ -1360,7 +1376,7 @@ export class Git { similarityThreshold?: number | null; cancellation?: CancellationToken; }, - ) { + ): Promise { const params = [ 'log', `-M${options?.similarityThreshold == null ? '' : `${options?.similarityThreshold}%`}`, @@ -1397,7 +1413,7 @@ export class Git { ordering: 'date' | 'author-date' | 'topo' | null, file?: string, cancellation?: CancellationToken, - ) { + ): Promise { const params = ['log', '-n1', '--no-renames', '--format=%H', `--find-object=${oid}`, ref]; if (ordering) { @@ -1420,7 +1436,10 @@ export class Git { return data.length === 0 ? undefined : data.trim(); } - async log__recent(repoPath: string, ordering?: 'date' | 'author-date' | 'topo' | null) { + async log__recent( + repoPath: string, + ordering?: 'date' | 'author-date' | 'topo' | null, + ): Promise { const params = ['log', '-n1', '--format=%H']; if (ordering) { @@ -1436,7 +1455,10 @@ export class Git { return data.length === 0 ? undefined : data.trim(); } - async log__recent_committerdate(repoPath: string, ordering?: 'date' | 'author-date' | 'topo' | null) { + async log__recent_committerdate( + repoPath: string, + ordering?: 'date' | 'author-date' | 'topo' | null, + ): Promise { const params = ['log', '-n1', '--format=%ct']; if (ordering) { @@ -1462,7 +1484,7 @@ export class Git { shas?: Set; stdin?: string; }, - ) { + ): Promise { if (options?.shas != null) { const stdin = join(options.shas, '\n'); return this.exec( @@ -1528,15 +1550,15 @@ export class Git { return data.length === 0 ? undefined : data.trim(); } - ls_remote(repoPath: string, remote: string, ref?: string) { + ls_remote(repoPath: string, remote: string, ref?: string): Promise { return this.exec({ cwd: repoPath }, 'ls-remote', remote, ref); } - ls_remote__HEAD(repoPath: string, remote: string) { + ls_remote__HEAD(repoPath: string, remote: string): Promise { return this.exec({ cwd: repoPath }, 'ls-remote', '--symref', remote, 'HEAD'); } - async ls_tree(repoPath: string, ref: string, path?: string) { + async ls_tree(repoPath: string, ref: string, path?: string): Promise { const params = ['ls-tree']; if (path) { params.push('-l', ref, '--', path); @@ -1547,7 +1569,7 @@ export class Git { return data.length === 0 ? undefined : data.trim(); } - merge_base(repoPath: string, rev1: string, rev2: string, options?: { forkPoint?: boolean }) { + merge_base(repoPath: string, rev1: string, rev2: string, options?: { forkPoint?: boolean }): Promise { const params = ['merge-base']; if (options?.forkPoint) { params.push('--fork-point'); @@ -1624,7 +1646,7 @@ export class Git { return this.exec({ cwd: repoPath }, 'remote', '-v'); } - remote__add(repoPath: string, name: string, url: string, options?: { fetch?: boolean }) { + remote__add(repoPath: string, name: string, url: string, options?: { fetch?: boolean }): Promise { const params = ['remote', 'add']; if (options?.fetch) { params.push('-f'); @@ -1632,11 +1654,11 @@ export class Git { return this.exec({ cwd: repoPath }, ...params, name, url); } - remote__prune(repoPath: string, name: string) { + remote__prune(repoPath: string, name: string): Promise { return this.exec({ cwd: repoPath }, 'remote', 'prune', name); } - remote__remove(repoPath: string, name: string) { + remote__remove(repoPath: string, name: string): Promise { return this.exec({ cwd: repoPath }, 'remote', 'remove', name); } @@ -1969,7 +1991,7 @@ export class Git { repoPath: string, options?: { cancellation?: CancellationToken; configs?: readonly string[] }, ...args: string[] - ) { + ): Promise { return this.exec( { cwd: repoPath, @@ -2031,7 +2053,13 @@ export class Git { return this.exec({ cwd: repoPath }, 'stash', deleteAfter ? 'pop' : 'apply', stashName); } - async stash__rename(repoPath: string, stashName: string, sha: string, message: string, stashOnRef?: string) { + async stash__rename( + repoPath: string, + stashName: string, + sha: string, + message: string, + stashOnRef?: string, + ): Promise { await this.stash__delete(repoPath, stashName, sha); return this.exec( { cwd: repoPath }, @@ -2043,7 +2071,7 @@ export class Git { ); } - async stash__delete(repoPath: string, stashName: string, sha?: string) { + async stash__delete(repoPath: string, stashName: string, sha?: string): Promise { if (!stashName) return undefined; if (sha) { @@ -2065,7 +2093,7 @@ export class Git { stash__list( repoPath: string, { args, similarityThreshold }: { args?: string[]; similarityThreshold?: number | null }, - ) { + ): Promise { if (args == null) { args = ['--name-status']; } @@ -2161,7 +2189,7 @@ export class Git { } } - stash(repoPath: string, ...args: string[]) { + stash(repoPath: string, ...args: string[]): Promise { return this.exec({ cwd: repoPath }, 'stash', ...args); } @@ -2189,11 +2217,11 @@ export class Git { ); } - symbolic_ref(repoPath: string, ref: string) { + symbolic_ref(repoPath: string, ref: string): Promise { return this.exec({ cwd: repoPath }, 'symbolic-ref', '--short', ref); } - async tag(repoPath: string, ...args: string[]) { + async tag(repoPath: string, ...args: string[]): Promise { try { const output = await this.exec({ cwd: repoPath }, 'tag', ...args); return output; @@ -2217,7 +2245,7 @@ export class Git { detach, force, }: { commitish?: string; createBranch?: string; detach?: boolean; force?: boolean } = {}, - ) { + ): Promise { const params = ['worktree', 'add']; if (force) { params.push('--force'); @@ -2235,11 +2263,11 @@ export class Git { return this.exec({ cwd: repoPath }, ...params); } - worktree__list(repoPath: string) { + worktree__list(repoPath: string): Promise { return this.exec({ cwd: repoPath }, 'worktree', 'list', '--porcelain'); } - worktree__remove(repoPath: string, worktree: string, { force }: { force?: boolean } = {}) { + worktree__remove(repoPath: string, worktree: string, { force }: { force?: boolean } = {}): Promise { const params = ['worktree', 'remove']; if (force) { params.push('--force'); @@ -2282,7 +2310,12 @@ export class Git { } } @log() - async runGitCommandViaTerminal(cwd: string, command: string, args: string[], options?: { execute?: boolean }) { + async runGitCommandViaTerminal( + cwd: string, + command: string, + args: string[], + options?: { execute?: boolean }, + ): Promise { const scope = getLogScope(); const location = await this.getLocation(); @@ -2353,6 +2386,6 @@ export class Git { } } -export function getShaInLogRegex(sha: string) { +export function getShaInLogRegex(sha: string): RegExp { return new RegExp(`(?:^\x00*|\x00\x00)${sha}\x00`); } diff --git a/src/env/node/git/localGitProvider.ts b/src/env/node/git/localGitProvider.ts index 82e5aa3f26205..9d2bf3b811411 100644 --- a/src/env/node/git/localGitProvider.ts +++ b/src/env/node/git/localGitProvider.ts @@ -185,7 +185,7 @@ export class LocalGitProvider implements GitProvider, Disposable { this.git.setLocator(this.ensureGit.bind(this)); } - dispose() { + dispose(): void { this._disposables.forEach(d => void d.dispose()); } @@ -909,7 +909,7 @@ export class LocalGitProvider implements GitProvider, Disposable { } @log({ exit: true }) - async getWorkingUri(repoPath: string, uri: Uri) { + async getWorkingUri(repoPath: string, uri: Uri): Promise { let relativePath = this.getRelativePath(uri, repoPath); let data; @@ -954,7 +954,7 @@ export class LocalGitProvider implements GitProvider, Disposable { } @log() - async applyChangesToWorkingFile(uri: GitUri, ref1?: string, ref2?: string) { + async applyChangesToWorkingFile(uri: GitUri, ref1?: string, ref2?: string): Promise { const scope = getLogScope(); ref1 = ref1 ?? uri.sha; @@ -2623,7 +2623,7 @@ export class LocalGitProvider implements GitProvider, Disposable { options?: { filter?: { branches?: (b: GitBranch) => boolean; tags?: (t: GitTag) => boolean }; }, - ) { + ): Promise { if (repoPath == null) return false; const [{ values: branches }, { values: tags }] = await Promise.all([ @@ -2878,7 +2878,7 @@ export class LocalGitProvider implements GitProvider, Disposable { ref: string, pathOrUri?: string | Uri, options?: { force?: boolean; timeout?: number }, - ) { + ): Promise { if ( !ref || ref === deletedOrMissing || diff --git a/src/env/node/git/shell.ts b/src/env/node/git/shell.ts index 823c36e3de528..40069f15ccd27 100644 --- a/src/env/node/git/shell.ts +++ b/src/env/node/git/shell.ts @@ -290,6 +290,6 @@ export function run( }); } -export async function fsExists(path: string) { +export async function fsExists(path: string): Promise { return new Promise(resolve => access(path, constants.F_OK, err => resolve(err == null))); } diff --git a/src/env/node/git/sub-providers/branches.ts b/src/env/node/git/sub-providers/branches.ts index 0e57fbc282f41..6d2d08d9cae96 100644 --- a/src/env/node/git/sub-providers/branches.ts +++ b/src/env/node/git/sub-providers/branches.ts @@ -295,7 +295,12 @@ export class BranchesGitSubProvider implements GitBranchesSubProvider { } @log() - async getMergeBase(repoPath: string, ref1: string, ref2: string, options?: { forkPoint?: boolean }) { + async getMergeBase( + repoPath: string, + ref1: string, + ref2: string, + options?: { forkPoint?: boolean }, + ): Promise { const scope = getLogScope(); try { diff --git a/src/env/node/git/sub-providers/remotes.ts b/src/env/node/git/sub-providers/remotes.ts index 768e24a81fbb4..37efc369fc1ce 100644 --- a/src/env/node/git/sub-providers/remotes.ts +++ b/src/env/node/git/sub-providers/remotes.ts @@ -6,7 +6,7 @@ import type { GitRemote } from '../../../../git/models/remote'; import { parseGitRemotes } from '../../../../git/parsers/remoteParser'; import { getRemoteProviderMatcher, loadRemoteProviders } from '../../../../git/remotes/remoteProviders'; import { RemotesGitProviderBase } from '../../../../git/sub-providers/remotes'; -import { sortRemotes } from '../../../../git/utils/remote.utils'; +import { sortRemotes } from '../../../../git/utils/-webview/sorting'; import { configuration } from '../../../../system/-webview/configuration'; import { gate } from '../../../../system/decorators/-webview/gate'; import { log } from '../../../../system/decorators/log'; diff --git a/src/env/node/git/sub-providers/tags.ts b/src/env/node/git/sub-providers/tags.ts index 1194b9202d8a9..ec9e5e9569eef 100644 --- a/src/env/node/git/sub-providers/tags.ts +++ b/src/env/node/git/sub-providers/tags.ts @@ -91,7 +91,7 @@ export class TagsGitSubProvider implements GitTagsSubProvider { await this.git.tag(repoPath, name, sha, ...(message != null && message.length > 0 ? ['-m', message] : [])); } catch (ex) { if (ex instanceof TagError) { - throw ex.WithTag(name).WithAction('create'); + throw ex.withTag(name).withAction('create'); } throw ex; @@ -104,7 +104,7 @@ export class TagsGitSubProvider implements GitTagsSubProvider { await this.git.tag(repoPath, '-d', name); } catch (ex) { if (ex instanceof TagError) { - throw ex.WithTag(name).WithAction('delete'); + throw ex.withTag(name).withAction('delete'); } throw ex; diff --git a/src/env/node/git/sub-providers/worktrees.ts b/src/env/node/git/sub-providers/worktrees.ts index 7066ae60983ec..2a756504836a8 100644 --- a/src/env/node/git/sub-providers/worktrees.ts +++ b/src/env/node/git/sub-providers/worktrees.ts @@ -144,7 +144,7 @@ export class WorktreesGitSubProvider implements GitWorktreesSubProvider { } @log() - async deleteWorktree(repoPath: string, path: string | Uri, options?: { force?: boolean }) { + async deleteWorktree(repoPath: string, path: string | Uri, options?: { force?: boolean }): Promise { const scope = getLogScope(); await this.git.ensureGitVersion( diff --git a/src/env/node/gk/localRepositoryLocationProvider.ts b/src/env/node/gk/localRepositoryLocationProvider.ts index 0bbe642c852d6..5fc4c874c7b4d 100644 --- a/src/env/node/gk/localRepositoryLocationProvider.ts +++ b/src/env/node/gk/localRepositoryLocationProvider.ts @@ -14,7 +14,7 @@ export class LocalRepositoryLocationProvider implements RepositoryLocationProvid private readonly sharedStorage: SharedGkStorageLocationProvider, ) {} - dispose() {} + dispose(): void {} private _localRepoDataMap: LocalRepoDataMap | undefined = undefined; diff --git a/src/env/node/gk/localSharedGkStorageLocationProvider.ts b/src/env/node/gk/localSharedGkStorageLocationProvider.ts index a7608b8edfa5a..b61bf51f2bea6 100644 --- a/src/env/node/gk/localSharedGkStorageLocationProvider.ts +++ b/src/env/node/gk/localSharedGkStorageLocationProvider.ts @@ -115,20 +115,20 @@ export class LocalSharedGkStorageLocationProvider implements SharedGkStorageLoca return true; } - async getSharedRepositoryLocationFileUri() { + async getSharedRepositoryLocationFileUri(): Promise { return this.getUri('repoMapping.json'); } - async getSharedCloudWorkspaceMappingFileUri() { + async getSharedCloudWorkspaceMappingFileUri(): Promise { return this.getUri('cloudWorkspaces.json'); } - async getSharedLocalWorkspaceMappingFileUri() { + async getSharedLocalWorkspaceMappingFileUri(): Promise { return this.getUri('localWorkspaces.json'); } } -export function getGKDLocalWorkspaceMappingFileUri() { +export function getGKDLocalWorkspaceMappingFileUri(): Uri { return Uri.file( join( homedir(), diff --git a/src/errors.ts b/src/errors.ts index f24065f1efcbf..e0b148b9712bd 100644 --- a/src/errors.ts +++ b/src/errors.ts @@ -171,11 +171,11 @@ export class OpenVirtualRepositoryError extends Error { } export class ProviderFetchError extends Error { - get status() { + get status(): number { return this.response.status; } - get statusText() { + get statusText(): string { return this.response.statusText; } diff --git a/src/eventBus.ts b/src/eventBus.ts index 2b9e64143ce93..f8f133540482c 100644 --- a/src/eventBus.ts +++ b/src/eventBus.ts @@ -87,11 +87,11 @@ const _cachedEventArgs = new Map(); - dispose() { + dispose(): void { this._emitter.dispose(); } - fire(name: T, data: EventsMapping[T], options?: EventBusOptions) { + fire(name: T, data: EventsMapping[T], options?: EventBusOptions): void { if (canCacheEventArgs(name)) { _cachedEventArgs.set(name, data as CacheableEventsMapping[typeof name]); } @@ -102,7 +102,7 @@ export class EventBus implements Disposable { }); } - fireAsync(name: T, data: EventsMapping[T], options?: EventBusOptions) { + fireAsync(name: T, data: EventsMapping[T], options?: EventBusOptions): void { queueMicrotask(() => this.fire(name, data, options)); } @@ -110,7 +110,7 @@ export class EventBus implements Disposable { return _cachedEventArgs.get(name) as CacheableEventsMapping[T] | undefined; } - on(name: T, handler: (e: EventBusEvent) => void, thisArgs?: unknown) { + on(name: T, handler: (e: EventBusEvent) => void, thisArgs?: unknown): Disposable { return this._emitter.event( // eslint-disable-next-line prefer-arrow-callback function (e) { diff --git a/src/extension.ts b/src/extension.ts index 738606bd55782..c0972fa460b13 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -269,7 +269,7 @@ export async function activate(context: ExtensionContext): Promise { void (await executeEditorCommand(GlCommand.BrowseRepoAtRevision, undefined, { uri: uri, before: options?.before, diff --git a/src/git/actions/branch.ts b/src/git/actions/branch.ts index 704f4e0984bea..6c05c70ed14ba 100644 --- a/src/git/actions/branch.ts +++ b/src/git/actions/branch.ts @@ -1,9 +1,10 @@ import { Container } from '../../container'; +import type { ViewNode } from '../../views/nodes/abstract/viewNode'; import { executeGitCommand } from '../actions'; import type { GitBranchReference, GitReference } from '../models/reference'; import type { Repository } from '../models/repository'; -export function create(repo?: string | Repository, ref?: GitReference, name?: string) { +export function create(repo?: string | Repository, ref?: GitReference, name?: string): Promise { return executeGitCommand({ command: 'branch', state: { @@ -15,7 +16,7 @@ export function create(repo?: string | Repository, ref?: GitReference, name?: st }); } -export function remove(repo?: string | Repository, refs?: GitBranchReference | GitBranchReference[]) { +export function remove(repo?: string | Repository, refs?: GitBranchReference | GitBranchReference[]): Promise { return executeGitCommand({ command: 'branch', state: { @@ -26,7 +27,7 @@ export function remove(repo?: string | Repository, refs?: GitBranchReference | G }); } -export function rename(repo?: string | Repository, ref?: GitBranchReference, name?: string) { +export function rename(repo?: string | Repository, ref?: GitBranchReference, name?: string): Promise { return executeGitCommand({ command: 'branch', state: { @@ -45,6 +46,6 @@ export function reveal( focus?: boolean; expand?: boolean | number; }, -) { +): Promise { return Container.instance.views.revealBranch(branch, options); } diff --git a/src/git/actions/commit.ts b/src/git/actions/commit.ts index a5017dd818643..a0b55325eb982 100644 --- a/src/git/actions/commit.ts +++ b/src/git/actions/commit.ts @@ -17,6 +17,7 @@ import { executeCommand, executeCoreGitCommand, executeEditorCommand } from '../ import { configuration } from '../../system/-webview/configuration'; import { findOrOpenEditor, findOrOpenEditors, openChangesEditor } from '../../system/-webview/vscode'; import { getSettledValue } from '../../system/promise'; +import type { ViewNode } from '../../views/nodes/abstract/viewNode'; import type { ShowInCommitGraphCommandArgs } from '../../webviews/plus/graph/protocol'; import { GitUri } from '../gitUri'; import type { GitCommit } from '../models/commit'; @@ -45,7 +46,11 @@ const filesOpenThreshold = 10; const filesOpenDiffsThreshold = 10; const filesOpenMultiDiffThreshold = 50; -export async function applyChanges(file: string | GitFile, rev1: GitRevisionReference, rev2?: GitRevisionReference) { +export async function applyChanges( + file: string | GitFile, + rev1: GitRevisionReference, + rev2?: GitRevisionReference, +): Promise { let create = false; let ref1 = rev1.ref; let ref2 = rev2?.ref; @@ -81,7 +86,7 @@ export async function applyChanges(file: string | GitFile, rev1: GitRevisionRefe } } -export async function copyIdToClipboard(ref: Ref | GitCommit) { +export async function copyIdToClipboard(ref: Ref | GitCommit): Promise { await env.clipboard.writeText(ref.ref); } @@ -239,7 +244,7 @@ export async function openAllChangesInChangesEditor( export async function openAllChangesWithDiffTool(commit: GitCommit): Promise; export async function openAllChangesWithDiffTool(files: GitFile[], ref: Ref): Promise; -export async function openAllChangesWithDiffTool(commitOrFiles: GitCommit | GitFile[], ref?: Ref) { +export async function openAllChangesWithDiffTool(commitOrFiles: GitCommit | GitFile[], ref?: Ref): Promise { const { files } = await getChangesRefArgs(commitOrFiles, ref); if ( @@ -270,7 +275,7 @@ export async function openAllChangesWithWorking( commitOrFiles: GitCommit | GitFile[], refOrOptions: Ref | (TextDocumentShowOptions & { title?: string }) | undefined, maybeOptions?: TextDocumentShowOptions & { title?: string }, -) { +): Promise { if (isCommit(commitOrFiles)) { if (configuration.get('views.openChangesInMultiDiffEditor')) { return openAllChangesInChangesEditor(commitOrFiles, refOrOptions as TextDocumentShowOptions | undefined); @@ -308,7 +313,7 @@ export async function openAllChangesWithWorkingIndividually( commitOrFiles: GitCommit | GitFile[], refOrOptions: Ref | TextDocumentShowOptions | undefined, maybeOptions?: TextDocumentShowOptions, -) { +): Promise { let { files, ref, options } = await getChangesRefArgs(commitOrFiles, refOrOptions, maybeOptions); if ( @@ -347,7 +352,7 @@ export async function openChanges( file: string | GitFile, commitOrRefs: GitCommit | RefRange, options?: TextDocumentShowOptions & { lhsTitle?: string; rhsTitle?: string }, -) { +): Promise { const hasCommit = isCommit(commitOrRefs); if (typeof file === 'string') { @@ -396,7 +401,11 @@ export async function openChanges( export function openChangesWithDiffTool(file: string | GitFile, commit: GitCommit, tool?: string): Promise; export function openChangesWithDiffTool(file: GitFile, ref: Ref, tool?: string): Promise; -export async function openChangesWithDiffTool(file: string | GitFile, commitOrRef: GitCommit | Ref, tool?: string) { +export async function openChangesWithDiffTool( + file: string | GitFile, + commitOrRef: GitCommit | Ref, + tool?: string, +): Promise { if (typeof file === 'string') { if (!isCommit(commitOrRef)) throw new Error('Invalid arguments'); @@ -432,7 +441,7 @@ export async function openChangesWithWorking( file: string | GitFile, commitOrRef: GitCommit | Ref, options?: TextDocumentShowOptions & { lhsTitle?: string }, -) { +): Promise { if (typeof file === 'string') { if (!isCommit(commitOrRef)) throw new Error('Invalid arguments'); @@ -546,7 +555,7 @@ export async function openFile( fileOrUri: string | GitFile | Uri, refOrOptions?: GitRevisionReference | TextDocumentShowOptions, options?: TextDocumentShowOptions, -) { +): Promise { let uri; if (fileOrUri instanceof Uri) { uri = fileOrUri; @@ -737,7 +746,7 @@ export async function openFilesAtRevision( ); } -export async function restoreFile(file: string | GitFile, revision: GitRevisionReference) { +export async function restoreFile(file: string | GitFile, revision: GitRevisionReference): Promise { let path; let ref; if (typeof file === 'string') { @@ -771,7 +780,7 @@ export function reveal( focus?: boolean; expand?: boolean | number; }, -) { +): Promise { return Container.instance.views.revealCommit(commit, options); } @@ -851,7 +860,7 @@ export async function openOnlyChangedFiles(container: Container, commitOrFiles: })); } -export async function undoCommit(container: Container, commit: GitRevisionReference) { +export async function undoCommit(container: Container, commit: GitRevisionReference): Promise { const repo = await container.git.getOrOpenScmRepository(commit.repoPath); const scmCommit = await repo?.getCommit('HEAD'); diff --git a/src/git/actions/contributor.ts b/src/git/actions/contributor.ts index b89892e207988..960993d9bcec8 100644 --- a/src/git/actions/contributor.ts +++ b/src/git/actions/contributor.ts @@ -1,9 +1,13 @@ import { Container } from '../../container'; +import type { ViewNode } from '../../views/nodes/abstract/viewNode'; import { executeGitCommand } from '../actions'; import type { GitContributor } from '../models/contributor'; import type { Repository } from '../models/repository'; -export function addAuthors(repo?: string | Repository, contributors?: GitContributor | GitContributor[]) { +export function addAuthors( + repo?: string | Repository, + contributors?: GitContributor | GitContributor[], +): Promise { return executeGitCommand({ command: 'co-authors', state: { repo: repo, contributors: contributors }, @@ -17,6 +21,6 @@ export function reveal( focus?: boolean; expand?: boolean | number; }, -) { +): Promise { return Container.instance.views.revealContributor(contributor, options); } diff --git a/src/git/actions/remote.ts b/src/git/actions/remote.ts index d24b36545cd99..2fbdac42fedce 100644 --- a/src/git/actions/remote.ts +++ b/src/git/actions/remote.ts @@ -1,4 +1,5 @@ import { Container } from '../../container'; +import type { ViewNode } from '../../views/nodes/abstract/viewNode'; import { executeGitCommand } from '../actions'; import type { GitRemote } from '../models/remote'; import type { Repository } from '../models/repository'; @@ -8,7 +9,7 @@ export function add( name?: string, url?: string, options?: { confirm?: boolean; fetch?: boolean; reveal?: boolean }, -) { +): Promise { return executeGitCommand({ command: 'remote', confirm: options?.confirm, @@ -23,7 +24,7 @@ export function add( }); } -export async function fetch(repo: string | Repository, remote: string) { +export async function fetch(repo: string | Repository, remote: string): Promise { if (typeof repo === 'string') { const r = Container.instance.git.getRepository(repo); if (r == null) return; @@ -34,14 +35,14 @@ export async function fetch(repo: string | Repository, remote: string) { await repo.fetch({ remote: remote }); } -export async function prune(repo: string | Repository, remote: string) { +export async function prune(repo: string | Repository, remote: string): Promise { return executeGitCommand({ command: 'remote', state: { repo: repo, subcommand: 'prune', remote: remote }, }); } -export async function remove(repo: string | Repository, remote: string) { +export async function remove(repo: string | Repository, remote: string): Promise { return executeGitCommand({ command: 'remote', state: { repo: repo, subcommand: 'remove', remote: remote }, @@ -55,6 +56,6 @@ export function reveal( focus?: boolean; expand?: boolean | number; }, -) { +): Promise { return Container.instance.views.revealRemote(remote, options); } diff --git a/src/git/actions/repository.ts b/src/git/actions/repository.ts index b81b890274ce7..d8a647eddc114 100644 --- a/src/git/actions/repository.ts +++ b/src/git/actions/repository.ts @@ -1,36 +1,44 @@ import { Container } from '../../container'; +import type { ViewNode } from '../../views/nodes/abstract/viewNode'; import type { ViewsWithRepositoryFolders } from '../../views/viewBase'; import { executeGitCommand } from '../actions'; import type { GitBranchReference, GitReference, GitRevisionReference, GitTagReference } from '../models/reference'; import type { Repository } from '../models/repository'; -export function cherryPick(repo?: string | Repository, refs?: GitRevisionReference | GitRevisionReference[]) { +export function cherryPick( + repo?: string | Repository, + refs?: GitRevisionReference | GitRevisionReference[], +): Promise { return executeGitCommand({ command: 'cherry-pick', state: { repo: repo, references: refs }, }); } -export function fetch(repos?: string | string[] | Repository | Repository[], ref?: GitBranchReference) { +export function fetch(repos?: string | string[] | Repository | Repository[], ref?: GitBranchReference): Promise { return executeGitCommand({ command: 'fetch', state: { repos: repos, reference: ref } }); } -export function merge(repo?: string | Repository, ref?: GitReference) { +export function merge(repo?: string | Repository, ref?: GitReference): Promise { return executeGitCommand({ command: 'merge', state: { repo: repo, reference: ref } }); } -export function pull(repos?: string | string[] | Repository | Repository[], ref?: GitBranchReference) { +export function pull(repos?: string | string[] | Repository | Repository[], ref?: GitBranchReference): Promise { return executeGitCommand({ command: 'pull', state: { repos: repos, reference: ref } }); } -export function push(repos?: string | string[] | Repository | Repository[], force?: boolean, ref?: GitReference) { +export function push( + repos?: string | string[] | Repository | Repository[], + force?: boolean, + ref?: GitReference, +): Promise { return executeGitCommand({ command: 'push', state: { repos: repos, flags: force ? ['--force'] : [], reference: ref }, }); } -export function rebase(repo?: string | Repository, ref?: GitReference, interactive: boolean = true) { +export function rebase(repo?: string | Repository, ref?: GitReference, interactive: boolean = true): Promise { return executeGitCommand({ command: 'rebase', state: { repo: repo, destination: ref, flags: interactive ? ['--interactive'] : [] }, @@ -41,7 +49,7 @@ export function reset( repo?: string | Repository, ref?: GitRevisionReference | GitTagReference, options?: { hard?: boolean; soft?: never } | { hard?: never; soft?: boolean }, -) { +): Promise { const flags: Array<'--hard' | '--soft'> = []; if (options?.hard) { flags.push('--hard'); @@ -56,14 +64,21 @@ export function reset( }); } -export function revert(repo?: string | Repository, refs?: GitRevisionReference | GitRevisionReference[]) { +export function revert( + repo?: string | Repository, + refs?: GitRevisionReference | GitRevisionReference[], +): Promise { return executeGitCommand({ command: 'revert', state: { repo: repo, references: refs }, }); } -export function switchTo(repos?: string | string[] | Repository | Repository[], ref?: GitReference, confirm?: boolean) { +export function switchTo( + repos?: string | string[] | Repository | Repository[], + ref?: GitReference, + confirm?: boolean, +): Promise { return executeGitCommand({ command: 'switch', state: { repos: repos, reference: ref }, @@ -79,6 +94,6 @@ export function reveal( focus?: boolean; expand?: boolean | number; }, -) { +): Promise { return Container.instance.views.revealRepository(repoPath, view, options); } diff --git a/src/git/actions/stash.ts b/src/git/actions/stash.ts index 44852c2c9d575..2b01962c82410 100644 --- a/src/git/actions/stash.ts +++ b/src/git/actions/stash.ts @@ -1,33 +1,34 @@ import type { Uri } from 'vscode'; import type { PushFlags } from '../../commands/git/stash'; import { Container } from '../../container'; +import type { ViewNode } from '../../views/nodes/abstract/viewNode'; import { executeGitCommand } from '../actions'; import type { GitStashCommit } from '../models/commit'; import type { GitStashReference } from '../models/reference'; import type { Repository } from '../models/repository'; -export function apply(repo?: string | Repository, ref?: GitStashReference) { +export function apply(repo?: string | Repository, ref?: GitStashReference): Promise { return executeGitCommand({ command: 'stash', state: { subcommand: 'apply', repo: repo, reference: ref }, }); } -export function drop(repo?: string | Repository, refs?: GitStashReference[]) { +export function drop(repo?: string | Repository, refs?: GitStashReference[]): Promise { return executeGitCommand({ command: 'stash', state: { subcommand: 'drop', repo: repo, references: refs }, }); } -export function rename(repo?: string | Repository, ref?: GitStashReference, message?: string) { +export function rename(repo?: string | Repository, ref?: GitStashReference, message?: string): Promise { return executeGitCommand({ command: 'stash', state: { subcommand: 'rename', repo: repo, reference: ref, message: message }, }); } -export function pop(repo?: string | Repository, ref?: GitStashReference) { +export function pop(repo?: string | Repository, ref?: GitStashReference): Promise { return executeGitCommand({ command: 'stash', state: { subcommand: 'pop', repo: repo, reference: ref }, @@ -42,7 +43,7 @@ export function push( keepStaged: boolean = false, onlyStaged: boolean = false, onlyStagedUris?: Uri[], -) { +): Promise { return executeGitCommand({ command: 'stash', state: { @@ -67,7 +68,7 @@ export function reveal( focus?: boolean; expand?: boolean | number; }, -) { +): Promise { return Container.instance.views.revealStash(stash, options); } diff --git a/src/git/actions/tag.ts b/src/git/actions/tag.ts index 755ba14f8c6b8..25a4ca5f23d57 100644 --- a/src/git/actions/tag.ts +++ b/src/git/actions/tag.ts @@ -1,9 +1,10 @@ import { Container } from '../../container'; +import type { ViewNode } from '../../views/nodes/abstract/viewNode'; import { executeGitCommand } from '../actions'; import type { GitReference, GitTagReference } from '../models/reference'; import type { Repository } from '../models/repository'; -export function create(repo?: string | Repository, ref?: GitReference, name?: string) { +export function create(repo?: string | Repository, ref?: GitReference, name?: string): Promise { return executeGitCommand({ command: 'tag', state: { @@ -15,7 +16,7 @@ export function create(repo?: string | Repository, ref?: GitReference, name?: st }); } -export function remove(repo?: string | Repository, refs?: GitTagReference | GitTagReference[]) { +export function remove(repo?: string | Repository, refs?: GitTagReference | GitTagReference[]): Promise { return executeGitCommand({ command: 'tag', state: { @@ -33,6 +34,6 @@ export function reveal( focus?: boolean; expand?: boolean | number; }, -) { +): Promise { return Container.instance.views.revealTag(tag, options); } diff --git a/src/git/actions/worktree.ts b/src/git/actions/worktree.ts index 6ca055ef7840f..e5418c24fd0f6 100644 --- a/src/git/actions/worktree.ts +++ b/src/git/actions/worktree.ts @@ -3,6 +3,7 @@ import type { WorktreeGitCommandArgs } from '../../commands/git/worktree'; import { Container } from '../../container'; import type { OpenWorkspaceLocation } from '../../system/-webview/vscode'; import { defer } from '../../system/promise'; +import type { ViewNode } from '../../views/nodes/abstract/viewNode'; import { executeGitCommand } from '../actions'; import type { GitReference } from '../models/reference'; import type { Repository } from '../models/repository'; @@ -13,7 +14,7 @@ export async function create( uri?: Uri, ref?: GitReference, options?: { addRemote?: { name: string; url: string }; createBranch?: string; reveal?: boolean }, -) { +): Promise { const deferred = defer(); await executeGitCommand({ @@ -42,7 +43,7 @@ export function copyChangesToWorktree( type: 'working-tree' | 'index', repo?: string | Repository, worktree?: GitWorktree, -) { +): Promise { return executeGitCommand({ command: 'worktree', state: { @@ -56,7 +57,10 @@ export function copyChangesToWorktree( }); } -export function open(worktree: GitWorktree, options?: { location?: OpenWorkspaceLocation; openOnly?: boolean }) { +export function open( + worktree: GitWorktree, + options?: { location?: OpenWorkspaceLocation; openOnly?: boolean }, +): Promise { return executeGitCommand({ command: 'worktree', state: { @@ -69,7 +73,7 @@ export function open(worktree: GitWorktree, options?: { location?: OpenWorkspace }); } -export function remove(repo?: string | Repository, uris?: Uri[]) { +export function remove(repo?: string | Repository, uris?: Uri[]): Promise { return executeGitCommand({ command: 'worktree', state: { subcommand: 'delete', repo: repo, uris: uris }, @@ -79,7 +83,7 @@ export function remove(repo?: string | Repository, uris?: Uri[]) { export function reveal( worktree: GitWorktree, options?: { select?: boolean; focus?: boolean; expand?: boolean | number }, -) { +): Promise { return Container.instance.views.revealWorktree(worktree, options); } diff --git a/src/git/cache.ts b/src/git/cache.ts index 636576e4bdabc..60124f990bfbb 100644 --- a/src/git/cache.ts +++ b/src/git/cache.ts @@ -46,13 +46,13 @@ export class GitCache implements Disposable { ); } - dispose() { + dispose(): void { this.reset(); this._disposable.dispose(); } private _useCaching: boolean = false; - get useCaching() { + get useCaching(): boolean { return this._useCaching; } @@ -62,63 +62,63 @@ export class GitCache implements Disposable { } private _branchCache: Map> | undefined; - get branch() { + get branch(): Map> | undefined { return this.useCaching ? (this._branchCache ??= new Map>()) : undefined; } private _branchesCache: Map>> | undefined; - get branches() { + get branches(): Map>> | undefined { return this.useCaching ? (this._branchesCache ??= new Map>>()) : undefined; } private _contributorsCache: Map>> | undefined; - get contributors() { + get contributors(): Map>> | undefined { return this.useCaching ? (this._contributorsCache ??= new Map>>()) : undefined; } private _pausedOperationStatusCache: Map> | undefined; - get pausedOperationStatus() { + get pausedOperationStatus(): Map> | undefined { return this.useCaching ? (this._pausedOperationStatusCache ??= new Map>()) : undefined; } private _remotesCache: Map> | undefined; - get remotes() { + get remotes(): Map> | undefined { return this.useCaching ? (this._remotesCache ??= new Map>()) : undefined; } private _repoInfoCache: Map | undefined; - get repoInfo() { + get repoInfo(): Map { return (this._repoInfoCache ??= new Map()); } private _stashesCache: Map | undefined; - get stashes() { + get stashes(): Map | undefined { return this.useCaching ? (this._stashesCache ??= new Map()) : undefined; } private _tagsCache: Map>> | undefined; - get tags() { + get tags(): Map>> | undefined { return this.useCaching ? (this._tagsCache ??= new Map>>()) : undefined; } private _trackedPaths = new PathTrie>(); - get trackedPaths() { + get trackedPaths(): PathTrie> { return this._trackedPaths; } private _worktreesCache: Map> | undefined; - get worktrees() { + get worktrees(): Map> | undefined { return this.useCaching ? (this._worktreesCache ??= new Map>()) : undefined; } @log({ singleLine: true }) - clearCaches(repoPath: string | undefined, ...caches: GitCaches[]) { + clearCaches(repoPath: string | undefined, ...caches: GitCaches[]): void { const cachesToClear = new Set | PathTrie | undefined>(); if (!caches.length || caches.includes('branches')) { @@ -170,7 +170,7 @@ export class GitCache implements Disposable { } @log({ singleLine: true }) - reset(onlyConfigControlledCaches: boolean = false) { + reset(onlyConfigControlledCaches: boolean = false): void { this._branchCache?.clear(); this._branchCache = undefined; this._branchesCache?.clear(); diff --git a/src/git/errors.ts b/src/git/errors.ts index c427c70a6886f..9ff86c1143849 100644 --- a/src/git/errors.ts +++ b/src/git/errors.ts @@ -557,13 +557,13 @@ export class TagError extends Error { Error.captureStackTrace?.(this, TagError); } - WithTag(tag: string) { + withTag(tag: string): this { this.tag = tag; this.message = TagError.buildTagErrorMessage(this.reason, tag, this.action); return this; } - WithAction(action: string) { + withAction(action: string): this { this.action = action; this.message = TagError.buildTagErrorMessage(this.reason, this.tag, action); return this; diff --git a/src/git/formatters/commitFormatter.ts b/src/git/formatters/commitFormatter.ts index 2f001369df03f..4dc674ca210c7 100644 --- a/src/git/formatters/commitFormatter.ts +++ b/src/git/formatters/commitFormatter.ts @@ -121,7 +121,7 @@ export class CommitFormatter extends Formatter { protected declare _options: RequiredTokenOptions & Required>; - override reset(item: GitCommit, options?: CommitFormatOptions) { + override reset(item: GitCommit, options?: CommitFormatOptions): void { super.reset(item, options); if (this._options.outputFormat == null) { this._options.outputFormat = 'plaintext'; diff --git a/src/git/formatters/formatter.ts b/src/git/formatters/formatter.ts index f48c4508cf474..19daabd665bee 100644 --- a/src/git/formatters/formatter.ts +++ b/src/git/formatters/formatter.ts @@ -30,7 +30,7 @@ export abstract class Formatter { - get directory() { + get directory(): string { const directory = escapeIfNeeded( getGitFileFormattedDirectory(this._item, false, this._options.relativePath), this._options.outputFormat, @@ -41,12 +41,12 @@ export class StatusFileFormatter extends Formatter return this._padOrTruncate(directory, this._options.tokenOptions.directory); } - get file() { + get file(): string { const file = escapeIfNeeded(basename(this._item.path), this._options.outputFormat); return this._padOrTruncate(file, this._options.tokenOptions.file); } - get filePath() { + get filePath(): string { const filePath = escapeIfNeeded( getGitFileFormattedPath(this._item, { relativeTo: this._options.relativePath, @@ -57,7 +57,7 @@ export class StatusFileFormatter extends Formatter return this._padOrTruncate(filePath, this._options.tokenOptions.filePath); } - get originalPath() { + get originalPath(): string { const originalPath = escapeIfNeeded( getGitFileOriginalRelativePath(this._item, this._options.relativePath), this._options.outputFormat, @@ -65,7 +65,7 @@ export class StatusFileFormatter extends Formatter return this._padOrTruncate(originalPath, this._options.tokenOptions.originalPath); } - get path() { + get path(): string { const directory = escapeIfNeeded( getGitFileRelativePath(this._item, this._options.relativePath), this._options.outputFormat, @@ -73,12 +73,12 @@ export class StatusFileFormatter extends Formatter return this._padOrTruncate(directory, this._options.tokenOptions.path); } - get status() { + get status(): string { const status = getGitFileStatusText(this._item.status); return this._padOrTruncate(status, this._options.tokenOptions.status); } - get working() { + get working(): string { let icon = ''; if (this._item.workingTreeStatus != null && this._item.indexStatus != null) { icon = `${GlyphChars.Pencil}${GlyphChars.Space}${GlyphChars.SpaceThinnest}${GlyphChars.Check}`; diff --git a/src/git/fsProvider.ts b/src/git/fsProvider.ts index 91c049ae32025..970b60082c4e0 100644 --- a/src/git/fsProvider.ts +++ b/src/git/fsProvider.ts @@ -32,7 +32,7 @@ export class GitFileSystemProvider implements FileSystemProvider, Disposable { ); } - dispose() { + dispose(): void { this._disposable.dispose(); } diff --git a/src/git/gitProviderService.ts b/src/git/gitProviderService.ts index 7fc210543b1bc..31063c35ba1f9 100644 --- a/src/git/gitProviderService.ts +++ b/src/git/gitProviderService.ts @@ -268,7 +268,7 @@ export class GitProviderService implements Disposable { this.updateContext(); } - dispose() { + dispose(): void { this._disposable.dispose(); this._providers.clear(); @@ -310,7 +310,7 @@ export class GitProviderService implements Disposable { } @debug() - onSubscriptionChanged(e: SubscriptionChangeEvent) { + private onSubscriptionChanged(e: SubscriptionChangeEvent) { this.clearAccessCache(); this._subscription = e.current; } @@ -560,7 +560,7 @@ export class GitProviderService implements Disposable { } @log({ singleLine: true }) - async registrationComplete() { + async registrationComplete(): Promise { const scope = getLogScope(); let { workspaceFolders } = workspace; @@ -1311,7 +1311,7 @@ export class GitProviderService implements Disposable { } @log() - getWorkingUri(repoPath: string | Uri, uri: Uri) { + getWorkingUri(repoPath: string | Uri, uri: Uri): Promise { const { provider, path } = this.getProvider(repoPath); return provider.getWorkingUri(path, uri); } @@ -1381,7 +1381,7 @@ export class GitProviderService implements Disposable { (repos, opts) => `${repos == null ? '' : repos.map(r => r.id).join(',')}|${JSON.stringify(opts)}`, ) @log({ args: { 0: repos => repos?.map(r => r.name).join(', ') } }) - async fetchAll(repositories?: Repository[], options?: { all?: boolean; prune?: boolean }) { + async fetchAll(repositories?: Repository[], options?: { all?: boolean; prune?: boolean }): Promise { if (repositories == null) { repositories = this.openRepositories; } @@ -1415,7 +1415,7 @@ export class GitProviderService implements Disposable { (repos, opts) => `${repos == null ? '' : repos.map(r => r.id).join(',')}|${JSON.stringify(opts)}`, ) @log({ args: { 0: repos => repos?.map(r => r.name).join(', ') } }) - async pullAll(repositories?: Repository[], options?: { rebase?: boolean }) { + async pullAll(repositories?: Repository[], options?: { rebase?: boolean }): Promise { if (repositories == null) { repositories = this.openRepositories; } @@ -1459,7 +1459,7 @@ export class GitProviderService implements Disposable { remote: string; }; }, - ) { + ): Promise { if (repositories == null) { repositories = this.openRepositories; } @@ -2208,7 +2208,7 @@ export class GitProviderService implements Disposable { ref: string, pathOrUri?: string | Uri, options?: { timeout?: number }, - ) { + ): Promise { if (pathOrUri != null && isUncommittedParent(ref)) { ref = 'HEAD'; } diff --git a/src/git/gitUri.ts b/src/git/gitUri.ts index 5bb65cc2b0614..6f8cc7e366b88 100644 --- a/src/git/gitUri.ts +++ b/src/git/gitUri.ts @@ -200,7 +200,7 @@ export class GitUri extends (Uri as any as UriEx) { } @memoize() - documentUri() { + documentUri(): Uri { // TODO@eamodio which is correct? return Uri.from({ scheme: this.scheme, @@ -212,7 +212,7 @@ export class GitUri extends (Uri as any as UriEx) { return Container.instance.git.getAbsoluteUri(this.fsPath, this.repoPath); } - equals(uri: Uri | undefined) { + equals(uri: Uri | undefined): boolean { if (!UriComparer.equals(this, uri)) return false; return this.sha === (isGitUri(uri) ? uri.sha : undefined); @@ -223,7 +223,7 @@ export class GitUri extends (Uri as any as UriEx) { } @memoize() - toFileUri() { + toFileUri(): Uri { return Container.instance.git.getAbsoluteUri(this.fsPath, this.repoPath); } @@ -242,7 +242,7 @@ export class GitUri extends (Uri as any as UriEx) { }); } - static fromRepoPath(repoPath: string, ref?: string) { + static fromRepoPath(repoPath: string, ref?: string): GitUri { return !ref ? new GitUri(Container.instance.git.getAbsoluteUri(repoPath, repoPath), repoPath) : new GitUri(Container.instance.git.getAbsoluteUri(repoPath, repoPath), { repoPath: repoPath, sha: ref }); diff --git a/src/git/models/branch.ts b/src/git/models/branch.ts index ecfb0fbcc6b74..448c70773c144 100644 --- a/src/git/models/branch.ts +++ b/src/git/models/branch.ts @@ -68,7 +68,7 @@ export class GitBranch implements GitBranchReference { : this.formatDateFromNow(); } - get ref() { + get ref(): string { return this.detached ? this.sha! : this.name; } @@ -169,16 +169,16 @@ export class GitBranch implements GitBranchReference { return getUpstreamStatus(this.upstream, this.state, options); } - get starred() { + get starred(): boolean { const starred = this.container.storage.getWorkspace('starred:branches'); return starred !== undefined && starred[this.id] === true; } - star() { + async star(): Promise { return this.container.git.getRepository(this.repoPath)?.star(this); } - unstar() { + async unstar(): Promise { return this.container.git.getRepository(this.repoPath)?.unstar(this); } } diff --git a/src/git/models/commit.ts b/src/git/models/commit.ts index 419349f5893cb..2c54225ea32e3 100644 --- a/src/git/models/commit.ts +++ b/src/git/models/commit.ts @@ -360,13 +360,13 @@ export class GitCommit implements GitRevisionReference { return this._files?.find(f => f.path === relativePath); } - formatDate(format?: string | null) { + formatDate(format?: string | null): string { return this.container.CommitDateFormatting.dateSource === 'committed' ? this.committer.formatDate(format) : this.author.formatDate(format); } - formatDateFromNow(short?: boolean) { + formatDateFromNow(short?: boolean): string { return this.container.CommitDateFormatting.dateSource === 'committed' ? this.committer.fromNow(short) : this.author.fromNow(short); diff --git a/src/git/models/fileChange.ts b/src/git/models/fileChange.ts index 7cfa3db18b9ee..1072bc100bc97 100644 --- a/src/git/models/fileChange.ts +++ b/src/git/models/fileChange.ts @@ -31,7 +31,7 @@ export class GitFileChange implements GitFileChangeShape { public readonly staged?: boolean, ) {} - get hasConflicts() { + get hasConflicts(): boolean { switch (this.status) { case GitFileConflictStatus.AddedByThem: case GitFileConflictStatus.AddedByUs: diff --git a/src/git/models/pullRequest.ts b/src/git/models/pullRequest.ts index 30a579de43aa4..fb860cc60becf 100644 --- a/src/git/models/pullRequest.ts +++ b/src/git/models/pullRequest.ts @@ -68,42 +68,42 @@ export class PullRequest implements PullRequestShape { } @memoize(format => format ?? 'MMMM Do, YYYY h:mma') - formatDate(format?: string | null) { + formatDate(format?: string | null): string { return formatDate(this.mergedDate ?? this.closedDate ?? this.updatedDate, format ?? 'MMMM Do, YYYY h:mma'); } - formatDateFromNow() { + formatDateFromNow(): string { return fromNow(this.mergedDate ?? this.closedDate ?? this.updatedDate); } @memoize(format => format ?? 'MMMM Do, YYYY h:mma') - formatClosedDate(format?: string | null) { + formatClosedDate(format?: string | null): string { if (this.closedDate == null) return ''; return formatDate(this.closedDate, format ?? 'MMMM Do, YYYY h:mma'); } - formatClosedDateFromNow() { + formatClosedDateFromNow(): string { if (this.closedDate == null) return ''; return fromNow(this.closedDate); } @memoize(format => format ?? 'MMMM Do, YYYY h:mma') - formatMergedDate(format?: string | null) { + formatMergedDate(format?: string | null): string { if (this.mergedDate == null) return ''; return formatDate(this.mergedDate, format ?? 'MMMM Do, YYYY h:mma') ?? ''; } - formatMergedDateFromNow() { + formatMergedDateFromNow(): string { if (this.mergedDate == null) return ''; return fromNow(this.mergedDate); } @memoize(format => format ?? 'MMMM Do, YYYY h:mma') - formatUpdatedDate(format?: string | null) { + formatUpdatedDate(format?: string | null): string { return formatDate(this.updatedDate, format ?? 'MMMM Do, YYYY h:mma') ?? ''; } - formatUpdatedDateFromNow() { + formatUpdatedDateFromNow(): string { return fromNow(this.updatedDate); } } diff --git a/src/git/models/reflog.ts b/src/git/models/reflog.ts index 7ab1d2d9391cd..722cad7834b66 100644 --- a/src/git/models/reflog.ts +++ b/src/git/models/reflog.ts @@ -30,11 +30,11 @@ export class GitReflogRecord { ) {} @memoize(format => format ?? 'MMMM Do, YYYY h:mma') - formatDate(format?: string | null) { + formatDate(format?: string | null): string { return formatDate(this.date, format ?? 'MMMM Do, YYYY h:mma'); } - formatDateFromNow() { + formatDateFromNow(): string { return fromNow(this.date); } @@ -45,7 +45,7 @@ export class GitReflogRecord { } @memoize() - get HEAD() { + get HEAD(): string { if (this._selector == null || this._selector.length === 0) return ''; if (this._selector.startsWith('refs/heads')) { @@ -59,25 +59,25 @@ export class GitReflogRecord { return this._selector; } - get previousSha() { + get previousSha(): string | undefined { return this._previousSha; } @memoize() - get previousShortSha() { + get previousShortSha(): string { return shortenRevision(this._previousSha); } - get selector() { + get selector(): string { return this._selector; } @memoize() - get shortSha() { + get shortSha(): string { return shortenRevision(this.sha); } - update(previousSha?: string, selector?: string) { + update(previousSha?: string, selector?: string): void { if (previousSha !== undefined) { this._previousSha = previousSha; } diff --git a/src/git/models/remote.ts b/src/git/models/remote.ts index 43b9ab4f679ec..8f9e31732c1ec 100644 --- a/src/git/models/remote.ts +++ b/src/git/models/remote.ts @@ -22,19 +22,19 @@ export class GitRemote { await this.container.git.remotes(this.repoPath).setRemoteAsDefault(this.name, value); } } diff --git a/src/git/models/repository.ts b/src/git/models/repository.ts index 05f0cd0df6bae..bb8ee46a84120 100644 --- a/src/git/models/repository.ts +++ b/src/git/models/repository.ts @@ -97,7 +97,7 @@ export class RepositoryChangeEvent { : `{ repository: ${this.repository?.name ?? ''}, changes: ${join(this._changes, ', ')} }`; } - changed(...args: [...RepositoryChange[], RepositoryChangeComparisonMode]) { + changed(...args: [...RepositoryChange[], RepositoryChangeComparisonMode]): boolean { const affected = args.slice(0, -1) as RepositoryChange[]; const mode = args[args.length - 1] as RepositoryChangeComparisonMode; @@ -132,7 +132,7 @@ export class RepositoryChangeEvent { : intersection.length === affected.length; } - with(changes: RepositoryChange[]) { + with(changes: RepositoryChange[]): RepositoryChangeEvent { return new RepositoryChangeEvent(this.repository, [...this._changes, ...changes]); } } @@ -175,7 +175,7 @@ export class Repository implements Disposable { } private _idHash: string | undefined; - get idHash() { + get idHash(): string { if (this._idHash === undefined) { this._idHash = md5(this.id); } @@ -333,7 +333,7 @@ export class Repository implements Disposable { return Disposable.from(...disposables); } - dispose() { + dispose(): void { this.unWatchFileSystem(true); this._disposable.dispose(); @@ -514,7 +514,10 @@ export class Repository implements Disposable { } @log() - branchDelete(branches: GitBranchReference | GitBranchReference[], options?: { force?: boolean; remote?: boolean }) { + branchDelete( + branches: GitBranchReference | GitBranchReference[], + options?: { force?: boolean; remote?: boolean }, + ): void { if (!Array.isArray(branches)) { branches = [branches]; } @@ -562,11 +565,11 @@ export class Repository implements Disposable { } @log() - cherryPick(...args: string[]) { + cherryPick(...args: string[]): void { void this.runTerminalCommand('cherry-pick', ...args); } - containsUri(uri: Uri) { + containsUri(uri: Uri): boolean { return this === this.container.git.getRepository(uri); } @@ -579,7 +582,7 @@ export class Repository implements Disposable { prune?: boolean; pull?: boolean; remote?: string; - }) { + }): Promise { const { progress, ...opts } = { progress: true, ...options }; if (!progress) return this.fetchCore(opts); @@ -655,13 +658,13 @@ export class Repository implements Disposable { } @log() - merge(...args: string[]) { + merge(...args: string[]): void { void this.runTerminalCommand('merge', ...args); } @gate() @log() - async pull(options?: { progress?: boolean; rebase?: boolean }) { + async pull(options?: { progress?: boolean; rebase?: boolean }): Promise { const { progress, ...opts } = { progress: true, ...options }; if (!progress) return this.pullCore(opts); @@ -728,7 +731,7 @@ export class Repository implements Disposable { progress?: boolean; reference?: GitReference; publish?: { remote: string }; - }) { + }): Promise { const { progress, ...opts } = { progress: true, ...options }; if (!progress) return this.pushCore(opts); @@ -763,14 +766,14 @@ export class Repository implements Disposable { } @log() - rebase(configs: string[] | undefined, ...args: string[]) { + rebase(configs: string[] | undefined, ...args: string[]): void { void this.runTerminalCommand( configs != null && configs.length !== 0 ? `${configs.join(' ')} rebase` : 'rebase', ...args, ); } - resume() { + resume(): void { if (!this._suspended) return; this._suspended = false; @@ -787,22 +790,22 @@ export class Repository implements Disposable { } @log() - revert(...args: string[]) { + revert(...args: string[]): void { void this.runTerminalCommand('revert', ...args); } - get starred() { + get starred(): boolean { const starred = this.container.storage.getWorkspace('starred:repositories'); return starred != null && starred[this.id] === true; } - star(branch?: GitBranch) { + star(branch?: GitBranch): Promise { return this.updateStarred(true, branch); } @gate() @log() - async switch(ref: string, options?: { createBranch?: string | undefined; progress?: boolean }) { + async switch(ref: string, options?: { createBranch?: string | undefined; progress?: boolean }): Promise { const { progress, ...opts } = { progress: true, ...options }; if (!progress) return this.switchCore(ref, opts); @@ -832,7 +835,7 @@ export class Repository implements Disposable { return !(options?.validate ?? true) || this.containsUri(uri) ? uri : undefined; } - unstar(branch?: GitBranch) { + unstar(branch?: GitBranch): Promise { return this.updateStarred(false, branch); } @@ -860,7 +863,7 @@ export class Repository implements Disposable { return this._etagFileSystem; } - suspend() { + suspend(): void { this._suspended = true; } diff --git a/src/git/models/status.ts b/src/git/models/status.ts index 3964a794c7539..a9003d07ae3fe 100644 --- a/src/git/models/status.ts +++ b/src/git/models/status.ts @@ -38,41 +38,41 @@ export class GitStatus { return 'upToDate'; } - get hasChanges() { + get hasChanges(): boolean { return this.files.length !== 0; } @memoize() - get hasConflicts() { + get hasConflicts(): boolean { return this.files.some(f => f.conflicted); } @memoize() - get conflicts() { + get conflicts(): GitStatusFile[] { return this.files.filter(f => f.conflicted); } @memoize() - get hasUntrackedChanges() { + get hasUntrackedChanges(): boolean { return this.files.some(f => f.workingTreeStatus === GitFileWorkingTreeStatus.Untracked); } @memoize() - get untrackedChanges() { + get untrackedChanges(): GitStatusFile[] { return this.files.filter(f => f.workingTreeStatus === GitFileWorkingTreeStatus.Untracked); } @memoize() - get hasWorkingTreeChanges() { + get hasWorkingTreeChanges(): boolean { return this.files.some(f => f.workingTreeStatus != null); } @memoize() - get workingTreeChanges() { + get workingTreeChanges(): GitStatusFile[] { return this.files.filter(f => f.workingTreeStatus != null); } - get ref() { + get ref(): string { return this.detached ? this.sha : this.branch; } @@ -175,7 +175,7 @@ export class GitStatus { } @memoize() - getDiffStatus() { + getDiffStatus(): { added: number; deleted: number; changed: number } { const diff = { added: 0, deleted: 0, diff --git a/src/git/models/statusFile.ts b/src/git/models/statusFile.ts index 55df9ab11d094..8c649694819fd 100644 --- a/src/git/models/statusFile.ts +++ b/src/git/models/statusFile.ts @@ -91,11 +91,11 @@ export class GitStatusFile implements GitFile { } } - get conflicted() { + get conflicted(): boolean { return this.conflictStatus != null; } - get staged() { + get staged(): boolean { return this.indexStatus != null; } @@ -109,7 +109,7 @@ export class GitStatusFile implements GitFile { return this.container.git.getAbsoluteUri(this.path, this.repoPath); } - get wip() { + get wip(): boolean { return this.workingTreeStatus != null; } diff --git a/src/git/models/tag.ts b/src/git/models/tag.ts index a84389d111b4d..a57ac59cc96ef 100644 --- a/src/git/models/tag.ts +++ b/src/git/models/tag.ts @@ -36,25 +36,25 @@ export class GitTag implements GitTagReference { : this.formatDateFromNow(); } - get ref() { + get ref(): string { return this.name; } @memoize(format => format ?? 'MMMM Do, YYYY h:mma') - formatCommitDate(format?: string | null) { + formatCommitDate(format?: string | null): string { return this.commitDate != null ? formatDate(this.commitDate, format ?? 'MMMM Do, YYYY h:mma') : ''; } - formatCommitDateFromNow() { + formatCommitDateFromNow(): string { return this.commitDate != null ? fromNow(this.commitDate) : ''; } @memoize(format => format ?? 'MMMM Do, YYYY h:mma') - formatDate(format?: string | null) { + formatDate(format?: string | null): string { return this.date != null ? formatDate(this.date, format ?? 'MMMM Do, YYYY h:mma') : ''; } - formatDateFromNow() { + formatDateFromNow(): string { return this.date != null ? fromNow(this.date) : ''; } diff --git a/src/git/remotes/azure-devops.ts b/src/git/remotes/azure-devops.ts index 0662d6bf2413e..b93f18578a8b2 100644 --- a/src/git/remotes/azure-devops.ts +++ b/src/git/remotes/azure-devops.ts @@ -92,7 +92,7 @@ export class AzureDevOpsRemote extends RemoteProvider { return this._autolinks; } - override get icon() { + override get icon(): string { return 'azdo'; } @@ -104,7 +104,7 @@ export class AzureDevOpsRemote extends RemoteProvider { return 'azureDevops' satisfies Unbrand as Brand; } - get name() { + get name(): string { return 'Azure DevOps'; } diff --git a/src/git/remotes/bitbucket-server.ts b/src/git/remotes/bitbucket-server.ts index 24389f47e4456..a6f5171649f1f 100644 --- a/src/git/remotes/bitbucket-server.ts +++ b/src/git/remotes/bitbucket-server.ts @@ -64,7 +64,7 @@ export class BitbucketServerRemote extends RemoteProvider { return super.splitPath(); } - override get icon() { + override get icon(): string { return 'bitbucket'; } @@ -76,7 +76,7 @@ export class BitbucketServerRemote extends RemoteProvider { return 'bitbucketServer' satisfies Unbrand as Brand; } - get name() { + get name(): string { return this.formatName('Bitbucket Server'); } diff --git a/src/git/remotes/bitbucket.ts b/src/git/remotes/bitbucket.ts index cc55ee0e25b30..f2a85d8e6e1c8 100644 --- a/src/git/remotes/bitbucket.ts +++ b/src/git/remotes/bitbucket.ts @@ -49,7 +49,7 @@ export class BitbucketRemote extends RemoteProvider { return this._autolinks; } - override get icon() { + override get icon(): string { return 'bitbucket'; } @@ -61,7 +61,7 @@ export class BitbucketRemote extends RemoteProvider { return 'bitbucket' satisfies Unbrand as Brand; } - get name() { + get name(): string { return this.formatName('Bitbucket'); } diff --git a/src/git/remotes/custom.ts b/src/git/remotes/custom.ts index 873a18d731e0a..7f770eb14fc81 100644 --- a/src/git/remotes/custom.ts +++ b/src/git/remotes/custom.ts @@ -23,7 +23,7 @@ export class CustomRemote extends RemoteProvider { return undefined; } - get name() { + get name(): string { return this.formatName('Custom'); } diff --git a/src/git/remotes/gerrit.ts b/src/git/remotes/gerrit.ts index 761d694fdc31c..b65559f16fc45 100644 --- a/src/git/remotes/gerrit.ts +++ b/src/git/remotes/gerrit.ts @@ -56,7 +56,7 @@ export class GerritRemote extends RemoteProvider { return this._autolinks; } - override get icon() { + override get icon(): string { return 'gerrit'; } @@ -68,7 +68,7 @@ export class GerritRemote extends RemoteProvider { return undefined; // TODO@eamodio DRAFTS add this when supported by backend } - get name() { + get name(): string { return this.formatName('Gerrit'); } diff --git a/src/git/remotes/gitea.ts b/src/git/remotes/gitea.ts index 2263185ff2b45..4f85fbf27391e 100644 --- a/src/git/remotes/gitea.ts +++ b/src/git/remotes/gitea.ts @@ -38,7 +38,7 @@ export class GiteaRemote extends RemoteProvider { return this._autolinks; } - override get icon() { + override get icon(): string { return 'gitea'; } @@ -50,7 +50,7 @@ export class GiteaRemote extends RemoteProvider { return undefined; // TODO@eamodio DRAFTS add this when supported by backend } - get name() { + get name(): string { return this.formatName('Gitea'); } diff --git a/src/git/remotes/github.ts b/src/git/remotes/github.ts index 3d4cf4f59600b..4a0a62cdfbd05 100644 --- a/src/git/remotes/github.ts +++ b/src/git/remotes/github.ts @@ -29,7 +29,7 @@ export class GitHubRemote extends RemoteProvider { super(domain, path, protocol, name, custom); } - get apiBaseUrl() { + get apiBaseUrl(): string { return this.custom ? `${this.protocol}://${this.domain}/api/v3` : `https://api.${this.domain}`; } @@ -165,12 +165,12 @@ export class GitHubRemote extends RemoteProvider { return this._autolinks; } - override get avatarUri() { + override get avatarUri(): Uri { const [owner] = this.splitPath(); return Uri.parse(`https://avatars.githubusercontent.com/${owner}`); } - override get icon() { + override get icon(): string { return 'github'; } @@ -184,7 +184,7 @@ export class GitHubRemote extends RemoteProvider { : 'github') satisfies Unbrand as Brand; } - get name() { + get name(): string { return this.formatName('GitHub'); } diff --git a/src/git/remotes/gitlab.ts b/src/git/remotes/gitlab.ts index 8dbc8a4cff0cb..09f8914cf04c4 100644 --- a/src/git/remotes/gitlab.ts +++ b/src/git/remotes/gitlab.ts @@ -29,7 +29,7 @@ export class GitLabRemote extends RemoteProvider { super(domain, path, protocol, name, custom); } - get apiBaseUrl() { + get apiBaseUrl(): string { return this.custom ? `${this.protocol}://${this.domain}/api` : `https://${this.domain}/api`; } @@ -266,7 +266,7 @@ export class GitLabRemote extends RemoteProvider { return this._autolinks; } - override get icon() { + override get icon(): string { return 'gitlab'; } @@ -280,7 +280,7 @@ export class GitLabRemote extends RemoteProvider { : 'gitlab') satisfies Unbrand as Brand; } - get name() { + get name(): string { return this.formatName('GitLab'); } diff --git a/src/git/remotes/google-source.ts b/src/git/remotes/google-source.ts index 75d6a95a44e59..2587db9970e60 100644 --- a/src/git/remotes/google-source.ts +++ b/src/git/remotes/google-source.ts @@ -16,7 +16,7 @@ export class GoogleSourceRemote extends GerritRemote { return undefined; // TODO@eamodio DRAFTS add this when supported by backend } - override get name() { + override get name(): string { return this.formatName('Google Source'); } diff --git a/src/git/remotes/remoteProvider.ts b/src/git/remotes/remoteProvider.ts index c696aa99cf284..e8687ba7155e8 100644 --- a/src/git/remotes/remoteProvider.ts +++ b/src/git/remotes/remoteProvider.ts @@ -70,7 +70,7 @@ export abstract class RemoteProvider `#:${typeof r === 'string' ? shortenRevision(r) : r.name}`).join(' '); } diff --git a/src/git/sub-providers/remotes.ts b/src/git/sub-providers/remotes.ts index f4750e706aa1f..54c09b83f62bf 100644 --- a/src/git/sub-providers/remotes.ts +++ b/src/git/sub-providers/remotes.ts @@ -184,7 +184,7 @@ export abstract class RemotesGitProviderBase implements GitRemotesSubProvider { } @log() - async setRemoteAsDefault(repoPath: string, name: string, value: boolean = true) { + async setRemoteAsDefault(repoPath: string, name: string, value: boolean = true): Promise { await this.container.storage.storeWorkspace('remote:default', value ? name : undefined); this.container.events.fire('git:repo:change', { repoPath: repoPath, diff --git a/src/git/utils/-webview/branch.issue.utils.ts b/src/git/utils/-webview/branch.issue.utils.ts index b579a6590e91b..f25fa3e8aafaf 100644 --- a/src/git/utils/-webview/branch.issue.utils.ts +++ b/src/git/utils/-webview/branch.issue.utils.ts @@ -23,7 +23,7 @@ export async function addAssociatedIssueToBranch( options?: { cancellation?: CancellationToken; }, -) { +): Promise { const { key, encoded } = await getConfigKeyAndEncodedAssociatedIssuesForBranch(container, branch); if (options?.cancellation?.isCancellationRequested) return; try { @@ -87,7 +87,7 @@ export async function removeAssociatedIssueFromBranch( options?: { cancellation?: CancellationToken; }, -) { +): Promise { const { key, encoded } = await getConfigKeyAndEncodedAssociatedIssuesForBranch(container, branch); if (options?.cancellation?.isCancellationRequested) return; try { diff --git a/src/git/utils/-webview/reference.utils.ts b/src/git/utils/-webview/reference.utils.ts index 95ceefca38cb0..89cd26aff1483 100644 --- a/src/git/utils/-webview/reference.utils.ts +++ b/src/git/utils/-webview/reference.utils.ts @@ -1,10 +1,10 @@ import type { GitBranch } from '../../models/branch'; import type { GitCommit, GitStashCommit } from '../../models/commit'; -import type { GitRevisionReference } from '../../models/reference'; +import type { GitBranchReference, GitRevisionReference, GitTagReference } from '../../models/reference'; import type { GitTag } from '../../models/tag'; -import { createReference } from "../reference.utils"; +import { createReference } from '../reference.utils'; -export function getReferenceFromBranch(branch: GitBranch) { +export function getReferenceFromBranch(branch: GitBranch): GitBranchReference { return createReference(branch.ref, branch.repoPath, { id: branch.id, refType: branch.refType, @@ -17,7 +17,7 @@ export function getReferenceFromBranch(branch: GitBranch) { export function getReferenceFromRevision( revision: GitCommit | GitStashCommit | GitRevisionReference, options?: { excludeMessage?: boolean }, -) { +): GitRevisionReference { if (revision.refType === 'stash') { return createReference(revision.ref, revision.repoPath, { refType: revision.refType, @@ -34,7 +34,7 @@ export function getReferenceFromRevision( }); } -export function getReferenceFromTag(tag: GitTag) { +export function getReferenceFromTag(tag: GitTag): GitTagReference { return createReference(tag.ref, tag.repoPath, { id: tag.id, refType: tag.refType, diff --git a/src/git/utils/-webview/sorting.ts b/src/git/utils/-webview/sorting.ts index ad4c5750c74f0..b860f298758e1 100644 --- a/src/git/utils/-webview/sorting.ts +++ b/src/git/utils/-webview/sorting.ts @@ -4,6 +4,7 @@ import { sortCompare } from '../../../system/string'; import type { GitBranch } from '../../models/branch'; import type { GitContributor } from '../../models/contributor'; import { isContributor } from '../../models/contributor'; +import type { GitRemote } from '../../models/remote'; import type { Repository } from '../../models/repository'; import type { GitTag } from '../../models/tag'; import type { GitWorktree } from '../../models/worktree'; @@ -19,7 +20,7 @@ export interface BranchSortOptions { openedWorktreesByBranch?: Set; } -export function sortBranches(branches: GitBranch[], options?: BranchSortOptions) { +export function sortBranches(branches: GitBranch[], options?: BranchSortOptions): GitBranch[] { options = { current: true, groupByType: true, orderBy: configuration.get('sortBranchesBy'), ...options }; switch (options.orderBy) { @@ -104,7 +105,7 @@ export function sortContributors( export function sortContributors( contributors: GitContributor[] | ContributorQuickPickItem[], options?: (ContributorSortOptions & { picked?: never }) | ContributorQuickPickSortOptions, -) { +): GitContributor[] | ContributorQuickPickItem[] { options = { picked: true, current: true, orderBy: configuration.get('sortContributorsBy'), ...options }; const getContributor = (contributor: GitContributor | ContributorQuickPickItem): GitContributor => { @@ -228,11 +229,21 @@ export function sortContributors( } } +export function sortRemotes(remotes: T[]): T[] { + return remotes.sort( + (a, b) => + (a.default ? -1 : 1) - (b.default ? -1 : 1) || + (a.name === 'origin' ? -1 : 1) - (b.name === 'origin' ? -1 : 1) || + (a.name === 'upstream' ? -1 : 1) - (b.name === 'upstream' ? -1 : 1) || + sortCompare(a.name, b.name), + ); +} + export interface RepositoriesSortOptions { orderBy?: RepositoriesSorting; } -export function sortRepositories(repositories: Repository[], options?: RepositoriesSortOptions) { +export function sortRepositories(repositories: Repository[], options?: RepositoriesSortOptions): Repository[] { options = { orderBy: configuration.get('sortRepositoriesBy'), ...options }; switch (options.orderBy) { @@ -267,7 +278,7 @@ export interface TagSortOptions { orderBy?: TagSorting; } -export function sortTags(tags: GitTag[], options?: TagSortOptions) { +export function sortTags(tags: GitTag[], options?: TagSortOptions): GitTag[] { options = { orderBy: configuration.get('sortTagsBy'), ...options }; switch (options.orderBy) { @@ -292,7 +303,10 @@ export function sortWorktrees( worktrees: WorktreeQuickPickItem[], options?: WorktreeSortOptions, ): WorktreeQuickPickItem[]; -export function sortWorktrees(worktrees: GitWorktree[] | WorktreeQuickPickItem[], options?: WorktreeSortOptions) { +export function sortWorktrees( + worktrees: GitWorktree[] | WorktreeQuickPickItem[], + options?: WorktreeSortOptions, +): GitWorktree[] | WorktreeQuickPickItem[] { options = { orderBy: configuration.get('sortBranchesBy'), ...options }; const getWorktree = (worktree: GitWorktree | WorktreeQuickPickItem): GitWorktree => { diff --git a/src/git/utils/-webview/worktree.quickpick.ts b/src/git/utils/-webview/worktree.quickpick.ts index 9e484516456bf..dfc4611fa6c67 100644 --- a/src/git/utils/-webview/worktree.quickpick.ts +++ b/src/git/utils/-webview/worktree.quickpick.ts @@ -6,7 +6,7 @@ import type { QuickPickItemOfT } from '../../../quickpicks/items/common'; import { pad } from '../../../system/string'; import type { GitStatus } from '../../models/status'; import type { GitWorktree } from '../../models/worktree'; -import { shortenRevision } from "../revision.utils"; +import { shortenRevision } from '../revision.utils'; import { getBranchIconPath } from './icons'; export interface WorktreeQuickPickItem extends QuickPickItemOfT { @@ -28,7 +28,7 @@ export function createWorktreeQuickPickItem( type?: boolean; status?: GitStatus; }, -) { +): WorktreeQuickPickItem { let description = ''; let detail = ''; if (options?.type) { diff --git a/src/git/utils/-webview/worktree.utils.ts b/src/git/utils/-webview/worktree.utils.ts index 4b8fedd01c522..7dfc62c10bc97 100644 --- a/src/git/utils/-webview/worktree.utils.ts +++ b/src/git/utils/-webview/worktree.utils.ts @@ -73,7 +73,7 @@ export async function getWorktreeForBranch( export async function getWorktreesByBranch( repos: Repository | Repository[] | undefined, options?: { includeDefault?: boolean }, -) { +): Promise> { const worktreesByBranch = new Map(); if (repos == null) return worktreesByBranch; @@ -99,7 +99,7 @@ export async function getWorktreesByBranch( export function groupWorktreesByBranch( worktrees: GitWorktree[], options?: { includeDefault?: boolean; worktreesByBranch?: Map }, -) { +): Map { const worktreesByBranch = options?.worktreesByBranch ?? new Map(); if (worktrees == null) return worktreesByBranch; diff --git a/src/git/utils/branch.utils.ts b/src/git/utils/branch.utils.ts index 306967dfeb0dc..45e3b8599a2a3 100644 --- a/src/git/utils/branch.utils.ts +++ b/src/git/utils/branch.utils.ts @@ -35,7 +35,7 @@ export function getBranchNameWithoutRemote(name: string): string { return name.substring(getRemoteNameSlashIndex(name) + 1); } -export function getBranchTrackingWithoutRemote(ref: GitBranchReference) { +export function getBranchTrackingWithoutRemote(ref: GitBranchReference): string | undefined { return ref.upstream?.name.substring(getRemoteNameSlashIndex(ref.upstream.name) + 1); } @@ -100,6 +100,6 @@ export function isDetachedHead(name: string): boolean { return name.length ? detachedHEADRegex.test(name) : true; } -export function isOfBranchRefType(branch: GitReference | undefined) { +export function isOfBranchRefType(branch: GitReference | undefined): branch is GitBranchReference { return branch?.refType === 'branch'; } diff --git a/src/git/utils/reference.utils.ts b/src/git/utils/reference.utils.ts index 7912bea56c32f..3fa50efd28a72 100644 --- a/src/git/utils/reference.utils.ts +++ b/src/git/utils/reference.utils.ts @@ -8,7 +8,7 @@ import type { GitTagReference, } from '../models/reference'; import { getBranchNameWithoutRemote, getRemoteNameFromBranchName } from './branch.utils'; -import { isRevisionRange, isShaParent, shortenRevision } from "./revision.utils"; +import { isRevisionRange, isShaParent, shortenRevision } from './revision.utils'; export function createReference( ref: string, @@ -96,7 +96,7 @@ export function createReference( export function getReferenceLabel( refs: GitReference | GitReference[] | undefined, options?: { capitalize?: boolean; expand?: boolean; icon?: boolean; label?: boolean; quoted?: boolean } | false, -) { +): string { if (refs == null) return ''; options = @@ -196,14 +196,14 @@ export function getReferenceLabel( } } -export function getReferenceNameWithoutRemote(ref: GitReference) { +export function getReferenceNameWithoutRemote(ref: GitReference): string { if (ref.refType === 'branch') { return ref.remote ? getBranchNameWithoutRemote(ref.name) : ref.name; } return ref.name; } -export function getReferenceTypeLabel(ref: GitReference | undefined) { +export function getReferenceTypeLabel(ref: GitReference | undefined): 'Branch' | 'Tag' | 'Commit' { switch (ref?.refType) { case 'branch': return 'Branch'; diff --git a/src/git/utils/remote.utils.ts b/src/git/utils/remote.utils.ts index fe4c6584ff904..1eabb844fd2c9 100644 --- a/src/git/utils/remote.utils.ts +++ b/src/git/utils/remote.utils.ts @@ -1,5 +1,4 @@ import { GlyphChars } from '../../constants'; -import { sortCompare } from '../../system/string'; import type { GitRemote } from '../models/remote'; import type { RemoteProvider } from '../remotes/remoteProvider'; @@ -7,7 +6,7 @@ export function getDefaultRemoteOrHighlander(remotes: T[]): return remotes.length === 1 ? remotes[0] : remotes.find(r => r.default); } -export function getHighlanderProviderName(remotes: GitRemote[]) { +export function getHighlanderProviderName(remotes: GitRemote[]): string | undefined { if (remotes.length === 0) return undefined; const remote = getDefaultRemoteOrHighlander(remotes); @@ -20,7 +19,7 @@ export function getHighlanderProviderName(remotes: GitRemote[]) return undefined; } -export function getHighlanderProviders(remotes: GitRemote[]) { +export function getHighlanderProviders(remotes: GitRemote[]): RemoteProvider[] | undefined { if (remotes.length === 0) return undefined; const remote = getDefaultRemoteOrHighlander(remotes); @@ -90,13 +89,3 @@ export function getVisibilityCacheKey(remotes: GitRemote | GitRemote[]): string .sort() .join(','); } - -export function sortRemotes(remotes: T[]) { - return remotes.sort( - (a, b) => - (a.default ? -1 : 1) - (b.default ? -1 : 1) || - (a.name === 'origin' ? -1 : 1) - (b.name === 'origin' ? -1 : 1) || - (a.name === 'upstream' ? -1 : 1) - (b.name === 'upstream' ? -1 : 1) || - sortCompare(a.name, b.name), - ); -} diff --git a/src/git/utils/remoteResource.utils.ts b/src/git/utils/remoteResource.utils.ts index 13a0c5c4f336c..fc86210d9add1 100644 --- a/src/git/utils/remoteResource.utils.ts +++ b/src/git/utils/remoteResource.utils.ts @@ -5,7 +5,7 @@ import { RemoteResourceType } from '../models/remoteResource'; // type: RemoteResourceType.Tag; // tag: string; // }; -export function getNameFromRemoteResource(resource: RemoteResource) { +export function getNameFromRemoteResource(resource: RemoteResource): string { switch (resource.type) { case RemoteResourceType.Branch: return 'Branch'; diff --git a/src/git/utils/revision.utils.ts b/src/git/utils/revision.utils.ts index bcaeab9aef7fd..a2bc2ab2ac399 100644 --- a/src/git/utils/revision.utils.ts +++ b/src/git/utils/revision.utils.ts @@ -16,23 +16,25 @@ function isMatch(regex: RegExp, ref: string | undefined) { return !ref ? false : regex.test(ref); } -export function isSha(ref: string) { +export function isSha(ref: string): boolean { return isMatch(shaRegex, ref); } -export function isShaLike(ref: string) { +export function isShaLike(ref: string): boolean { return isMatch(shaLikeRegex, ref); } -export function isShaParent(ref: string) { +export function isShaParent(ref: string): boolean { return isMatch(shaParentRegex, ref); } -export function isUncommitted(ref: string | undefined, exact: boolean = false) { +export function isUncommitted(ref: string | undefined, exact: boolean = false): boolean { return ref === uncommitted || ref === uncommittedStaged || (!exact && isMatch(uncommittedRegex, ref)); } -export function isUncommittedParent(ref: string | undefined) { +export function isUncommittedParent( + ref: string | undefined, +): ref is '0000000000000000000000000000000000000000^' | '0000000000000000000000000000000000000000:^' { return ref === `${uncommitted}^` || ref === `${uncommittedStaged}^`; } @@ -41,11 +43,11 @@ export function isUncommittedStaged(ref: string | undefined, exact: boolean = fa } let abbreviatedShaLength = 7; -export function getAbbreviatedShaLength() { +export function getAbbreviatedShaLength(): number { return abbreviatedShaLength; } -export function setAbbreviatedShaLength(length: number) { +export function setAbbreviatedShaLength(length: number): void { abbreviatedShaLength = length; } @@ -55,7 +57,7 @@ export function shortenRevision( force?: boolean; strings?: { uncommitted?: string; uncommittedStaged?: string; working?: string }; }, -) { +): string { if (ref === deletedOrMissing) return '(deleted)'; if (!ref) return options?.strings?.working ?? ''; diff --git a/src/git/utils/tag.utils.ts b/src/git/utils/tag.utils.ts index 4325b0a9fd0da..a92a0795814a4 100644 --- a/src/git/utils/tag.utils.ts +++ b/src/git/utils/tag.utils.ts @@ -1,9 +1,9 @@ -import type { GitReference } from '../models/reference'; +import type { GitReference, GitTagReference } from '../models/reference'; export function getTagId(repoPath: string, name: string): string { return `${repoPath}|tag/${name}`; } -export function isOfTagRefType(tag: GitReference | undefined) { +export function isOfTagRefType(tag: GitReference | undefined): tag is GitTagReference { return tag?.refType === 'tag'; } diff --git a/src/hovers/lineHoverController.ts b/src/hovers/lineHoverController.ts index f10224dc1f06a..23836dc92abb6 100644 --- a/src/hovers/lineHoverController.ts +++ b/src/hovers/lineHoverController.ts @@ -23,7 +23,7 @@ export class LineHoverController implements Disposable { ); } - dispose() { + dispose(): void { this.unregister(); this.container.lineTracker.unsubscribe(this); diff --git a/src/messages.ts b/src/messages.ts index 4100a0e90382d..9ea4a67517f53 100644 --- a/src/messages.ts +++ b/src/messages.ts @@ -104,7 +104,7 @@ export function showFileNotUnderSourceControlWarningMessage(message: string): Pr ); } -export function showGitDisabledErrorMessage() { +export function showGitDisabledErrorMessage(): Promise { return showMessage( 'error', 'GitLens requires Git to be enabled. Please re-enable Git \u2014 set `git.enabled` to true and reload.', @@ -112,14 +112,14 @@ export function showGitDisabledErrorMessage() { ); } -export function showGitInvalidConfigErrorMessage() { +export function showGitInvalidConfigErrorMessage(): Promise { return showMessage( 'error', 'GitLens is unable to use Git. Your Git configuration seems to be invalid. Please resolve any issues with your Git configuration and reload.', ); } -export function showGitMissingErrorMessage() { +export function showGitMissingErrorMessage(): Promise { return showMessage( 'error', "GitLens was unable to find Git. Please make sure Git is installed. Also ensure that Git is either in the PATH, or that 'git.path' is pointed to its installed location.", @@ -138,7 +138,7 @@ export function showGitVersionUnsupportedErrorMessage( ); } -export async function showPreReleaseExpiredErrorMessage(version: string) { +export async function showPreReleaseExpiredErrorMessage(version: string): Promise { const upgrade = { title: 'Upgrade' }; const switchToRelease = { title: 'Switch to Release Version' }; const result = await showMessage( @@ -230,7 +230,7 @@ export function showIntegrationRequestTimedOutWarningMessage(providerName: strin ); } -export async function showWhatsNewMessage(majorVersion: string) { +export async function showWhatsNewMessage(majorVersion: string): Promise { const confirm = { title: 'OK', isCloseAffordance: true }; const releaseNotes = { title: 'View Release Notes' }; const result = await showMessage( diff --git a/src/plus/gk/authenticationConnection.ts b/src/plus/gk/authenticationConnection.ts index f0d480974be85..57fb26f503a2d 100644 --- a/src/plus/gk/authenticationConnection.ts +++ b/src/plus/gk/authenticationConnection.ts @@ -31,7 +31,7 @@ export class AuthenticationConnection implements Disposable { private readonly connection: ServerConnection, ) {} - dispose() {} + dispose(): void {} abort(): Promise { if (this._cancellationSource == null) return Promise.resolve(); diff --git a/src/plus/gk/authenticationProvider.ts b/src/plus/gk/authenticationProvider.ts index 64dc6bd33b8c7..dd3ecca5eaf82 100644 --- a/src/plus/gk/authenticationProvider.ts +++ b/src/plus/gk/authenticationProvider.ts @@ -2,6 +2,7 @@ import type { AuthenticationProvider, AuthenticationProviderAuthenticationSessionsChangeEvent, AuthenticationSession, + Event, } from 'vscode'; import { Disposable, EventEmitter, window } from 'vscode'; import { uuid } from '@env/crypto'; @@ -36,7 +37,7 @@ export interface AuthenticationProviderOptions { export class AccountAuthenticationProvider implements AuthenticationProvider, Disposable { private _onDidChangeSessions = new EventEmitter(); - get onDidChangeSessions() { + get onDidChangeSessions(): Event { return this._onDidChangeSessions.event; } @@ -60,7 +61,7 @@ export class AccountAuthenticationProvider implements AuthenticationProvider, Di ); } - dispose() { + dispose(): void { this._disposable.dispose(); } @@ -72,12 +73,12 @@ export class AccountAuthenticationProvider implements AuthenticationProvider, Di return this._authConnection.abort(); } - public setOptionsForScopes(scopes: string[], options: AuthenticationProviderOptions) { + public setOptionsForScopes(scopes: string[], options: AuthenticationProviderOptions): void { this._optionsByScope ??= new Map(); this._optionsByScope.set(getScopesKey(scopes), options); } - public clearOptionsForScopes(scopes: string[]) { + public clearOptionsForScopes(scopes: string[]): void { this._optionsByScope?.delete(getScopesKey(scopes)); } @@ -142,7 +143,7 @@ export class AccountAuthenticationProvider implements AuthenticationProvider, Di } @debug() - public async removeSession(id: string) { + public async removeSession(id: string): Promise { const scope = getLogScope(); try { @@ -167,7 +168,7 @@ export class AccountAuthenticationProvider implements AuthenticationProvider, Di } @debug() - public async removeSessionsByScopes(scopes?: string[]) { + public async removeSessionsByScopes(scopes?: string[]): Promise { const scope = getLogScope(); try { diff --git a/src/plus/gk/serverConnection.ts b/src/plus/gk/serverConnection.ts index 60d1427c08edb..4ffa5260d28e1 100644 --- a/src/plus/gk/serverConnection.ts +++ b/src/plus/gk/serverConnection.ts @@ -43,7 +43,7 @@ interface GKFetchOptions extends FetchOptions { export class ServerConnection implements Disposable { constructor(private readonly container: Container) {} - dispose() {} + dispose(): void {} @memoize() private get baseGkApiUri(): Uri { @@ -58,7 +58,7 @@ export class ServerConnection implements Disposable { return Uri.parse('https://api.gitkraken.dev'); } - getGkApiUrl(...pathSegments: string[]) { + getGkApiUrl(...pathSegments: string[]): string { return Uri.joinPath(this.baseGkApiUri, ...pathSegments).toString(); } @@ -120,7 +120,12 @@ export class ServerConnection implements Disposable { return this.gkFetch(this.getGkApiUrl(path), init, options); } - async fetchGkApiGraphQL(path: string, request: GraphQLRequest, init?: RequestInit, options?: GKFetchOptions) { + async fetchGkApiGraphQL( + path: string, + request: GraphQLRequest, + init?: RequestInit, + options?: GKFetchOptions, + ): Promise { return this.fetchGkApi( path, { @@ -352,6 +357,6 @@ export interface GraphQLRequest { variables?: Record; } -export function getUrl(base: Uri, ...pathSegments: string[]) { +export function getUrl(base: Uri, ...pathSegments: string[]): string { return Uri.joinPath(base, ...pathSegments).toString(); } diff --git a/src/plus/gk/subscriptionService.ts b/src/plus/gk/subscriptionService.ts index 265b8ee3d6519..2b764135f6433 100644 --- a/src/plus/gk/subscriptionService.ts +++ b/src/plus/gk/subscriptionService.ts @@ -375,7 +375,7 @@ export class SubscriptionService implements Disposable { @gate() @log() - async continueFeaturePreview(feature: FeaturePreviews) { + async continueFeaturePreview(feature: FeaturePreviews): Promise { const preview = this.getStoredFeaturePreview(feature); const status = getFeaturePreviewStatus(preview); @@ -1653,7 +1653,7 @@ export class SubscriptionService implements Disposable { ); } - onLoginUri(uri: Uri) { + private onLoginUri(uri: Uri): void { const scope = getLogScope(); const queryParams = new URLSearchParams(uri.query); const code = queryParams.get('code'); diff --git a/src/plus/gk/utils/subscription.utils.ts b/src/plus/gk/utils/subscription.utils.ts index c2693ef06e906..807bc605799cd 100644 --- a/src/plus/gk/utils/subscription.utils.ts +++ b/src/plus/gk/utils/subscription.utils.ts @@ -5,7 +5,7 @@ import type { PaidSubscriptionPlans, Subscription, SubscriptionPlan } from '../m export const SubscriptionUpdatedUriPathPrefix = 'did-update-subscription'; -export function getSubscriptionStateName(state: SubscriptionState, planId?: SubscriptionPlanId) { +export function getSubscriptionStateName(state: SubscriptionState, planId?: SubscriptionPlanId): string { switch (state) { case SubscriptionState.Community: case SubscriptionState.ProPreviewExpired: @@ -123,11 +123,11 @@ export function getSubscriptionPlan( }; } -export function getSubscriptionPlanName(id: SubscriptionPlanId) { +export function getSubscriptionPlanName(id: SubscriptionPlanId): string { return `GitLens ${getSubscriptionPlanTier(id)}`; } -export function getSubscriptionPlanTier(id: SubscriptionPlanId) { +export function getSubscriptionPlanTier(id: SubscriptionPlanId): 'Community' | 'Pro' | 'Teams' | 'Enterprise' { switch (id) { case SubscriptionPlanId.CommunityWithAccount: return 'Community'; diff --git a/src/plus/graph/statusbar.ts b/src/plus/graph/statusbar.ts index 7c5ed60ce09cc..5f76161540afa 100644 --- a/src/plus/graph/statusbar.ts +++ b/src/plus/graph/statusbar.ts @@ -25,7 +25,7 @@ export class GraphStatusBarController implements Disposable { ); } - dispose() { + dispose(): void { this._disposable.dispose(); } diff --git a/src/plus/integrations/authentication/integrationAuthenticationProvider.ts b/src/plus/integrations/authentication/integrationAuthenticationProvider.ts index 6ec5c137c0654..7cd0ef13ae80b 100644 --- a/src/plus/integrations/authentication/integrationAuthenticationProvider.ts +++ b/src/plus/integrations/authentication/integrationAuthenticationProvider.ts @@ -60,7 +60,7 @@ abstract class IntegrationAuthenticationProviderBase void d.dispose()); } @@ -223,11 +223,11 @@ abstract class IntegrationAuthenticationProviderBase extends IntegrationAuthenticationProviderBase { - protected override async deleteAllSecrets(sessionId: string) { + protected override async deleteAllSecrets(sessionId: string): Promise { await this.deleteSecret(this.getLocalSecretKey(sessionId), sessionId); } - protected override async storeSession(sessionId: string, session: ProviderAuthenticationSession) { + protected override async storeSession(sessionId: string, session: ProviderAuthenticationSession): Promise { await this.writeSecret(this.getLocalSecretKey(sessionId), session); } @@ -244,7 +244,7 @@ export abstract class LocalIntegrationAuthenticationProvider< storedSession: ProviderAuthenticationSession | undefined, descriptor?: IntegrationAuthenticationSessionDescriptor, options?: { createIfNeeded?: boolean; forceNewSession?: boolean; source?: Sources }, - ) { + ): Promise { if (!options?.createIfNeeded && !options?.forceNewSession) return storedSession; return this.createSession(descriptor); @@ -258,14 +258,14 @@ export abstract class CloudIntegrationAuthenticationProvider< return `gitlens.integration.auth.cloud:${this.authProviderId}|${id}`; } - protected override async deleteAllSecrets(sessionId: string) { + protected override async deleteAllSecrets(sessionId: string): Promise { await Promise.allSettled([ this.deleteSecret(this.getLocalSecretKey(sessionId), sessionId), this.deleteSecret(this.getCloudSecretKey(sessionId), sessionId), ]); } - protected override async storeSession(sessionId: string, session: ProviderAuthenticationSession) { + protected override async storeSession(sessionId: string, session: ProviderAuthenticationSession): Promise { await this.writeSecret(this.getCloudSecretKey(sessionId), session); } diff --git a/src/plus/integrations/authentication/integrationAuthenticationService.ts b/src/plus/integrations/authentication/integrationAuthenticationService.ts index 0eb24268a0ae5..42844f0e09428 100644 --- a/src/plus/integrations/authentication/integrationAuthenticationService.ts +++ b/src/plus/integrations/authentication/integrationAuthenticationService.ts @@ -17,7 +17,7 @@ export class IntegrationAuthenticationService implements Disposable { constructor(private readonly container: Container) {} - dispose() { + dispose(): void { this.providers.forEach(p => void p.dispose()); this.providers.clear(); } @@ -56,7 +56,7 @@ export class IntegrationAuthenticationService implements Disposable { await this.container.storage.store('integrations:configured', configured); } - async addConfigured(descriptor: ConfiguredIntegrationDescriptor) { + async addConfigured(descriptor: ConfiguredIntegrationDescriptor): Promise { const descriptors = this.configured.get(descriptor.integrationId) ?? []; // Only add if one does not exist if (descriptors.some(d => d.domain === descriptor.domain && d.integrationId === descriptor.integrationId)) { @@ -67,7 +67,9 @@ export class IntegrationAuthenticationService implements Disposable { await this.storeConfigured(); } - async removeConfigured(descriptor: Pick) { + async removeConfigured( + descriptor: Pick, + ): Promise { const descriptors = this.configured.get(descriptor.integrationId); if (descriptors == null) return; const index = descriptors.findIndex( @@ -86,7 +88,7 @@ export class IntegrationAuthenticationService implements Disposable { } @log() - async reset() { + async reset(): Promise { // TODO: This really isn't ideal, since it will only work for "cloud" providers as we won't have any more specific descriptors await Promise.allSettled( supportedIntegrationIds.map(async providerId => (await this.ensureProvider(providerId)).deleteSession()), diff --git a/src/plus/integrations/integration.ts b/src/plus/integrations/integration.ts index 9111954976518..53080c011e92f 100644 --- a/src/plus/integrations/integration.ts +++ b/src/plus/integrations/integration.ts @@ -173,7 +173,9 @@ export abstract class IntegrationBase< } protected _session: ProviderAuthenticationSession | null | undefined; - getSession(source: Sources) { + getSession( + source: Sources, + ): ProviderAuthenticationSession | Promise | undefined { if (this._session === undefined) { return this.ensureSession({ createIfNeeded: false, source: source }); } @@ -262,7 +264,7 @@ export abstract class IntegrationBase< void (await this.ensureSession({ createIfNeeded: true, forceNewSession: true })); } - refresh() { + refresh(): void { void this.ensureSession({ createIfNeeded: false }); } diff --git a/src/plus/integrations/integrationService.ts b/src/plus/integrations/integrationService.ts index 3a1d6a850cc52..9656a8b8a7068 100644 --- a/src/plus/integrations/integrationService.ts +++ b/src/plus/integrations/integrationService.ts @@ -88,7 +88,7 @@ export class IntegrationService implements Disposable { ); } - dispose() { + dispose(): void { this._disposable?.dispose(); } @@ -167,7 +167,7 @@ export class IntegrationService implements Disposable { } } - async manageCloudIntegrations(source: Source | undefined) { + async manageCloudIntegrations(source: Source | undefined): Promise { const scope = getLogScope(); if (this.container.telemetry.enabled) { this.container.telemetry.sendEvent( diff --git a/src/plus/integrations/providers/github.ts b/src/plus/integrations/providers/github.ts index 80e175b424b51..518fc4a2bcb55 100644 --- a/src/plus/integrations/providers/github.ts +++ b/src/plus/integrations/providers/github.ts @@ -287,7 +287,7 @@ export class GitHubIntegration extends GitHubIntegrationBase { const authProvider = await this.authenticationService.get(this.authProvider.id); const session = await authProvider.getSession(this.authProviderDescriptor); if (session == null && this.maybeConnected) { diff --git a/src/plus/integrations/providers/github/githubGitProvider.ts b/src/plus/integrations/providers/github/githubGitProvider.ts index 733c5c9d612f3..e166aff6a0830 100644 --- a/src/plus/integrations/providers/github/githubGitProvider.ts +++ b/src/plus/integrations/providers/github/githubGitProvider.ts @@ -145,7 +145,7 @@ export class GitHubGitProvider implements GitProvider, Disposable { this._disposables.push(authentication.onDidChangeSessions(this.onAuthenticationSessionsChanged, this)); } - dispose() { + dispose(): void { this._disposables.forEach(d => void d.dispose()); } @@ -391,7 +391,7 @@ export class GitHubGitProvider implements GitProvider, Disposable { } @log() - async getWorkingUri(repoPath: string, uri: Uri) { + async getWorkingUri(repoPath: string, uri: Uri): Promise { return this.createVirtualUri(repoPath, undefined, uri.path); } @@ -1186,7 +1186,7 @@ export class GitHubGitProvider implements GitProvider, Disposable { options?: { filter?: { branches?: (b: GitBranch) => boolean; tags?: (t: GitTag) => boolean }; }, - ) { + ): Promise { const [{ values: branches }, { values: tags }] = await Promise.all([ this.branches.getBranches(repoPath, { filter: options?.filter?.branches, @@ -1226,7 +1226,7 @@ export class GitHubGitProvider implements GitProvider, Disposable { ref: string, pathOrUri?: string | Uri, _options?: { force?: boolean; timeout?: number }, - ) { + ): Promise { if ( !ref || ref === deletedOrMissing || diff --git a/src/plus/integrations/providers/github/utils/-webview/search.utils.ts b/src/plus/integrations/providers/github/utils/-webview/search.utils.ts index b799c66125197..32dec767bd5e3 100644 --- a/src/plus/integrations/providers/github/utils/-webview/search.utils.ts +++ b/src/plus/integrations/providers/github/utils/-webview/search.utils.ts @@ -10,7 +10,7 @@ export async function getQueryArgsFromSearchQuery( search: SearchQuery, operations: Map>, repoPath: string, -) { +): Promise { const query = []; for (const [op, values] of operations.entries()) { diff --git a/src/plus/launchpad/launchpadIndicator.ts b/src/plus/launchpad/launchpadIndicator.ts index 716571cf2ffe6..a2d62633a76e4 100644 --- a/src/plus/launchpad/launchpadIndicator.ts +++ b/src/plus/launchpad/launchpadIndicator.ts @@ -47,7 +47,7 @@ export class LaunchpadIndicator implements Disposable { ); } - dispose() { + dispose(): void { this.clearRefreshTimer(); this._statusBarLaunchpad?.dispose(); this._disposable.dispose(); diff --git a/src/plus/launchpad/launchpadProvider.ts b/src/plus/launchpad/launchpadProvider.ts index a67519507d03b..52f8a045e2ef3 100644 --- a/src/plus/launchpad/launchpadProvider.ts +++ b/src/plus/launchpad/launchpadProvider.ts @@ -3,7 +3,7 @@ import type { EnrichedItemsByUniqueId, PullRequestWithUniqueID, } from '@gitkraken/provider-apis'; -import type { CancellationToken, ConfigurationChangeEvent } from 'vscode'; +import type { CancellationToken, ConfigurationChangeEvent, Event } from 'vscode'; import { Disposable, env, EventEmitter, Uri, window } from 'vscode'; import { md5 } from '@env/crypto'; import { GlCommand } from '../../constants.commands'; @@ -137,12 +137,12 @@ export interface LaunchpadCategorizedTimings { export class LaunchpadProvider implements Disposable { private readonly _onDidChange = new EventEmitter(); - get onDidChange() { + get onDidChange(): Event { return this._onDidChange.event; } private readonly _onDidRefresh = new EventEmitter(); - get onDidRefresh() { + get onDidRefresh(): Event { return this._onDidRefresh.event; } @@ -156,7 +156,7 @@ export class LaunchpadProvider implements Disposable { ); } - dispose() { + dispose(): void { this._disposable.dispose(); } @@ -344,7 +344,7 @@ export class LaunchpadProvider implements Disposable { } @log() - refresh() { + refresh(): void { this._prs = undefined; this._enrichedItems = undefined; this._codeSuggestions = undefined; @@ -353,7 +353,7 @@ export class LaunchpadProvider implements Disposable { } @log({ args: { 0: i => `${i.id} (${i.provider.name} ${i.type})` } }) - async pin(item: LaunchpadItem) { + async pin(item: LaunchpadItem): Promise { item.viewer.pinned = true; this._onDidChange.fire(); @@ -363,7 +363,7 @@ export class LaunchpadProvider implements Disposable { } @log({ args: { 0: i => `${i.id} (${i.provider.name} ${i.type})` } }) - async unpin(item: LaunchpadItem) { + async unpin(item: LaunchpadItem): Promise { item.viewer.pinned = false; this._onDidChange.fire(); @@ -376,7 +376,7 @@ export class LaunchpadProvider implements Disposable { } @log({ args: { 0: i => `${i.id} (${i.provider.name} ${i.type})` } }) - async snooze(item: LaunchpadItem) { + async snooze(item: LaunchpadItem): Promise { item.viewer.snoozed = true; this._onDidChange.fire(); @@ -386,7 +386,7 @@ export class LaunchpadProvider implements Disposable { } @log({ args: { 0: i => `${i.id} (${i.provider.name} ${i.type})` } }) - async unsnooze(item: LaunchpadItem) { + async unsnooze(item: LaunchpadItem): Promise { item.viewer.snoozed = false; this._onDidChange.fire(); @@ -425,7 +425,7 @@ export class LaunchpadProvider implements Disposable { } @log({ args: { 0: i => `${i.id} (${i.provider.name} ${i.type})` } }) - openCodeSuggestion(item: LaunchpadItem, target: string) { + openCodeSuggestion(item: LaunchpadItem, target: string): void { const draft = item.codeSuggestions?.value?.find(d => d.id === target); if (draft == null) return; this._codeSuggestions?.delete(item.uuid); @@ -437,7 +437,7 @@ export class LaunchpadProvider implements Disposable { } @log() - openCodeSuggestionInBrowser(target: string) { + openCodeSuggestionInBrowser(target: string): void { void openUrl(this.container.drafts.generateWebUrl(target)); } @@ -474,7 +474,7 @@ export class LaunchpadProvider implements Disposable { } @log({ args: { 0: i => `${i.id} (${i.provider.name} ${i.type})` } }) - async openChanges(item: LaunchpadItem) { + async openChanges(item: LaunchpadItem): Promise { if (!item.openRepository?.localBranch?.current) return; await this.switchTo(item); @@ -493,7 +493,7 @@ export class LaunchpadProvider implements Disposable { } @log({ args: { 0: i => `${i.id} (${i.provider.name} ${i.type})` } }) - async openInGraph(item: LaunchpadItem) { + async openInGraph(item: LaunchpadItem): Promise { const deepLinkUrl = this.getItemBranchDeepLink(item); if (deepLinkUrl == null) return; @@ -989,7 +989,7 @@ export function getLaunchpadItemGroups(item: LaunchpadItem): LaunchpadGroup[] { return groups; } -export function groupAndSortLaunchpadItems(items?: LaunchpadItem[]) { +export function groupAndSortLaunchpadItems(items?: LaunchpadItem[]): Map { if (items == null || items.length === 0) return new Map(); const grouped = new Map(launchpadGroups.map(g => [g, []])); @@ -1011,7 +1011,7 @@ export function groupAndSortLaunchpadItems(items?: LaunchpadItem[]) { return grouped; } -export function countLaunchpadItemGroups(items?: LaunchpadItem[]) { +export function countLaunchpadItemGroups(items?: LaunchpadItem[]): Map { if (items == null || items.length === 0) return new Map(); const grouped = new Map(launchpadGroups.map(g => [g, 0])); @@ -1041,7 +1041,7 @@ export function countLaunchpadItemGroups(items?: LaunchpadItem[]) { return grouped; } -export function sortLaunchpadItems(items: LaunchpadItem[]) { +export function sortLaunchpadItems(items: LaunchpadItem[]): LaunchpadItem[] { return items.sort( (a, b) => (a.viewer.pinned ? -1 : 1) - (b.viewer.pinned ? -1 : 1) || @@ -1065,7 +1065,7 @@ export function getPullRequestBranchDeepLink( remoteUrl: string, action?: DeepLinkActionType, pr?: PullRequest, -) { +): Uri { const schemeOverride = configuration.get('deepLinks.schemeOverride'); const scheme = typeof schemeOverride === 'string' ? schemeOverride : env.uriScheme; @@ -1092,7 +1092,7 @@ export function getPullRequestBranchDeepLink( ); } -export function getLaunchpadItemIdHash(item: LaunchpadItem) { +export function getLaunchpadItemIdHash(item: LaunchpadItem): string { return md5(item.uuid); } diff --git a/src/plus/repos/repositoryIdentityService.ts b/src/plus/repos/repositoryIdentityService.ts index cdc7eeda2778d..58d71de1adcfa 100644 --- a/src/plus/repos/repositoryIdentityService.ts +++ b/src/plus/repos/repositoryIdentityService.ts @@ -165,7 +165,7 @@ export class RepositoryIdentityService implements Disposable { async storeRepositoryLocation( repo: Repository, identity?: RepositoryIdentityDescriptor, - ) { + ): Promise { if (repo.virtual || this.locator == null) return; const [identityResult, remotesResult] = await Promise.allSettled([ diff --git a/src/plus/startWork/startWork.ts b/src/plus/startWork/startWork.ts index 175d77d6d3016..f414fa76c1bfb 100644 --- a/src/plus/startWork/startWork.ts +++ b/src/plus/startWork/startWork.ts @@ -688,7 +688,7 @@ function repeatSpaces(count: number) { return ' '.repeat(count); } -export function getStartWorkItemIdHash(item: StartWorkItem) { +export function getStartWorkItemIdHash(item: StartWorkItem): string { return md5(item.item.issue.id); } diff --git a/src/plus/workspaces/models/cloudWorkspace.ts b/src/plus/workspaces/models/cloudWorkspace.ts index b2148cfcd1a1c..da32419f4050d 100644 --- a/src/plus/workspaces/models/cloudWorkspace.ts +++ b/src/plus/workspaces/models/cloudWorkspace.ts @@ -38,7 +38,7 @@ export class CloudWorkspace { this._disposable = this.container.git.onDidChangeRepositories(this.resetRepositoriesByName, this); } - dispose() { + dispose(): void { this._disposable.dispose(); } @@ -50,7 +50,7 @@ export class CloudWorkspace { return this._localPath; } - resetRepositoriesByName() { + resetRepositoriesByName(): void { this._repositoriesByName = undefined; } diff --git a/src/plus/workspaces/models/localWorkspace.ts b/src/plus/workspaces/models/localWorkspace.ts index b9e73629b7314..6835a7d48f0e8 100644 --- a/src/plus/workspaces/models/localWorkspace.ts +++ b/src/plus/workspaces/models/localWorkspace.ts @@ -21,7 +21,7 @@ export class LocalWorkspace { this._disposable = this.container.git.onDidChangeRepositories(this.resetRepositoriesByName, this); } - dispose() { + dispose(): void { this._disposable.dispose(); } @@ -33,7 +33,7 @@ export class LocalWorkspace { return this._localPath; } - resetRepositoriesByName() { + resetRepositoriesByName(): void { this._repositoriesByName = undefined; } diff --git a/src/plus/workspaces/workspacesService.ts b/src/plus/workspaces/workspacesService.ts index e71761fbaa5be..e8fcd91a2e7cb 100644 --- a/src/plus/workspaces/workspacesService.ts +++ b/src/plus/workspaces/workspacesService.ts @@ -357,7 +357,7 @@ export class WorkspacesService implements Disposable { } @log() - resetWorkspaces(options?: { cloud?: boolean; local?: boolean }) { + resetWorkspaces(options?: { cloud?: boolean; local?: boolean }): void { if (options?.cloud ?? true) { this._cloudWorkspaces = undefined; } @@ -751,7 +751,7 @@ export class WorkspacesService implements Disposable { } @log() - async deleteCloudWorkspace(workspaceId: string) { + async deleteCloudWorkspace(workspaceId: string): Promise { const confirmation = await window.showWarningMessage( `Are you sure you want to delete this workspace? This cannot be undone.`, { modal: true }, @@ -798,7 +798,7 @@ export class WorkspacesService implements Disposable { async addCloudWorkspaceRepos( workspaceId: string, options?: { repos?: Repository[]; suppressNotifications?: boolean }, - ) { + ): Promise { const workspace = this.getCloudWorkspace(workspaceId); if (workspace == null) return; @@ -966,7 +966,7 @@ export class WorkspacesService implements Disposable { } @log({ args: { 1: false } }) - async removeCloudWorkspaceRepo(workspaceId: string, descriptor: CloudWorkspaceRepositoryDescriptor) { + async removeCloudWorkspaceRepo(workspaceId: string, descriptor: CloudWorkspaceRepositoryDescriptor): Promise { const workspace = this.getCloudWorkspace(workspaceId); if (workspace == null) return; @@ -1338,7 +1338,7 @@ function getCurrentWorkspaceId(): string | undefined { return workspace.getConfiguration('gitkraken')?.get('workspaceId'); } -export function scheduleAddMissingCurrentWorkspaceRepos(container: Container) { +export function scheduleAddMissingCurrentWorkspaceRepos(container: Container): void { const currentWorkspaceId = getCurrentWorkspaceId(); if (currentWorkspaceId == null) return; diff --git a/src/quickpicks/items/directive.ts b/src/quickpicks/items/directive.ts index 74fd024935288..de30d8121babf 100644 --- a/src/quickpicks/items/directive.ts +++ b/src/quickpicks/items/directive.ts @@ -36,7 +36,7 @@ export function createDirectiveQuickPickItem( iconPath?: Uri | { light: Uri; dark: Uri } | ThemeIcon; onDidSelect?: () => void | Promise; }, -) { +): DirectiveQuickPickItem { let label = options?.label; let detail = options?.detail; let description = options?.description; diff --git a/src/quickpicks/items/gitWizard.ts b/src/quickpicks/items/gitWizard.ts index 8a9ecb5a76260..53f56aaf4e70d 100644 --- a/src/quickpicks/items/gitWizard.ts +++ b/src/quickpicks/items/gitWizard.ts @@ -1,6 +1,7 @@ import type { QuickInputButton, QuickPickItem } from 'vscode'; import { ThemeIcon } from 'vscode'; import type { GitWizardCommandArgs } from '../../commands/gitWizard'; +import type { StepGenerator } from '../../commands/quickCommand'; import { getSteps } from '../../commands/quickWizard.utils'; import { GlyphChars } from '../../constants'; import { GlCommand } from '../../constants.commands'; @@ -30,7 +31,7 @@ export class GitWizardQuickPickItem extends CommandQuickPickItem<[GitWizardComma super(labelOrItem, undefined, GlCommand.GitCommands, [args], { suppressKeyPress: true }); } - executeSteps(pickedVia: 'menu' | 'command') { + executeSteps(pickedVia: 'menu' | 'command'): StepGenerator { return getSteps(Container.instance, this.args![0], pickedVia); } } @@ -156,7 +157,7 @@ export async function createCommitQuickPickItem commit: T, picked?: boolean, options?: { alwaysShow?: boolean; buttons?: QuickInputButton[]; compact?: boolean; icon?: boolean | 'avatar' }, -) { +): Promise | CommitQuickPickItem> { if (isStash(commit)) { return createStashQuickPickItem(commit, picked, { ...options, @@ -213,7 +214,7 @@ export function createStashQuickPickItem( stash: GitStashCommit, picked?: boolean, options?: { alwaysShow?: boolean; buttons?: QuickInputButton[]; compact?: boolean; icon?: boolean }, -) { +): CommitQuickPickItem { const number = stash.number == null ? '' : `${stash.number}: `; if (options?.compact) { @@ -337,7 +338,7 @@ export function createRemoteQuickPickItem( type?: boolean; upstream?: boolean; }, -) { +): RemoteQuickPickItem { let description = ''; if (options?.type) { description = 'remote'; @@ -375,7 +376,7 @@ export async function createRepositoryQuickPickItem( fetched?: boolean; status?: boolean; }, -) { +): Promise { let repoStatus; if (options?.branch || options?.status) { repoStatus = await repository.git.status().getStatus(); @@ -443,7 +444,7 @@ export function createTagQuickPickItem( ref?: boolean; type?: boolean; }, -) { +): TagQuickPickItem { let description = ''; if (options?.type) { description = 'tag'; diff --git a/src/statusbar/statusBarController.ts b/src/statusbar/statusBarController.ts index 05568d065a1ab..ea1d31a1c9444 100644 --- a/src/statusbar/statusBarController.ts +++ b/src/statusbar/statusBarController.ts @@ -34,7 +34,7 @@ export class StatusBarController implements Disposable { ); } - dispose() { + dispose(): void { this.clearBlame(); this._statusBarBlame?.dispose(); @@ -199,7 +199,7 @@ export class StatusBarController implements Disposable { } } - clearBlame() { + clearBlame(): void { this._selectedSha = undefined; this._cancellation?.cancel(); this._statusBarBlame?.hide(); diff --git a/src/system/-webview/command.ts b/src/system/-webview/command.ts index 999152017ea8f..59f18f5e743fa 100644 --- a/src/system/-webview/command.ts +++ b/src/system/-webview/command.ts @@ -99,7 +99,10 @@ export function registerCommands(container: Container): Disposable[] { return registrableCommands.map(c => new c(container)); } -export function executeActionCommand(action: Action, args: Omit) { +export function executeActionCommand( + action: Action, + args: Omit, +): Thenable { return commands.executeCommand(`${actionCommandPrefix}${action}`, { ...args, type: action }); } @@ -177,6 +180,6 @@ export function executeCoreGitCommand( return commands.executeCommand(command, ...args); } -export function executeEditorCommand(command: GlCommands, uri: Uri | undefined, args: T) { +export function executeEditorCommand(command: GlCommands, uri: Uri | undefined, args: T): Thenable { return commands.executeCommand(command, uri, args); } diff --git a/src/system/-webview/configuration.ts b/src/system/-webview/configuration.ts index a7199a71df1a9..b0d01fb48557f 100644 --- a/src/system/-webview/configuration.ts +++ b/src/system/-webview/configuration.ts @@ -142,20 +142,26 @@ export class Configuration { : e.affectsConfiguration(section, scope!); } - inspect>(section: S, scope?: ConfigurationScope | null) { + inspect>( + section: S, + scope?: ConfigurationScope | null, + ): InspectWorkspaceConfiguration | undefined { return workspace .getConfiguration(extensionPrefix, scope) .inspect(section === undefined ? extensionPrefix : section); } - inspectAny(section: S, scope?: ConfigurationScope | null) { + inspectAny( + section: S, + scope?: ConfigurationScope | null, + ): InspectWorkspaceConfiguration | undefined { return workspace.getConfiguration(undefined, scope).inspect(section); } inspectCore>( section: S, scope?: ConfigurationScope | null, - ) { + ): InspectWorkspaceConfiguration | undefined { return workspace.getConfiguration(undefined, scope).inspect(section); } @@ -359,6 +365,22 @@ export class Configuration { export const configuration = new Configuration(); +interface InspectWorkspaceConfiguration { + key: string; + + defaultValue?: T; + globalValue?: T; + workspaceValue?: T; + workspaceFolderValue?: T; + + defaultLanguageValue?: T; + globalLanguageValue?: T; + workspaceLanguageValue?: T; + workspaceFolderLanguageValue?: T; + + languageIds?: string[]; +} + type SubPath = Key extends string ? T[Key] extends Record ? diff --git a/src/system/-webview/keyboard.ts b/src/system/-webview/keyboard.ts index 981881a30db76..a5ae7953a990a 100644 --- a/src/system/-webview/keyboard.ts +++ b/src/system/-webview/keyboard.ts @@ -34,7 +34,7 @@ export class KeyboardScope implements Disposable { args: false, prefix: context => `${context.prefix}[${mappings.length}]`, }) - async dispose() { + async dispose(): Promise { const index = mappings.indexOf(this._mapping); const scope = getLogScope(); @@ -49,7 +49,7 @@ export class KeyboardScope implements Disposable { } private _paused = true; - get paused() { + get paused(): boolean { return this._paused; } @@ -57,7 +57,7 @@ export class KeyboardScope implements Disposable { args: false, prefix: (context, key) => `${context.prefix}[${mappings.length}](${key})`, }) - async clearKeyCommand(key: Keys) { + async clearKeyCommand(key: Keys): Promise { const scope = getLogScope(); const mapping = mappings[mappings.length - 1]; @@ -75,7 +75,7 @@ export class KeyboardScope implements Disposable { args: false, prefix: context => `${context.prefix}(paused=${context.instance._paused})`, }) - async pause(keys?: Keys[]) { + async pause(keys?: Keys[]): Promise { if (this._paused) return; this._paused = true; @@ -91,14 +91,14 @@ export class KeyboardScope implements Disposable { args: false, prefix: context => `${context.prefix}(paused=${context.instance._paused})`, }) - async resume() { + async resume(): Promise { if (!this._paused) return; this._paused = false; await this.updateKeyCommandsContext(this._mapping); } - async start() { + async start(): Promise { await this.resume(); } @@ -106,7 +106,7 @@ export class KeyboardScope implements Disposable { args: false, prefix: (context, key) => `${context.prefix}[${mappings.length}](${key})`, }) - async setKeyCommand(key: Keys, command: KeyCommand | (() => Promise)) { + async setKeyCommand(key: Keys, command: KeyCommand | (() => Promise)): Promise { const scope = getLogScope(); const mapping = mappings[mappings.length - 1]; @@ -139,7 +139,7 @@ export class Keyboard implements Disposable { this._disposable = Disposable.from(...subscriptions); } - dispose() { + dispose(): void { this._disposable.dispose(); } diff --git a/src/system/-webview/vscode.ts b/src/system/-webview/vscode.ts index fea0832fb31fd..3dfc26e13f7e0 100644 --- a/src/system/-webview/vscode.ts +++ b/src/system/-webview/vscode.ts @@ -70,7 +70,7 @@ export function findOrOpenEditors(uris: Uri[], options?: TextDocumentShowOptions } } -export function getEditorCommand() { +export function getEditorCommand(): string { let editor; switch (env.appName) { case 'Visual Studio Code - Insiders': @@ -121,7 +121,7 @@ export function getOtherVisibleTextEditors(editor: TextEditor): TextEditor[] { ); } -export function getQuickPickIgnoreFocusOut() { +export function getQuickPickIgnoreFocusOut(): boolean { return !configuration.get('advanced.quickPick.closeOnFocusOut'); } @@ -343,11 +343,11 @@ export function openWorkspace( }); } -export async function revealInFileExplorer(uri: Uri) { +export async function revealInFileExplorer(uri: Uri): Promise { void (await executeCoreCommand('revealFileInOS', uri)); } -export function supportedInVSCodeVersion(feature: 'language-models') { +export function supportedInVSCodeVersion(feature: 'language-models'): boolean { switch (feature) { case 'language-models': return satisfies(codeVersion, '>= 1.90-insider'); diff --git a/src/system/color.ts b/src/system/color.ts index f7612d012bfdc..1609a2145e8b1 100644 --- a/src/system/color.ts +++ b/src/system/color.ts @@ -1,13 +1,13 @@ import { CharCode } from '../constants'; -export function opacity(color: string, percentage: number) { +export function opacity(color: string, percentage: number): string { const rgba = Color.from(color); if (rgba == null) return color; return rgba.transparent(percentage / 100).toString(); } -export function mix(color1: string, color2: string, percentage: number) { +export function mix(color1: string, color2: string, percentage: number): string { const rgba1 = Color.from(color1); const rgba2 = Color.from(color2); if (rgba1 == null || rgba2 == null) return color1; @@ -30,7 +30,7 @@ export function scale(value1: string, value2: string, steps: number): string[] { return colors; } -export function toRgba(color: string) { +export function toRgba(color: string): number[] | null { const result = parseColor(color); if (result == null) return null; @@ -515,7 +515,7 @@ export class Color { return new Color(new RGBA(r, g, b, a)); } - mix(color: Color, factor: number) { + mix(color: Color, factor: number): Color { return mixColors(this, color, factor); } diff --git a/src/system/commands.ts b/src/system/commands.ts index 992383e013f30..014ab815874b3 100644 --- a/src/system/commands.ts +++ b/src/system/commands.ts @@ -1,6 +1,6 @@ import type { Commands } from '../constants.commands'; -export function createCommandLink(command: Commands, args?: T) { +export function createCommandLink(command: Commands, args?: T): string { if (args == null) return `command:${command}`; return `command:${command}?${encodeURIComponent(typeof args === 'string' ? args : JSON.stringify(args))}`; diff --git a/src/system/date.ts b/src/system/date.ts index 70cc2f29b18e6..7a3282923627e 100644 --- a/src/system/date.ts +++ b/src/system/date.ts @@ -24,7 +24,7 @@ let defaultShortRelativeTimeFormat: InstanceType const numberFormatCache = new Map(); -export function setDefaultDateLocales(locales: string | string[] | null | undefined) { +export function setDefaultDateLocales(locales: string | string[] | null | undefined): void { if (typeof locales === 'string') { if (locales === 'system' || locales.trim().length === 0) { defaultLocales = undefined; @@ -135,7 +135,7 @@ export function formatDate( format: 'full' | 'long' | 'medium' | 'short' | string | null | undefined, locale?: string, cache: boolean = true, -) { +): string { format = format ?? undefined; const key = `${locale ?? ''}:${format}`; diff --git a/src/system/decorators/-webview/gate.ts b/src/system/decorators/-webview/gate.ts index e5bd165d96249..ad772cb957c08 100644 --- a/src/system/decorators/-webview/gate.ts +++ b/src/system/decorators/-webview/gate.ts @@ -3,7 +3,7 @@ import { isPromise } from '../../promise'; import { resolveProp } from './resolver'; export function gate any>(resolver?: (...args: Parameters) => string) { - return (_target: any, key: string, descriptor: PropertyDescriptor) => { + return (_target: any, key: string, descriptor: PropertyDescriptor): void => { // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type let fn: Function | undefined; if (typeof descriptor.value === 'function') { diff --git a/src/system/decorators/-webview/memoize.ts b/src/system/decorators/-webview/memoize.ts index 45f4ce44379f8..7e28c669a58f5 100644 --- a/src/system/decorators/-webview/memoize.ts +++ b/src/system/decorators/-webview/memoize.ts @@ -2,7 +2,7 @@ import { resolveProp } from './resolver'; export function memoize any>(resolver?: (...args: Parameters) => string) { - return (_target: any, key: string, descriptor: PropertyDescriptor & Record) => { + return (_target: any, key: string, descriptor: PropertyDescriptor & Record): void => { // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type let fn: Function | undefined; let fnKey: string | undefined; diff --git a/src/system/decorators/-webview/resolver.ts b/src/system/decorators/-webview/resolver.ts index 27131c6646034..85bf5e6ed5512 100644 --- a/src/system/decorators/-webview/resolver.ts +++ b/src/system/decorators/-webview/resolver.ts @@ -64,7 +64,7 @@ export function resolveProp any>( key: string, resolver: Resolver | undefined, ...args: Parameters -) { +): string { if (args.length === 0) return key; let resolved; diff --git a/src/system/decorators/log.ts b/src/system/decorators/log.ts index cfc0759295985..86be64a8394ca 100644 --- a/src/system/decorators/log.ts +++ b/src/system/decorators/log.ts @@ -41,18 +41,23 @@ export const LogInstanceNameFn = Symbol('logInstanceNameFn'); export function logName(fn: (c: T, name: string) => string) { // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type - return (target: Function) => { + return (target: Function): void => { (target as any)[LogInstanceNameFn] = fn; }; } -export function debug any>(options?: LogOptions) { +export function debug any>( + options?: LogOptions, +): (_target: any, key: string, descriptor: PropertyDescriptor & Record) => void { return log(options, true); } type PromiseType = T extends Promise ? U : T; -export function log any>(options?: LogOptions, debug = false) { +export function log any>( + options?: LogOptions, + debug = false, +): (_target: any, key: string, descriptor: PropertyDescriptor & Record) => void { let overrides: LogOptions['args'] | undefined; let ifFn: LogOptions['if'] | undefined; let enterFn: LogOptions['enter'] | undefined; diff --git a/src/system/function.ts b/src/system/function.ts index 408df067b3baf..b611634be5b93 100644 --- a/src/system/function.ts +++ b/src/system/function.ts @@ -7,10 +7,10 @@ export interface Deferrable any> { pending(): boolean; } -interface PropOfValue { - (): any; - value: string | undefined; -} +// interface PropOfValue { +// (): any; +// value: string | undefined; +// } export function debounce ReturnType>( fn: T, @@ -187,16 +187,16 @@ export function partial any, P extends any[]>( return (...rest) => fn(...partialArgs, ...rest); } -export function propOf>(o: T, key: K) { - const propOfCore = >(o: T, key: K) => { - const value: string = - (propOfCore as PropOfValue).value === undefined ? key : `${(propOfCore as PropOfValue).value}.${key}`; - (propOfCore as PropOfValue).value = value; - const fn = >(k: Y) => propOfCore(o[key], k); - return Object.assign(fn, { value: value }); - }; - return propOfCore(o, key); -} +// export function propOf>(o: T, key: K) { +// const propOfCore = >(o: T, key: K) => { +// const value: string = +// (propOfCore as PropOfValue).value === undefined ? key : `${(propOfCore as PropOfValue).value}.${key}`; +// (propOfCore as PropOfValue).value = value; +// const fn = >(k: Y) => propOfCore(o[key], k); +// return Object.assign(fn, { value: value }); +// }; +// return propOfCore(o, key); +// } export function disposableInterval(fn: (...args: any[]) => void, ms: number): Disposable { let timer: ReturnType | undefined; @@ -253,7 +253,7 @@ export function throttle ReturnType>(fn: T, del let waiting = false; let waitingArgs: Parameters | undefined; - return function (this: unknown, ...args: Parameters) { + return function (this: unknown, ...args: Parameters): void { if (waiting) { waitingArgs = args; diff --git a/src/system/loggable.ts b/src/system/loggable.ts index b8c65222f6db6..a8bff1b24248f 100644 --- a/src/system/loggable.ts +++ b/src/system/loggable.ts @@ -53,6 +53,9 @@ export class LoggableScope implements Disposable { } } -export function maybeStartLoggableScope(prefix: string, options?: { debug?: boolean; enter?: string }) { +export function maybeStartLoggableScope( + prefix: string, + options?: { debug?: boolean; enter?: string }, +): LoggableScope | undefined { return Logger.enabled('error') ? new LoggableScope(prefix, options) : undefined; } diff --git a/src/system/logger.scope.ts b/src/system/logger.scope.ts index b396acabccafc..c4a13e958332f 100644 --- a/src/system/logger.scope.ts +++ b/src/system/logger.scope.ts @@ -12,17 +12,17 @@ export interface LogScope { exitFailed?: string; } -export function clearLogScope(scopeId: number) { +export function clearLogScope(scopeId: number): void { scopes.delete(scopeId); } -export function getLoggableScopeBlock(scopeId: number, prevScopeId?: number) { +export function getLoggableScopeBlock(scopeId: number, prevScopeId?: number): string { return prevScopeId == null ? `[${scopeId.toString(16).padStart(13)}]` : `[${prevScopeId.toString(16).padStart(5)} \u2192 ${scopeId.toString(16).padStart(5)}]`; } -export function getLoggableScopeBlockOverride(prefix: string, suffix?: string) { +export function getLoggableScopeBlockOverride(prefix: string, suffix?: string): string { if (suffix == null) return `[${prefix.padEnd(13)}]`; return `[${prefix}${suffix.padStart(13 - prefix.length)}]`; @@ -59,7 +59,7 @@ export function startLogScope(prefix: string, scope: LogScope | boolean | undefi }; } -export function setLogScope(scopeId: number, scope: LogScope) { +export function setLogScope(scopeId: number, scope: LogScope): LogScope { scope = { prevScopeId: logScopeIdGenerator.current, ...scope }; scopes.set(scopeId, scope); return scope; diff --git a/src/system/logger.ts b/src/system/logger.ts index 177d70a20bf8c..50c64de74aba7 100644 --- a/src/system/logger.ts +++ b/src/system/logger.ts @@ -249,7 +249,7 @@ export class BufferedLogChannel implements LogChannel { return this.channel.name; } - appendLine(value: string) { + appendLine(value: string): void { this.buffer.push(value); if (this.buffer.length >= maxBufferedLines) { @@ -303,7 +303,7 @@ function toOrderedLevel(logLevel: LogLevel): OrderedLevel { } // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type -export function getLoggableName(instance: Function | object) { +export function getLoggableName(instance: Function | object): string { let ctor; if (typeof instance === 'function') { if (instance.prototype?.constructor == null) return instance.name; diff --git a/src/system/markdown.ts b/src/system/markdown.ts index 4626cdcd5039e..96498ce108325 100644 --- a/src/system/markdown.ts +++ b/src/system/markdown.ts @@ -26,10 +26,8 @@ export function escapeMarkdown(s: string, options: { quoted?: boolean; inlineBac return s.trim().replace(markdownQuotedRegex, '\t\\\n> '); } -/** - * escapes markdown code blocks - */ -export function escapeMarkdownCodeBlocks(s: string) { +/** escapes markdown code blocks */ +export function escapeMarkdownCodeBlocks(s: string): string { const tripleBackticks = '```'; const escapedTripleBackticks = '\\`\\`\\`'; diff --git a/src/system/searchTree.ts b/src/system/searchTree.ts index a85cf718b3a89..97a6a37e6bc6d 100644 --- a/src/system/searchTree.ts +++ b/src/system/searchTree.ts @@ -344,7 +344,7 @@ export class TernarySearchTree { return { next: next }; } - forEach(callback: (value: V, index: K) => any) { + forEach(callback: (value: V, index: K) => any): void { this._forEach(this._root, callback); } diff --git a/src/system/stopwatch.ts b/src/system/stopwatch.ts index a480604a44224..66d84e62c9f1e 100644 --- a/src/system/stopwatch.ts +++ b/src/system/stopwatch.ts @@ -22,7 +22,7 @@ export class Stopwatch implements Disposable { private readonly logProvider: LogProvider; private _time: [number, number]; - get startTime() { + get startTime(): [number, number] { return this._time; } diff --git a/src/system/string.ts b/src/system/string.ts index 18e274508823c..91e3c0c6af395 100644 --- a/src/system/string.ts +++ b/src/system/string.ts @@ -10,7 +10,7 @@ import { getNumericFormat } from './date'; export { fromBase64, base64 } from '@env/base64'; -export function capitalize(s: string) { +export function capitalize(s: string): string { return `${s[0].toLocaleUpperCase()}${s.slice(1)}`; } @@ -131,11 +131,11 @@ export function encodeHtmlWeak(s: string | undefined): string | undefined { }); } -export function escapeRegex(s: string) { +export function escapeRegex(s: string): string { return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&'); } -export function getDurationMilliseconds(start: [number, number]) { +export function getDurationMilliseconds(start: [number, number]): number { const [secs, nanosecs] = hrtime(start); return secs * 1000 + Math.floor(nanosecs / 1000000); } @@ -183,7 +183,7 @@ export function* getLines(data: string | string[], char: string = '\n'): Iterabl } } -export function getPossessiveForm(name: string) { +export function getPossessiveForm(name: string): string { return name.endsWith('s') ? `${name}'` : `${name}'s`; } @@ -224,7 +224,7 @@ export function getWidth(s: string): number { const superscripts = ['\u00B9', '\u00B2', '\u00B3', '\u2074', '\u2075', '\u2076', '\u2077', '\u2078', '\u2079']; -export function getSuperscript(num: number) { +export function getSuperscript(num: number): string { return superscripts[num - 1] ?? ''; } @@ -468,13 +468,13 @@ export function isUpperAsciiLetter(code: number): boolean { return code >= CharCode.A && code <= CharCode.Z; } -export function pad(s: string, before: number = 0, after: number = 0, padding: string = '\u00a0') { +export function pad(s: string, before: number = 0, after: number = 0, padding: string = '\u00a0'): string { if (before === 0 && after === 0) return s; return `${before === 0 ? '' : padding.repeat(before)}${s}${after === 0 ? '' : padding.repeat(after)}`; } -export function padOrTruncateEnd(s: string, maxLength: number, fillString?: string) { +export function padOrTruncateEnd(s: string, maxLength: number, fillString?: string): string { if (s.length === maxLength) return s; if (s.length > maxLength) return s.substring(0, maxLength); return s.padEnd(maxLength, fillString); @@ -497,7 +497,7 @@ export function pluralize( /** Controls the string for a zero value */ zero?: string; }, -) { +): string { if (options == null) { numericFormat ??= getNumericFormat(); return `${numericFormat(count)} ${s}${count === 1 ? '' : 's'}`; @@ -525,19 +525,19 @@ export function pluralize( // eslint-disable-next-line no-control-regex const illegalCharsForFSRegex = /[\\/:*?"<>|\x00-\x1f\x80-\x9f]/g; -export function sanitizeForFileSystem(s: string, replacement: string = '_') { +export function sanitizeForFileSystem(s: string, replacement: string = '_'): string { if (!s) return s; return s.replace(illegalCharsForFSRegex, replacement); } -export function splitLast(s: string, splitter: string) { +export function splitLast(s: string, splitter: string): string[] { const index = s.lastIndexOf(splitter); if (index === -1) return [s]; return [s.substring(index), s.substring(0, index - 1)]; } -export function splitSingle(s: string, splitter: string) { +export function splitSingle(s: string, splitter: string): string[] { const index = s.indexOf(splitter); if (index === -1) return [s]; @@ -546,7 +546,7 @@ export function splitSingle(s: string, splitter: string) { return rest != null ? [start, rest] : [start]; } -export function truncate(s: string, truncateTo: number, ellipsis: string = '\u2026', width?: number) { +export function truncate(s: string, truncateTo: number, ellipsis: string = '\u2026', width?: number): string { if (!s) return s; if (truncateTo <= 1) return ellipsis; @@ -568,7 +568,7 @@ export function truncate(s: string, truncateTo: number, ellipsis: string = '\u20 return `${s.substring(0, chars)}${ellipsis}`; } -export function truncateLeft(s: string, truncateTo: number, ellipsis: string = '\u2026', width?: number) { +export function truncateLeft(s: string, truncateTo: number, ellipsis: string = '\u2026', width?: number): string { if (!s) return s; if (truncateTo <= 1) return ellipsis; @@ -590,7 +590,7 @@ export function truncateLeft(s: string, truncateTo: number, ellipsis: string = ' return `${ellipsis}${s.substring(s.length - chars)}`; } -export function truncateMiddle(s: string, truncateTo: number, ellipsis: string = '\u2026') { +export function truncateMiddle(s: string, truncateTo: number, ellipsis: string = '\u2026'): string { if (!s) return s; if (truncateTo <= 1) return ellipsis; @@ -616,7 +616,7 @@ const base64ReverseMap = new Uint8Array([ 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, ]); -export function decompressFromBase64LZString(input: string | undefined) { +export function decompressFromBase64LZString(input: string | undefined): string { if (input == null || input === '') return ''; const result = _decompressLZString(input, 32) ?? ''; diff --git a/src/telemetry/walkthroughStateProvider.ts b/src/telemetry/walkthroughStateProvider.ts index f426ca53683f8..c350643c2011b 100644 --- a/src/telemetry/walkthroughStateProvider.ts +++ b/src/telemetry/walkthroughStateProvider.ts @@ -220,11 +220,11 @@ export class WalkthroughStateProvider implements Disposable { void setContext(`gitlens:walkthroughState:${key}`, true); } - get doneCount() { + get doneCount(): number { return this.completed.size; } - get progress() { + get progress(): number { return this.doneCount / this.walkthroughSize; } diff --git a/src/terminal/linkProvider.ts b/src/terminal/linkProvider.ts index af4e2c78b1a1d..7fcda68032933 100644 --- a/src/terminal/linkProvider.ts +++ b/src/terminal/linkProvider.ts @@ -36,7 +36,7 @@ export class GitTerminalLinkProvider implements Disposable, TerminalLinkProvider this.disposable = window.registerTerminalLinkProvider(this); } - dispose() { + dispose(): void { this.disposable.dispose(); } diff --git a/src/trackers/documentTracker.ts b/src/trackers/documentTracker.ts index a9527c0a77061..5185cbb9742f9 100644 --- a/src/trackers/documentTracker.ts +++ b/src/trackers/documentTracker.ts @@ -94,7 +94,7 @@ export class GitDocumentTracker implements Disposable { this._dirtyIdleTriggerDelay = configuration.get('advanced.blame.delayAfterEdit'); } - dispose() { + dispose(): void { this._disposable.dispose(); void this.clear(); @@ -339,7 +339,7 @@ export class GitDocumentTracker implements Disposable { } @debug() - async clear() { + async clear(): Promise { for (const d of this._documentMap.values()) { (await d).dispose(); } @@ -419,7 +419,7 @@ export class GitDocumentTracker implements Disposable { private readonly _openUrisTracked = new UriSet(); private _updateContextDebounced: Deferrable<() => void> | undefined; - updateContext(uri: Uri, blameable: boolean, tracked: boolean) { + updateContext(uri: Uri, blameable: boolean, tracked: boolean): void { let changed = false; function updateContextCore(this: GitDocumentTracker, uri: Uri, blameable: boolean, tracked: boolean) { diff --git a/src/trackers/lineTracker.ts b/src/trackers/lineTracker.ts index 096f1ff405f53..5e505a7a73ac8 100644 --- a/src/trackers/lineTracker.ts +++ b/src/trackers/lineTracker.ts @@ -50,7 +50,7 @@ export class LineTracker { private readonly documentTracker: GitDocumentTracker, ) {} - dispose() { + dispose(): void { for (const subscriber of this._subscriptions.keys()) { this.unsubscribe(subscriber); } @@ -140,7 +140,7 @@ export class LineTracker { } private _suspended = false; - get suspended() { + get suspended(): boolean { return this._suspended; } @@ -148,7 +148,7 @@ export class LineTracker { return this._state.get(line); } - resetState(line?: number) { + resetState(line?: number): void { if (line != null) { this._state.delete(line); return; @@ -157,7 +157,7 @@ export class LineTracker { this._state.clear(); } - setState(line: number, state: LineState | undefined) { + setState(line: number, state: LineState | undefined): void { this._state.set(line, state); } @@ -186,12 +186,12 @@ export class LineTracker { return false; } - refresh() { + refresh(): void { this.notifyLinesChanged('editor'); } @debug() - resume(options?: { force?: boolean; silent?: boolean }) { + resume(options?: { force?: boolean; silent?: boolean }): void { if (!options?.force && !this._suspended) return; this._suspended = false; @@ -203,7 +203,7 @@ export class LineTracker { } @debug() - suspend(options?: { force?: boolean; silent?: boolean }) { + suspend(options?: { force?: boolean; silent?: boolean }): void { if (!options?.force && this._suspended) return; this._suspended = true; @@ -215,7 +215,7 @@ export class LineTracker { } } - subscribed(subscriber: unknown) { + subscribed(subscriber: unknown): boolean { return this._subscriptions.has(subscriber); } @@ -260,7 +260,7 @@ export class LineTracker { } @debug({ args: false, singleLine: true }) - unsubscribe(subscriber: unknown) { + unsubscribe(subscriber: unknown): void { const subs = this._subscriptions.get(subscriber); if (subs == null) return; diff --git a/src/trackers/trackedDocument.ts b/src/trackers/trackedDocument.ts index 9fcb8b8488220..eccfc3bc5a454 100644 --- a/src/trackers/trackedDocument.ts +++ b/src/trackers/trackedDocument.ts @@ -63,7 +63,7 @@ export class GitDocumentState { return this.logCache.get(key); } - setBlame(key: string, value: CachedBlame | undefined) { + setBlame(key: string, value: CachedBlame | undefined): void { if (value == null) { this.blameCache.delete(key); return; @@ -71,7 +71,7 @@ export class GitDocumentState { this.blameCache.set(key, value); } - setDiff(key: string, value: CachedDiff | undefined) { + setDiff(key: string, value: CachedDiff | undefined): void { if (value == null) { this.diffCache.delete(key); return; @@ -79,7 +79,7 @@ export class GitDocumentState { this.diffCache.set(key, value); } - setLog(key: string, value: CachedLog | undefined) { + setLog(key: string, value: CachedLog | undefined): void { if (value == null) { this.logCache.delete(key); return; @@ -104,7 +104,7 @@ export class TrackedGitDocument implements Disposable { onDidBlameStateChange: (e: DocumentBlameStateChangeEvent) => void, visible: boolean, dirty: boolean, - ) { + ): Promise { const doc = new TrackedGitDocument(container, tracker, document, onDidBlameStateChange, dirty); await doc.initialize(visible); return doc; @@ -127,7 +127,7 @@ export class TrackedGitDocument implements Disposable { public dirty: boolean, ) {} - dispose() { + dispose(): void { this.state = undefined; this._disposed = true; @@ -166,7 +166,7 @@ export class TrackedGitDocument implements Disposable { } private _forceDirtyStateChangeOnNextDocumentChange: boolean = false; - get forceDirtyStateChangeOnNextDocumentChange() { + get forceDirtyStateChangeOnNextDocumentChange(): boolean { return this._forceDirtyStateChangeOnNextDocumentChange; } @@ -190,12 +190,12 @@ export class TrackedGitDocument implements Disposable { }; } - is(document: TextDocument) { + is(document: TextDocument): boolean { return document === this.document; } @debug() - refresh(reason: 'changed' | 'saved' | 'visible' | 'repositoryChanged') { + refresh(reason: 'changed' | 'saved' | 'visible' | 'repositoryChanged'): void { if (this._pendingUpdates == null && reason === 'visible') return; const scope = getLogScope(); @@ -230,7 +230,7 @@ export class TrackedGitDocument implements Disposable { } private _blameFailure: Error | undefined; - setBlameFailure(ex: Error) { + setBlameFailure(ex: Error): void { const wasBlameable = this.blameable; this._blameFailure = ex; @@ -244,11 +244,11 @@ export class TrackedGitDocument implements Disposable { } } - resetForceDirtyStateChangeOnNextDocumentChange() { + resetForceDirtyStateChangeOnNextDocumentChange(): void { this._forceDirtyStateChangeOnNextDocumentChange = false; } - setForceDirtyStateChangeOnNextDocumentChange() { + setForceDirtyStateChangeOnNextDocumentChange(): void { this._forceDirtyStateChangeOnNextDocumentChange = true; } @@ -290,6 +290,6 @@ export async function createTrackedGitDocument( onDidChangeBlameState: (e: DocumentBlameStateChangeEvent) => void, visible: boolean, dirty: boolean, -) { +): Promise { return TrackedGitDocument.create(container, tracker, document, onDidChangeBlameState, visible, dirty); } diff --git a/src/uris/deepLinks/deepLinkService.ts b/src/uris/deepLinks/deepLinkService.ts index 132a59ec4a9ec..b2e934408862e 100644 --- a/src/uris/deepLinks/deepLinkService.ts +++ b/src/uris/deepLinks/deepLinkService.ts @@ -74,7 +74,7 @@ export class DeepLinkService implements Disposable { void this.processPendingDeepLink(pendingDeepLink); } - dispose() { + dispose(): void { Disposable.from(...this._disposables).dispose(); } @@ -124,7 +124,7 @@ export class DeepLinkService implements Disposable { } } - async processDeepLinkUri(uri: Uri, useProgress: boolean = true, repo?: Repository) { + async processDeepLinkUri(uri: Uri, useProgress: boolean = true, repo?: Repository): Promise { const link = parseDeepLinkUri(uri); if (link == null) return; diff --git a/src/uris/uriService.ts b/src/uris/uriService.ts index dc775255a1398..4020028af99cd 100644 --- a/src/uris/uriService.ts +++ b/src/uris/uriService.ts @@ -42,12 +42,12 @@ export class UriService implements Disposable, UriHandler { this._disposable = window.registerUriHandler(this); } - dispose() { + dispose(): void { this._disposable.dispose(); } @log({ args: { 0: u => u.with({ query: '' }).toString(true) } }) - handleUri(uri: Uri) { + handleUri(uri: Uri): void { const [, type] = uri.path.split('/'); if (type === AuthenticationUriPathPrefix) { this._onDidReceiveAuthenticationUri.fire(uri); diff --git a/src/views/branchesView.ts b/src/views/branchesView.ts index 4b97a0bd04068..8d7af9a38bdd6 100644 --- a/src/views/branchesView.ts +++ b/src/views/branchesView.ts @@ -33,7 +33,7 @@ export class BranchesRepositoryNode extends RepositoryFolderNode { if (branch.remote) return undefined; const { repoPath } = branch; @@ -247,7 +247,10 @@ export class BranchesView extends ViewBase<'branches', BranchesViewNode, Branche }); } - async findCommit(commit: GitCommit | { repoPath: string; ref: string }, token?: CancellationToken) { + async findCommit( + commit: GitCommit | { repoPath: string; ref: string }, + token?: CancellationToken, + ): Promise { const { repoPath } = commit; // Get all the branches the commit is on @@ -282,14 +285,14 @@ export class BranchesView extends ViewBase<'branches', BranchesViewNode, Branche } @gate(() => '') - revealBranch( + async revealBranch( branch: GitBranchReference, options?: { select?: boolean; focus?: boolean; expand?: boolean | number; }, - ) { + ): Promise { return window.withProgress( { location: ProgressLocation.Notification, @@ -318,7 +321,7 @@ export class BranchesView extends ViewBase<'branches', BranchesViewNode, Branche focus?: boolean; expand?: boolean | number; }, - ) { + ): Promise { return window.withProgress( { location: ProgressLocation.Notification, @@ -343,7 +346,7 @@ export class BranchesView extends ViewBase<'branches', BranchesViewNode, Branche async revealRepository( repoPath: string, options?: { select?: boolean; focus?: boolean; expand?: boolean | number }, - ) { + ): Promise { const node = await this.findNode(n => n instanceof RepositoryFolderNode && n.repoPath === repoPath, { maxDepth: 1, canTraverse: n => n instanceof BranchesViewNode || n instanceof RepositoryFolderNode, diff --git a/src/views/commitsView.ts b/src/views/commitsView.ts index 73ab0ac0c23bd..80f94df8eda5a 100644 --- a/src/views/commitsView.ts +++ b/src/views/commitsView.ts @@ -70,7 +70,7 @@ export class CommitsRepositoryNode extends RepositoryFolderNode { if (reset) { this.child = undefined; } else { @@ -81,7 +81,7 @@ export class CommitsRepositoryNode extends RepositoryFolderNode { const lastFetched = (await this.repo?.getLastFetched()) ?? 0; const interval = getLastFetchedUpdateInterval(lastFetched); @@ -106,7 +106,7 @@ export class CommitsRepositoryNode extends RepositoryFolderNode { const { repoPath } = commit; const branchesProvider = this.container.git.branches(commit.repoPath); @@ -401,7 +404,7 @@ export class CommitsView extends ViewBase<'commits', CommitsViewNode, CommitsVie focus?: boolean; expand?: boolean | number; }, - ) { + ): Promise { return window.withProgress( { location: ProgressLocation.Notification, @@ -426,7 +429,7 @@ export class CommitsView extends ViewBase<'commits', CommitsViewNode, CommitsVie async revealRepository( repoPath: string, options?: { select?: boolean; focus?: boolean; expand?: boolean | number }, - ) { + ): Promise { const node = await this.findNode(n => n instanceof RepositoryFolderNode && n.repoPath === repoPath, { maxDepth: 1, canTraverse: n => n instanceof CommitsViewNode || n instanceof RepositoryFolderNode, diff --git a/src/views/contributorsView.ts b/src/views/contributorsView.ts index 97dfc50b30e6a..9737cfe99be08 100644 --- a/src/views/contributorsView.ts +++ b/src/views/contributorsView.ts @@ -34,14 +34,14 @@ export class ContributorsRepositoryNode extends RepositoryFolderNode { return Disposable.from( await super.subscribe(), onDidFetchAvatar(e => this.child?.updateAvatar(e.email)), ); } - protected changed(e: RepositoryChangeEvent) { + protected changed(e: RepositoryChangeEvent): boolean { return e.changed( RepositoryChange.Config, RepositoryChange.Heads, @@ -149,7 +149,7 @@ export class ContributorsView extends ViewBase<'contributors', ContributorsViewN return this._state; } - protected getRoot() { + protected getRoot(): ContributorsViewNode { return new ContributorsViewNode(this); } @@ -222,7 +222,7 @@ export class ContributorsView extends ViewBase<'contributors', ContributorsViewN ]; } - protected override filterConfigurationChanged(e: ConfigurationChangeEvent) { + protected override filterConfigurationChanged(e: ConfigurationChangeEvent): boolean { const changed = super.filterConfigurationChanged(e); if ( !changed && @@ -243,7 +243,7 @@ export class ContributorsView extends ViewBase<'contributors', ContributorsViewN return true; } - findContributor(contributor: GitContributor, token?: CancellationToken) { + findContributor(contributor: GitContributor, token?: CancellationToken): Promise { const { repoPath, username, email, name } = contributor; return this.findNode( @@ -272,7 +272,7 @@ export class ContributorsView extends ViewBase<'contributors', ContributorsViewN async revealRepository( repoPath: string, options?: { select?: boolean; focus?: boolean; expand?: boolean | number }, - ) { + ): Promise { const node = await this.findNode(n => n instanceof RepositoryFolderNode && n.repoPath === repoPath, { maxDepth: 1, canTraverse: n => n instanceof ContributorsViewNode || n instanceof RepositoryFolderNode, @@ -293,7 +293,7 @@ export class ContributorsView extends ViewBase<'contributors', ContributorsViewN focus?: boolean; expand?: boolean | number; }, - ) { + ): Promise { return window.withProgress( { location: ProgressLocation.Notification, diff --git a/src/views/draftsView.ts b/src/views/draftsView.ts index 264d5cd7ff000..5274c064c1469 100644 --- a/src/views/draftsView.ts +++ b/src/views/draftsView.ts @@ -14,6 +14,7 @@ import { configuration } from '../system/-webview/configuration'; import { gate } from '../system/decorators/-webview/gate'; import { groupByFilterMap } from '../system/iterable'; import { CacheableChildrenViewNode } from './nodes/abstract/cacheableChildrenViewNode'; +import type { ViewNode } from './nodes/abstract/viewNode'; import { DraftNode } from './nodes/draftNode'; import { GroupingNode } from './nodes/groupingNode'; import { ViewBase } from './viewBase'; @@ -87,12 +88,12 @@ export class DraftsView extends ViewBase<'drafts', DraftsViewNode, DraftsViewCon this.description = previewBadge; } - override dispose() { + override dispose(): void { this._disposable?.dispose(); super.dispose(); } - protected getRoot() { + protected getRoot(): DraftsViewNode { return new DraftsViewNode(this); } @@ -164,7 +165,7 @@ export class DraftsView extends ViewBase<'drafts', DraftsViewNode, DraftsViewCon ]; } - async findDraft(draft: Draft, cancellation?: CancellationToken) { + async findDraft(draft: Draft, cancellation?: CancellationToken): Promise { return this.findNode((n: any) => n.draft?.id === draft.id, { allowPaging: false, maxDepth: 2, @@ -185,7 +186,7 @@ export class DraftsView extends ViewBase<'drafts', DraftsViewNode, DraftsViewCon focus?: boolean; expand?: boolean | number; }, - ) { + ): Promise { const node = await this.findDraft(draft); if (node == null) return undefined; diff --git a/src/views/fileHistoryView.ts b/src/views/fileHistoryView.ts index b41cc954c2c7e..18c48da6087ea 100644 --- a/src/views/fileHistoryView.ts +++ b/src/views/fileHistoryView.ts @@ -106,7 +106,7 @@ export class FileHistoryView extends ViewBase< ]; } - protected override filterConfigurationChanged(e: ConfigurationChangeEvent) { + protected override filterConfigurationChanged(e: ConfigurationChangeEvent): boolean { const changed = super.filterConfigurationChanged(e); if ( !changed && @@ -127,7 +127,7 @@ export class FileHistoryView extends ViewBase< return true; } - async showHistoryForUri(uri: GitUri) { + async showHistoryForUri(uri: GitUri): Promise { this.setCursorFollowing(false); const root = this.ensureRoot(true); diff --git a/src/views/launchpadView.ts b/src/views/launchpadView.ts index d344e28f814e5..e9bcc2bd94322 100644 --- a/src/views/launchpadView.ts +++ b/src/views/launchpadView.ts @@ -8,6 +8,7 @@ import type { Container } from '../container'; import { AuthenticationRequiredError } from '../errors'; import { PlusFeatures } from '../features'; import { GitUri, unknownGitUri } from '../git/gitUri'; +import type { PullRequest } from '../git/models/pullRequest'; import type { SubscriptionChangeEvent } from '../plus/gk/subscriptionService'; import { ensurePlusFeaturesEnabled } from '../plus/gk/utils/-webview/plus.utils'; import type { LaunchpadCommandArgs } from '../plus/launchpad/launchpad'; @@ -62,7 +63,7 @@ export class LaunchpadItemNode extends CacheableChildrenViewNode<'launchpad-item return this.item.url ?? this.item.underlyingPullRequest.url; } - get pullRequest() { + get pullRequest(): PullRequest | undefined { return this.item.type === 'pullrequest' ? this.item.underlyingPullRequest : undefined; } @@ -132,7 +133,7 @@ export class LaunchpadViewNode extends CacheableChildrenViewNode< ); } - override dispose() { + override dispose(): void { this.disposable?.dispose(); super.dispose(); } @@ -143,7 +144,7 @@ export class LaunchpadViewNode extends CacheableChildrenViewNode< } } - override refresh() { + override refresh(): void { if (this.children == null) return; disposeChildren(this.children); @@ -226,7 +227,7 @@ export class LaunchpadView extends ViewBase<'launchpad', LaunchpadViewNode, Laun super(container, 'launchpad', 'Launchpad', 'launchpadView', grouped); } - override dispose() { + override dispose(): void { this._disposable?.dispose(); super.dispose(); } @@ -236,7 +237,7 @@ export class LaunchpadView extends ViewBase<'launchpad', LaunchpadViewNode, Laun return description ? `${description} \u00a0\u2022\u00a0 ${proBadge}` : proBadge; } - protected getRoot() { + protected getRoot(): LaunchpadViewNode { return new LaunchpadViewNode(this); } @@ -306,7 +307,7 @@ export class LaunchpadView extends ViewBase<'launchpad', LaunchpadViewNode, Laun ]; } - protected override filterConfigurationChanged(e: ConfigurationChangeEvent) { + protected override filterConfigurationChanged(e: ConfigurationChangeEvent): boolean { const changed = super.filterConfigurationChanged(e); if ( !changed && diff --git a/src/views/lineHistoryView.ts b/src/views/lineHistoryView.ts index dfb8fad527657..5d28aad65fc35 100644 --- a/src/views/lineHistoryView.ts +++ b/src/views/lineHistoryView.ts @@ -28,7 +28,7 @@ export class LineHistoryView extends ViewBase<'lineHistory', LineHistoryTrackerN return false; } - protected getRoot() { + protected getRoot(): LineHistoryTrackerNode { return new LineHistoryTrackerNode(this); } @@ -56,7 +56,7 @@ export class LineHistoryView extends ViewBase<'lineHistory', LineHistoryTrackerN ]; } - protected override filterConfigurationChanged(e: ConfigurationChangeEvent) { + protected override filterConfigurationChanged(e: ConfigurationChangeEvent): boolean { const changed = super.filterConfigurationChanged(e); if ( !changed && diff --git a/src/views/nodes/UncommittedFileNode.ts b/src/views/nodes/UncommittedFileNode.ts index c0f81d38ac6a8..7bcb886048ac6 100644 --- a/src/views/nodes/UncommittedFileNode.ts +++ b/src/views/nodes/UncommittedFileNode.ts @@ -54,7 +54,7 @@ export class UncommittedFileNode extends ViewFileNode<'uncommitted-file', ViewsW } private _description: string | undefined; - get description() { + get description(): string { if (this._description == null) { this._description = StatusFileFormatter.fromTemplate( this.view.config.formats.files.description, @@ -66,7 +66,7 @@ export class UncommittedFileNode extends ViewFileNode<'uncommitted-file', ViewsW } private _folderName: string | undefined; - get folderName() { + get folderName(): string { if (this._folderName == null) { this._folderName = dirname(this.uri.relativePath); } @@ -74,7 +74,7 @@ export class UncommittedFileNode extends ViewFileNode<'uncommitted-file', ViewsW } private _label: string | undefined; - get label() { + get label(): string { if (this._label == null) { this._label = StatusFileFormatter.fromTemplate( `\${file}`, diff --git a/src/views/nodes/abstract/cacheableChildrenViewNode.ts b/src/views/nodes/abstract/cacheableChildrenViewNode.ts index 3e5ebae2ec7b7..9271f7b1652f4 100644 --- a/src/views/nodes/abstract/cacheableChildrenViewNode.ts +++ b/src/views/nodes/abstract/cacheableChildrenViewNode.ts @@ -21,13 +21,13 @@ export abstract class CacheableChildrenViewNode< this._children = value; } - override dispose() { + override dispose(): void { super.dispose(); this.children = undefined; } @debug() - override refresh(reset: boolean = false) { + override refresh(reset: boolean = false): void { if (reset) { this.children = undefined; } diff --git a/src/views/nodes/abstract/repositoriesSubscribeableNode.ts b/src/views/nodes/abstract/repositoriesSubscribeableNode.ts index 7fbb17386ba04..4a6868ac519f0 100644 --- a/src/views/nodes/abstract/repositoriesSubscribeableNode.ts +++ b/src/views/nodes/abstract/repositoriesSubscribeableNode.ts @@ -19,7 +19,7 @@ export abstract class RepositoriesSubscribeableNode< super('repositories', unknownGitUri, view); } - override async getSplattedChild() { + override async getSplattedChild(): Promise { if (this.children == null) { await this.getChildren(); } diff --git a/src/views/nodes/abstract/repositoryFolderNode.ts b/src/views/nodes/abstract/repositoryFolderNode.ts index 6aa2865676242..ad2a10e24ae65 100644 --- a/src/views/nodes/abstract/repositoryFolderNode.ts +++ b/src/views/nodes/abstract/repositoryFolderNode.ts @@ -49,7 +49,7 @@ export abstract class RepositoryFolderNode< this._child = value; } - override dispose() { + override dispose(): void { super.dispose(); this.child = undefined; } @@ -161,7 +161,7 @@ export abstract class RepositoryFolderNode< return item; } - override async getSplattedChild() { + override async getSplattedChild(): Promise { if (this.child == null) { await this.getChildren(); } @@ -171,7 +171,7 @@ export abstract class RepositoryFolderNode< @gate() @debug() - override async refresh(reset: boolean = false) { + override async refresh(reset: boolean = false): Promise { super.refresh(reset); await this.child?.triggerChange(reset, false, this); @@ -179,13 +179,13 @@ export abstract class RepositoryFolderNode< } @log() - async star() { + async star(): Promise { await this.repo.star(); // void this.parent!.triggerChange(); } @log() - async unstar() { + async unstar(): Promise { await this.repo.unstar(); // void this.parent!.triggerChange(); } diff --git a/src/views/nodes/abstract/subscribeableViewNode.ts b/src/views/nodes/abstract/subscribeableViewNode.ts index e93258486b3f7..a358c7ac18928 100644 --- a/src/views/nodes/abstract/subscribeableViewNode.ts +++ b/src/views/nodes/abstract/subscribeableViewNode.ts @@ -50,7 +50,7 @@ export abstract class SubscribeableViewNode< this.disposable = Disposable.from(...disposables); } - override dispose() { + override dispose(): void { super.dispose(); void this.unsubscribe(); this.disposable?.dispose(); @@ -113,7 +113,7 @@ export abstract class SubscribeableViewNode< } @debug() - protected onAutoRefreshChanged() { + protected onAutoRefreshChanged(): void { this.onVisibilityChanged({ visible: this.view.visible }); } @@ -133,7 +133,7 @@ export abstract class SubscribeableViewNode< // } // } @debug() - protected onVisibilityChanged(e: TreeViewVisibilityChangeEvent) { + protected onVisibilityChanged(e: TreeViewVisibilityChangeEvent): void { void this.ensureSubscription(); if (e.visible) { @@ -143,7 +143,7 @@ export abstract class SubscribeableViewNode< @gate() @debug() - async ensureSubscription() { + async ensureSubscription(): Promise { // We only need to subscribe if we are visible and if auto-refresh enabled (when supported) if (!this.canSubscribe || !this.view.visible || (canAutoRefreshView(this.view) && !this.view.autoRefresh)) { await this.unsubscribe(); @@ -160,7 +160,7 @@ export abstract class SubscribeableViewNode< @gate() @debug() - async resetSubscription() { + async resetSubscription(): Promise { await this.unsubscribe(); await this.ensureSubscription(); } diff --git a/src/views/nodes/abstract/viewFileNode.ts b/src/views/nodes/abstract/viewFileNode.ts index 2d6553161357f..b96d30b66f469 100644 --- a/src/views/nodes/abstract/viewFileNode.ts +++ b/src/views/nodes/abstract/viewFileNode.ts @@ -39,7 +39,7 @@ export function getFileTooltip( file: GitFile | GitStatusFile, suffix?: string, outputFormat?: 'markdown' | 'plaintext', -) { +): string { return StatusFileFormatter.fromTemplate( `\${status${suffix ? `' ${suffix}'` : ''}} $(file) \${filePath}\${ ← originalPath}\${'\\\n'changesDetail}`, file, @@ -49,7 +49,7 @@ export function getFileTooltip( ); } -export function getFileTooltipMarkdown(file: GitFile | GitStatusFile, suffix?: string) { +export function getFileTooltipMarkdown(file: GitFile | GitStatusFile, suffix?: string): MarkdownString { const tooltip = new MarkdownString(getFileTooltip(file, suffix, 'markdown'), true); tooltip.supportHtml = true; tooltip.isTrusted = true; diff --git a/src/views/nodes/abstract/viewNode.ts b/src/views/nodes/abstract/viewNode.ts index 5664818bd6908..02ac7ccfe0e36 100644 --- a/src/views/nodes/abstract/viewNode.ts +++ b/src/views/nodes/abstract/viewNode.ts @@ -279,7 +279,7 @@ export abstract class ViewNode< protected _disposed = false; // NOTE: @eamodio uncomment to track node leaks // @debug() - dispose() { + dispose(): void { this._disposed = true; // NOTE: @eamodio uncomment to track node leaks // this.view.unregisterNode(this); @@ -294,11 +294,11 @@ export abstract class ViewNode< return this._context ?? this.parent?.context ?? {}; } - protected updateContext(context: AmbientContext, reset: boolean = false) { + protected updateContext(context: AmbientContext, reset: boolean = false): void { this._context = this.getNewContext(context, reset); } - protected getNewContext(context: AmbientContext, reset: boolean = false) { + protected getNewContext(context: AmbientContext, reset: boolean = false): AmbientContext { return { ...(reset ? this.parent?.context : this.context), ...context }; } diff --git a/src/views/nodes/branchNode.ts b/src/views/nodes/branchNode.ts index 8547b29f5924e..d2c2b673d66fe 100644 --- a/src/views/nodes/branchNode.ts +++ b/src/views/nodes/branchNode.ts @@ -105,7 +105,7 @@ export class BranchNode }; } - override dispose() { + override dispose(): void { super.dispose(); this.children = undefined; } @@ -436,18 +436,18 @@ export class BranchNode } @log() - async star() { + async star(): Promise { await this.branch.star(); void this.view.refresh(true); } @log() - async unstar() { + async unstar(): Promise { await this.branch.unstar(); void this.view.refresh(true); } - override refresh(reset?: boolean) { + override refresh(reset?: boolean): void { void super.refresh?.(reset); this.children = undefined; @@ -503,12 +503,12 @@ export class BranchNode return this._log; } - get hasMore() { + get hasMore(): boolean { return this._log?.hasMore ?? true; } @gate() - async loadMore(limit?: number | { until?: any }) { + async loadMore(limit?: number | { until?: any }): Promise { let log = await window.withProgress( { location: { viewId: this.view.id }, @@ -800,7 +800,7 @@ export class CommitsCurrentBranchNode extends SubscribeableViewNode<'commits-cur return this.branch.upstream?.missing || this.branch.detached ? undefined : this.repo?.getLastFetched(); } - protected async subscribe() { + protected async subscribe(): Promise { const lastFetched = (await this.getLastFetched()) ?? 0; const interval = getLastFetchedUpdateInterval(lastFetched); diff --git a/src/views/nodes/branchTrackingStatusNode.ts b/src/views/nodes/branchTrackingStatusNode.ts index 3eac6843085e8..7583eb042c451 100644 --- a/src/views/nodes/branchTrackingStatusNode.ts +++ b/src/views/nodes/branchTrackingStatusNode.ts @@ -332,7 +332,7 @@ export class BranchTrackingStatusNode @gate() @debug() - override refresh(reset?: boolean) { + override refresh(reset?: boolean): void { if (reset) { this._log = undefined; } @@ -356,12 +356,12 @@ export class BranchTrackingStatusNode return this._log; } - get hasMore() { + get hasMore(): boolean { return this._log?.hasMore ?? true; } @gate() - async loadMore(limit?: number | { until?: any }) { + async loadMore(limit?: number | { until?: any }): Promise { let log = await window.withProgress( { location: { viewId: this.view.id }, diff --git a/src/views/nodes/branchesNode.ts b/src/views/nodes/branchesNode.ts index 1c1451f24b59e..a0c545f11d8b4 100644 --- a/src/views/nodes/branchesNode.ts +++ b/src/views/nodes/branchesNode.ts @@ -128,7 +128,7 @@ export class BranchesNode extends CacheableChildrenViewNode<'branches', ViewsWit } @debug() - override refresh() { + override refresh(): void { super.refresh(true); } } diff --git a/src/views/nodes/commitFileNode.ts b/src/views/nodes/commitFileNode.ts index 3cbae343b0e5d..ef7dfc4b844c7 100644 --- a/src/views/nodes/commitFileNode.ts +++ b/src/views/nodes/commitFileNode.ts @@ -129,7 +129,7 @@ export abstract class CommitFileNodeBase< } private _folderName: string | undefined; - get folderName() { + get folderName(): string { if (this._folderName === undefined) { this._folderName = relativeDir(this.uri.relativePath); } @@ -137,7 +137,7 @@ export abstract class CommitFileNodeBase< } private _label: string | undefined; - get label() { + get label(): string { if (this._label === undefined) { this._label = StatusFileFormatter.fromTemplate(this.view.config.formats.files.label, this.file, { relativePath: this.relativePath, diff --git a/src/views/nodes/commitNode.ts b/src/views/nodes/commitNode.ts index 222973b449e2d..8def54e34e60e 100644 --- a/src/views/nodes/commitNode.ts +++ b/src/views/nodes/commitNode.ts @@ -49,7 +49,7 @@ export class CommitNode extends ViewRefNode<'commit', ViewsWithCommits | FileHis this._uniqueId = getViewNodeId(this.type, this.context); } - override dispose() { + override dispose(): void { super.dispose(); this.children = undefined; } @@ -213,7 +213,7 @@ export class CommitNode extends ViewRefNode<'commit', ViewsWithCommits | FileHis }; } - override refresh(reset?: boolean) { + override refresh(reset?: boolean): void { void super.refresh?.(reset); this.children = undefined; diff --git a/src/views/nodes/common.ts b/src/views/nodes/common.ts index f13857f38866b..813f8034dcf64 100644 --- a/src/views/nodes/common.ts +++ b/src/views/nodes/common.ts @@ -84,7 +84,7 @@ export abstract class PagerNode extends ViewNode<'pager'> { super('pager', unknownGitUri, view, parent); } - async loadAll() { + async loadAll(): Promise { const count = (await this.options?.getCount?.()) ?? 0; return this.view.loadMoreNodeChildren( this.parent! as ViewNode & PageableViewNode, @@ -94,7 +94,7 @@ export abstract class PagerNode extends ViewNode<'pager'> { ); } - loadMore() { + loadMore(): Promise { return this.view.loadMoreNodeChildren( this.parent! as ViewNode & PageableViewNode, this.options?.pageSize ?? configuration.get('views.pageItemLimit'), diff --git a/src/views/nodes/compareBranchNode.ts b/src/views/nodes/compareBranchNode.ts index a62d4a082e01b..f83829b1a4420 100644 --- a/src/views/nodes/compareBranchNode.ts +++ b/src/views/nodes/compareBranchNode.ts @@ -247,7 +247,7 @@ export class CompareBranchNode extends SubscribeableViewNode< } @log() - async clear() { + async clear(): Promise { this._compareWith = undefined; await this.updateCompareWith(undefined); @@ -256,13 +256,13 @@ export class CompareBranchNode extends SubscribeableViewNode< } @log() - clearReviewed() { + clearReviewed(): void { void this.storeCompareWith(true).catch(); void this.triggerChange(); } @log() - async edit() { + async edit(): Promise { const pick = await showReferencePicker( this.branch.repoPath, `Compare ${this.branch.name}${this.compareWithWorkingTree ? ' (working)' : ''} with`, @@ -286,13 +286,13 @@ export class CompareBranchNode extends SubscribeableViewNode< } @debug() - override refresh(reset?: boolean) { + override refresh(reset?: boolean): void { super.refresh(reset); this.loadCompareWith(); } @log() - async setComparisonType(comparisonType: Exclude) { + async setComparisonType(comparisonType: Exclude): Promise { if (this._compareWith != null) { await this.updateCompareWith({ ...this._compareWith, type: comparisonType, checkedFiles: undefined }); } else { @@ -304,7 +304,7 @@ export class CompareBranchNode extends SubscribeableViewNode< } @log() - async setDefaultCompareWith(compareWith: StoredBranchComparison) { + async setDefaultCompareWith(compareWith: StoredBranchComparison): Promise { if (this._compareWith != null) return; await this.updateCompareWith(compareWith); diff --git a/src/views/nodes/compareResultsNode.ts b/src/views/nodes/compareResultsNode.ts index 970fb8e84cb31..e4a9bc100d139 100644 --- a/src/views/nodes/compareResultsNode.ts +++ b/src/views/nodes/compareResultsNode.ts @@ -127,7 +127,7 @@ export class CompareResultsNode extends SubscribeableViewNode< } } - dismiss() { + dismiss(): void { void this.remove(true); } @@ -254,13 +254,13 @@ export class CompareResultsNode extends SubscribeableViewNode< } @log() - clearReviewed() { + clearReviewed(): void { resetComparisonCheckedFiles(this.view, this.getStorageId()); void this.store().catch(); } @log() - async swap() { + async swap(): Promise { if (this._ref.ref === '') { void window.showErrorMessage('Cannot swap comparisons with the working tree'); return; @@ -322,7 +322,7 @@ export class CompareResultsNode extends SubscribeableViewNode< return this.store(silent); } - store(silent = false) { + store(silent = false): Promise { const storageId = this.getStorageId(); const checkedFiles = getComparisonCheckedFiles(this.view, storageId); @@ -341,11 +341,11 @@ export class CompareResultsNode extends SubscribeableViewNode< } } -export function getComparisonStoragePrefix(storageId: string) { +export function getComparisonStoragePrefix(storageId: string): string { return `${storageId}|`; } -export function getComparisonCheckedFiles(view: View, storageId: string) { +export function getComparisonCheckedFiles(view: View, storageId: string): string[] { const checkedFiles = []; const checked = view.nodeState.get(getComparisonStoragePrefix(storageId), 'checked'); @@ -357,11 +357,11 @@ export function getComparisonCheckedFiles(view: View, storageId: string) { return checkedFiles; } -export function resetComparisonCheckedFiles(view: View, storageId: string) { +export function resetComparisonCheckedFiles(view: View, storageId: string): void { view.nodeState.delete(getComparisonStoragePrefix(storageId), 'checked'); } -export function restoreComparisonCheckedFiles(view: View, checkedFiles: string[] | undefined) { +export function restoreComparisonCheckedFiles(view: View, checkedFiles: string[] | undefined): void { if (checkedFiles?.length) { for (const id of checkedFiles) { view.nodeState.storeState(id, 'checked', TreeItemCheckboxState.Checked, true); diff --git a/src/views/nodes/contributorNode.ts b/src/views/nodes/contributorNode.ts index 72a7aba10c123..8f077ca28aaae 100644 --- a/src/views/nodes/contributorNode.ts +++ b/src/views/nodes/contributorNode.ts @@ -174,7 +174,7 @@ export class ContributorNode extends ViewNode<'contributor', ViewsWithContributo @gate() @debug() - override refresh(reset?: boolean) { + override refresh(reset?: boolean): void { if (reset) { this._log = undefined; } @@ -198,12 +198,12 @@ export class ContributorNode extends ViewNode<'contributor', ViewsWithContributo return this._log; } - get hasMore() { + get hasMore(): boolean { return this._log?.hasMore ?? true; } @gate() - async loadMore(limit?: number | { until?: any }) { + async loadMore(limit?: number | { until?: any }): Promise { let log = await window.withProgress( { location: { viewId: this.view.id }, diff --git a/src/views/nodes/contributorsNode.ts b/src/views/nodes/contributorsNode.ts index ca2cdb14ee5d5..1de1919a4a252 100644 --- a/src/views/nodes/contributorsNode.ts +++ b/src/views/nodes/contributorsNode.ts @@ -99,7 +99,7 @@ export class ContributorsNode extends CacheableChildrenViewNode< return item; } - updateAvatar(email: string) { + updateAvatar(email: string): void { if (this.children == null) return; for (const child of this.children) { @@ -110,7 +110,7 @@ export class ContributorsNode extends CacheableChildrenViewNode< } @debug() - override refresh() { + override refresh(): void { super.refresh(true); } diff --git a/src/views/nodes/fileHistoryNode.ts b/src/views/nodes/fileHistoryNode.ts index b995fc28338f7..ac942004e28cc 100644 --- a/src/views/nodes/fileHistoryNode.ts +++ b/src/views/nodes/fileHistoryNode.ts @@ -162,7 +162,7 @@ export class FileHistoryNode return item; } - get label() { + get label(): string { // Check if this is a base folder if (this.folder && this.uri.fileName === '') { return `${basename(this.uri.path)}${ @@ -178,7 +178,7 @@ export class FileHistoryNode } @debug() - protected subscribe() { + protected subscribe(): Disposable | undefined { const repo = this.view.container.git.getRepository(this.uri); if (repo == null) return undefined; @@ -242,7 +242,7 @@ export class FileHistoryNode @gate() @debug() - override refresh(reset?: boolean) { + override refresh(reset?: boolean): void { if (reset) { this._log = undefined; } @@ -266,12 +266,12 @@ export class FileHistoryNode return this.folder ? getFolderGlobUri(this.uri) : this.uri; } - get hasMore() { + get hasMore(): boolean { return this._log?.hasMore ?? true; } @gate() - async loadMore(limit?: number | { until?: any }) { + async loadMore(limit?: number | { until?: any }): Promise { let log = await window.withProgress( { location: { viewId: this.view.id }, diff --git a/src/views/nodes/fileHistoryTrackerNode.ts b/src/views/nodes/fileHistoryTrackerNode.ts index 4d5ed3b3d2940..ccf127d85c4b8 100644 --- a/src/views/nodes/fileHistoryTrackerNode.ts +++ b/src/views/nodes/fileHistoryTrackerNode.ts @@ -30,7 +30,7 @@ export class FileHistoryTrackerNode extends SubscribeableViewNode<'file-history- super('file-history-tracker', unknownGitUri, view); } - override dispose() { + override dispose(): void { super.dispose(); this.child = undefined; } @@ -98,7 +98,7 @@ export class FileHistoryTrackerNode extends SubscribeableViewNode<'file-history- @gate() @log() - async changeBase() { + async changeBase(): Promise { const pick = await showReferencePicker( this.uri.repoPath!, 'Change File History Base', @@ -125,7 +125,7 @@ export class FileHistoryTrackerNode extends SubscribeableViewNode<'file-history- @gate() @debug({ exit: true }) - override async refresh(reset: boolean = false) { + override async refresh(reset: boolean = false): Promise { const scope = getLogScope(); if (!this.canSubscribe) return false; @@ -196,7 +196,7 @@ export class FileHistoryTrackerNode extends SubscribeableViewNode<'file-history- } @log() - setEditorFollowing(enabled: boolean) { + setEditorFollowing(enabled: boolean): void { if (enabled) { this.setUri(); // Don't need to call triggerChange here, since canSubscribe will do it @@ -209,13 +209,13 @@ export class FileHistoryTrackerNode extends SubscribeableViewNode<'file-history- } @log() - async showHistoryForUri(uri: GitUri) { + async showHistoryForUri(uri: GitUri): Promise { this.setUri(uri); await this.triggerChange(); } @debug() - protected subscribe() { + protected subscribe(): Disposable { return Disposable.from( weakEvent(window.onDidChangeActiveTextEditor, debounce(this.onActiveEditorChanged, 250), this), ); @@ -242,7 +242,7 @@ export class FileHistoryTrackerNode extends SubscribeableViewNode<'file-history- void this.triggerChange(); } - setUri(uri?: GitUri) { + setUri(uri?: GitUri): void { this._uri = uri ?? unknownGitUri; void setContext('gitlens:views:fileHistory:canPin', this.hasUri); } diff --git a/src/views/nodes/fileRevisionAsCommitNode.ts b/src/views/nodes/fileRevisionAsCommitNode.ts index 2a3d15571e437..b5259afb1c9c3 100644 --- a/src/views/nodes/fileRevisionAsCommitNode.ts +++ b/src/views/nodes/fileRevisionAsCommitNode.ts @@ -229,7 +229,7 @@ export async function getFileRevisionAsCommitTooltip( getBranchAndTagTips?: (sha: string, options?: { compact?: boolean }) => string | undefined; unpublished?: boolean; }, -) { +): Promise { const [remotesResult, _] = await Promise.allSettled([ container.git.remotes(commit.repoPath).getBestRemotesWithProviders(options?.cancellation), commit.message == null ? commit.ensureFullDetails() : undefined, diff --git a/src/views/nodes/launchpadViewGroupingNode.ts b/src/views/nodes/launchpadViewGroupingNode.ts index 553f6f1c6988d..d1adeedfb70c1 100644 --- a/src/views/nodes/launchpadViewGroupingNode.ts +++ b/src/views/nodes/launchpadViewGroupingNode.ts @@ -25,7 +25,7 @@ export class LaunchpadViewGroupingNode exten ); } - override dispose() { + override dispose(): void { super.dispose(); this.disposable?.dispose(); } diff --git a/src/views/nodes/lineHistoryNode.ts b/src/views/nodes/lineHistoryNode.ts index 4b4015fea492f..035816bd2a099 100644 --- a/src/views/nodes/lineHistoryNode.ts +++ b/src/views/nodes/lineHistoryNode.ts @@ -176,21 +176,21 @@ export class LineHistoryNode return item; } - get label() { + get label(): string { return `${this.uri.fileName}${this.lines}${ this.uri.sha ? ` ${this.uri.sha === deletedOrMissing ? this.uri.shortSha : `(${this.uri.shortSha})`}` : '' }`; } @memoize() - get lines() { + get lines(): string { return this.selection.isSingleLine ? `:${this.selection.start.line + 1}` : `:${this.selection.start.line + 1}-${this.selection.end.line + 1}`; } @debug() - protected subscribe() { + protected subscribe(): Disposable | undefined { const repo = this.view.container.git.getRepository(this.uri); if (repo == null) return undefined; @@ -241,7 +241,7 @@ export class LineHistoryNode @gate() @debug() - override refresh(reset?: boolean) { + override refresh(reset?: boolean): void { if (reset) { this._log = undefined; } @@ -263,12 +263,12 @@ export class LineHistoryNode return this._log; } - get hasMore() { + get hasMore(): boolean { return this._log?.hasMore ?? true; } @gate() - async loadMore(limit?: number | { until?: any }) { + async loadMore(limit?: number | { until?: any }): Promise { let log = await window.withProgress( { location: { viewId: this.view.id }, diff --git a/src/views/nodes/lineHistoryTrackerNode.ts b/src/views/nodes/lineHistoryTrackerNode.ts index 521c9dc0e3771..443c316afd1a8 100644 --- a/src/views/nodes/lineHistoryTrackerNode.ts +++ b/src/views/nodes/lineHistoryTrackerNode.ts @@ -1,4 +1,4 @@ -import type { Selection } from 'vscode'; +import type { Disposable, Selection } from 'vscode'; import { TreeItem, TreeItemCollapsibleState, window } from 'vscode'; import type { GitCommitish } from '../../git/gitUri'; import { GitUri, unknownGitUri } from '../../git/gitUri'; @@ -35,7 +35,7 @@ export class LineHistoryTrackerNode extends SubscribeableViewNode< super('line-history-tracker', unknownGitUri, view); } - override dispose() { + override dispose(): void { super.dispose(); this.child = undefined; } @@ -117,7 +117,7 @@ export class LineHistoryTrackerNode extends SubscribeableViewNode< @gate() @log() - async changeBase() { + async changeBase(): Promise { const pick = await showReferencePicker( this.uri.repoPath!, 'Change Line History Base', @@ -144,7 +144,7 @@ export class LineHistoryTrackerNode extends SubscribeableViewNode< @gate() @debug({ exit: true }) - override async refresh(reset: boolean = false) { + override async refresh(reset: boolean = false): Promise { const scope = getLogScope(); if (!this.canSubscribe) return false; @@ -215,12 +215,12 @@ export class LineHistoryTrackerNode extends SubscribeableViewNode< } @log() - setEditorFollowing(enabled: boolean) { + setEditorFollowing(enabled: boolean): void { this.canSubscribe = enabled; } @debug() - protected subscribe() { + protected subscribe(): Disposable | undefined { if (this.view.container.lineTracker.subscribed(this)) return undefined; const onActiveLinesChanged = debounce(this.onActiveLinesChanged.bind(this), 250); @@ -255,7 +255,7 @@ export class LineHistoryTrackerNode extends SubscribeableViewNode< void this.triggerChange(); } - setUri(uri?: GitUri) { + setUri(uri?: GitUri): void { this._uri = uri ?? unknownGitUri; void setContext('gitlens:views:fileHistory:canPin', this.hasUri); } diff --git a/src/views/nodes/mergeConflictFileNode.ts b/src/views/nodes/mergeConflictFileNode.ts index 6f6605e450572..dc108acf5c123 100644 --- a/src/views/nodes/mergeConflictFileNode.ts +++ b/src/views/nodes/mergeConflictFileNode.ts @@ -63,7 +63,7 @@ export class MergeConflictFileNode extends ViewFileNode<'conflict-file', ViewsWi } private _description: string | undefined; - get description() { + get description(): string { if (this._description == null) { this._description = StatusFileFormatter.fromTemplate( this.view.config.formats.files.description, @@ -77,7 +77,7 @@ export class MergeConflictFileNode extends ViewFileNode<'conflict-file', ViewsWi } private _folderName: string | undefined; - get folderName() { + get folderName(): string { if (this._folderName == null) { this._folderName = relativeDir(this.uri.relativePath); } @@ -85,7 +85,7 @@ export class MergeConflictFileNode extends ViewFileNode<'conflict-file', ViewsWi } private _label: string | undefined; - get label() { + get label(): string { if (this._label == null) { this._label = StatusFileFormatter.fromTemplate(this.view.config.formats.files.label, this.file, { relativePath: this.relativePath, diff --git a/src/views/nodes/pullRequestNode.ts b/src/views/nodes/pullRequestNode.ts index 5d36b8619729a..dd6f22928dd0a 100644 --- a/src/views/nodes/pullRequestNode.ts +++ b/src/views/nodes/pullRequestNode.ts @@ -135,7 +135,7 @@ export async function getPullRequestChildren( parent: ViewNode, pullRequest: PullRequest, repoOrPath?: Repository | string, -) { +): Promise { let repo: Repository | undefined; if (repoOrPath == null) { repo = await getOrOpenPullRequestRepository(view.container, pullRequest, { promptIfNeeded: true }); @@ -216,7 +216,7 @@ export async function getPullRequestChildren( export function getPullRequestTooltip( pullRequest: PullRequest, context?: { commit?: GitCommit; idPrefix?: string; codeSuggestionsCount?: number }, -) { +): MarkdownString { const tooltip = new MarkdownString('', true); tooltip.supportHtml = true; tooltip.isTrusted = true; diff --git a/src/views/nodes/reflogNode.ts b/src/views/nodes/reflogNode.ts index 2672ac7166996..8a0f99ff47524 100644 --- a/src/views/nodes/reflogNode.ts +++ b/src/views/nodes/reflogNode.ts @@ -68,7 +68,7 @@ export class ReflogNode } @debug() - override refresh(reset?: boolean) { + override refresh(reset?: boolean): void { super.refresh(true); if (reset) { @@ -88,11 +88,11 @@ export class ReflogNode return this._reflog; } - get hasMore() { + get hasMore(): boolean { return this._reflog?.hasMore ?? true; } - async loadMore(limit?: number) { + async loadMore(limit?: number): Promise { let reflog = await this.getReflog(); if (!reflog?.hasMore) return; diff --git a/src/views/nodes/reflogRecordNode.ts b/src/views/nodes/reflogRecordNode.ts index b14a1d1553e59..bb75ff2e460ce 100644 --- a/src/views/nodes/reflogRecordNode.ts +++ b/src/views/nodes/reflogRecordNode.ts @@ -70,7 +70,7 @@ export class ReflogRecordNode extends ViewNode<'reflog-record', ViewsWithCommits @gate() @debug() - override refresh(reset?: boolean) { + override refresh(reset?: boolean): void { if (reset) { this._log = undefined; } @@ -88,12 +88,12 @@ export class ReflogRecordNode extends ViewNode<'reflog-record', ViewsWithCommits return this._log; } - get hasMore() { + get hasMore(): boolean { return this._log?.hasMore ?? true; } @gate() - async loadMore(limit?: number | { until?: any }) { + async loadMore(limit?: number | { until?: any }): Promise { let log = await window.withProgress( { location: { viewId: this.view.id }, diff --git a/src/views/nodes/remoteNode.ts b/src/views/nodes/remoteNode.ts index 49bd37975bb55..6bbd03ac1ce96 100644 --- a/src/views/nodes/remoteNode.ts +++ b/src/views/nodes/remoteNode.ts @@ -142,7 +142,7 @@ export class RemoteNode extends ViewNode<'remote', ViewsWithRemotes> { } @log() - async setAsDefault(state: boolean = true) { + async setAsDefault(state: boolean = true): Promise { await this.remote.setAsDefault(state); void this.triggerChange(); } diff --git a/src/views/nodes/remotesNode.ts b/src/views/nodes/remotesNode.ts index 6dc0bb1e094a0..7224180faf718 100644 --- a/src/views/nodes/remotesNode.ts +++ b/src/views/nodes/remotesNode.ts @@ -53,7 +53,7 @@ export class RemotesNode extends CacheableChildrenViewNode<'remotes', ViewsWithR } @debug() - override refresh() { + override refresh(): void { super.refresh(true); } } diff --git a/src/views/nodes/repositoriesNode.ts b/src/views/nodes/repositoriesNode.ts index c76b2adef9250..9b607adfaabd5 100644 --- a/src/views/nodes/repositoriesNode.ts +++ b/src/views/nodes/repositoriesNode.ts @@ -68,7 +68,7 @@ export class RepositoriesNode extends SubscribeableViewNode< @gate() @debug() - override async refresh(reset: boolean = false) { + override async refresh(reset: boolean = false): Promise { const hasChildren = this.children != null; super.refresh(reset); if (!hasChildren) return; @@ -106,7 +106,7 @@ export class RepositoriesNode extends SubscribeableViewNode< } @debug() - protected subscribe() { + protected subscribe(): Disposable { const subscriptions = [ weakEvent(this.view.container.git.onDidChangeRepositories, this.onRepositoriesChanged, this), ]; diff --git a/src/views/nodes/repositoryNode.ts b/src/views/nodes/repositoryNode.ts index e6e801e894020..491fb0c23cec1 100644 --- a/src/views/nodes/repositoryNode.ts +++ b/src/views/nodes/repositoryNode.ts @@ -314,23 +314,23 @@ export class RepositoryNode extends SubscribeableViewNode<'repository', ViewsWit } @log() - fetch(options: { all?: boolean; progress?: boolean; prune?: boolean; remote?: string } = {}) { + fetch(options: { all?: boolean; progress?: boolean; prune?: boolean; remote?: string }): Promise { return this.repo.fetch(options); } @log() - pull(options: { progress?: boolean; rebase?: boolean } = {}) { + pull(options: { progress?: boolean; rebase?: boolean }): Promise { return this.repo.pull(options); } @log() - push(options: { force?: boolean; progress?: boolean } = {}) { + push(options: { force?: boolean; progress?: boolean }): Promise { return this.repo.push(options); } @gate() @debug() - override async refresh(reset: boolean = false) { + override async refresh(reset: boolean = false): Promise { super.refresh(reset); if (reset) { @@ -341,19 +341,19 @@ export class RepositoryNode extends SubscribeableViewNode<'repository', ViewsWit } @log() - async star() { + async star(): Promise { await this.repo.star(); void this.parent!.triggerChange(); } @log() - async unstar() { + async unstar(): Promise { await this.repo.unstar(); void this.parent!.triggerChange(); } @debug() - protected async subscribe() { + protected async subscribe(): Promise { const lastFetched = (await this.repo?.getLastFetched()) ?? 0; const disposables = [weakEvent(this.repo.onDidChange, this.onRepositoryChanged, this)]; diff --git a/src/views/nodes/resultsCommitsNode.ts b/src/views/nodes/resultsCommitsNode.ts index 07e35bf8c2e83..40e76b81b139b 100644 --- a/src/views/nodes/resultsCommitsNode.ts +++ b/src/views/nodes/resultsCommitsNode.ts @@ -209,7 +209,7 @@ export class ResultsCommitsNode { return this.ensureResults().loadMore(limit); } @@ -157,7 +157,7 @@ export class SearchResultsNode extends ViewNode<'search-results', SearchAndCompa resultsType?: { singular: string; plural: string }; }; log: Promise | GitLog | undefined; - }) { + }): Promise { if (search == null) { await executeGitCommand({ command: 'search', @@ -189,7 +189,7 @@ export class SearchResultsNode extends ViewNode<'search-results', SearchAndCompa @gate() @debug() - override refresh(reset: boolean = false) { + override refresh(reset: boolean = false): void { this._resultsNode?.refresh(reset); } diff --git a/src/views/nodes/stashesNode.ts b/src/views/nodes/stashesNode.ts index 3624a10ce691d..ddd8742e9623d 100644 --- a/src/views/nodes/stashesNode.ts +++ b/src/views/nodes/stashesNode.ts @@ -51,7 +51,7 @@ export class StashesNode extends CacheableChildrenViewNode<'stashes', ViewsWithS } @debug() - override refresh() { + override refresh(): void { super.refresh(true); } } diff --git a/src/views/nodes/statusFileNode.ts b/src/views/nodes/statusFileNode.ts index 695d238a5cc77..f553d2fb10510 100644 --- a/src/views/nodes/statusFileNode.ts +++ b/src/views/nodes/statusFileNode.ts @@ -5,6 +5,7 @@ import type { DiffWithPreviousCommandArgs } from '../../commands/diffWithPreviou import { GlCommand } from '../../constants.commands'; import { StatusFileFormatter } from '../../git/formatters/statusFormatter'; import { GitUri } from '../../git/gitUri'; +import type { GitCommit } from '../../git/models/commit'; import type { GitFileWithCommit } from '../../git/models/file'; import { isGitFileChange } from '../../git/models/fileChange'; import { getGitFileStatusIcon } from '../../git/utils/fileStatus.utils'; @@ -141,7 +142,7 @@ export class StatusFileNode extends ViewFileNode<'status-file', ViewsWithCommits } private _description: string | undefined; - get description() { + get description(): string { if (this._description == null) { this._description = StatusFileFormatter.fromTemplate( this.view.config.formats.files.description, @@ -158,7 +159,7 @@ export class StatusFileNode extends ViewFileNode<'status-file', ViewsWithCommits } private _folderName: string | undefined; - get folderName() { + get folderName(): string { if (this._folderName == null) { this._folderName = relativeDir(this.uri.relativePath); } @@ -166,7 +167,7 @@ export class StatusFileNode extends ViewFileNode<'status-file', ViewsWithCommits } private _label: string | undefined; - get label() { + get label(): string { if (this._label == null) { this._label = StatusFileFormatter.fromTemplate( this.view.config.formats.files.label, @@ -182,7 +183,7 @@ export class StatusFileNode extends ViewFileNode<'status-file', ViewsWithCommits return this._label; } - get commit() { + get commit(): GitCommit { return this._files[0]?.commit; } diff --git a/src/views/nodes/tagNode.ts b/src/views/nodes/tagNode.ts index ebd4e3b641645..39d3c7be39a40 100644 --- a/src/views/nodes/tagNode.ts +++ b/src/views/nodes/tagNode.ts @@ -104,7 +104,7 @@ export class TagNode extends ViewRefNode<'tag', ViewsWithTags, GitTagReference> @gate() @debug() - override refresh(reset?: boolean) { + override refresh(reset?: boolean): void { if (reset) { this._log = undefined; } @@ -121,12 +121,12 @@ export class TagNode extends ViewRefNode<'tag', ViewsWithTags, GitTagReference> return this._log; } - get hasMore() { + get hasMore(): boolean { return this._log?.hasMore ?? true; } @gate() - async loadMore(limit?: number | { until?: any }) { + async loadMore(limit?: number | { until?: any }): Promise { let log = await window.withProgress( { location: { viewId: this.view.id }, diff --git a/src/views/nodes/tagsNode.ts b/src/views/nodes/tagsNode.ts index ba2351c0fb600..dca0a908e1bbd 100644 --- a/src/views/nodes/tagsNode.ts +++ b/src/views/nodes/tagsNode.ts @@ -66,7 +66,7 @@ export class TagsNode extends CacheableChildrenViewNode<'tags', ViewsWithTagsNod } @debug() - override refresh() { + override refresh(): void { super.refresh(true); } } diff --git a/src/views/nodes/worktreeNode.ts b/src/views/nodes/worktreeNode.ts index 61ef1f59942e0..a4d9b9022f044 100644 --- a/src/views/nodes/worktreeNode.ts +++ b/src/views/nodes/worktreeNode.ts @@ -369,7 +369,7 @@ export class WorktreeNode extends CacheableChildrenViewNode<'worktree', ViewsWit } @debug() - override refresh(reset?: boolean) { + override refresh(reset?: boolean): void { super.refresh(true); if (reset) { @@ -412,12 +412,12 @@ export class WorktreeNode extends CacheableChildrenViewNode<'worktree', ViewsWit return this._log; } - get hasMore() { + get hasMore(): boolean { return this._log?.hasMore ?? true; } @gate() - async loadMore(limit?: number | { until?: any }) { + async loadMore(limit?: number | { until?: any }): Promise { let log = await window.withProgress( { location: { viewId: this.view.id }, diff --git a/src/views/nodes/worktreesNode.ts b/src/views/nodes/worktreesNode.ts index 549fdadb7e787..a5f121a73b45f 100644 --- a/src/views/nodes/worktreesNode.ts +++ b/src/views/nodes/worktreesNode.ts @@ -83,7 +83,7 @@ export class WorktreesNode extends CacheableChildrenViewNode<'worktrees', ViewsW } @debug() - override refresh() { + override refresh(): void { super.refresh(true); } } diff --git a/src/views/pullRequestView.ts b/src/views/pullRequestView.ts index fae1d67cacda4..0b2585225355a 100644 --- a/src/views/pullRequestView.ts +++ b/src/views/pullRequestView.ts @@ -31,7 +31,10 @@ export class PullRequestViewNode extends ViewNode<'pullrequest', PullRequestView return item; } - async setPullRequest(pr: PullRequest | undefined, branchOrCommitOrRepoPath: GitBranch | GitCommit | string) { + async setPullRequest( + pr: PullRequest | undefined, + branchOrCommitOrRepoPath: GitBranch | GitCommit | string, + ): Promise { if (pr != null) { this.child = new PullRequestNode(this.view, this, pr, branchOrCommitOrRepoPath, { expand: true }); this.view.description = `${pr.repository.owner}/${pr.repository.repo}#${pr.id}`; @@ -64,11 +67,14 @@ export class PullRequestView extends ViewBase<'pullRequest', PullRequestViewNode return false; } - close() { + close(): void { this.setVisible(false); } - async showPullRequest(pr: PullRequest | undefined, branchOrCommitOrRepoPath: GitBranch | GitCommit | string) { + async showPullRequest( + pr: PullRequest | undefined, + branchOrCommitOrRepoPath: GitBranch | GitCommit | string, + ): Promise { if (pr != null) { this.description = `${pr.repository.owner}/${pr.repository.repo}#${pr.id}`; this.setVisible(true); @@ -87,7 +93,7 @@ export class PullRequestView extends ViewBase<'pullRequest', PullRequestViewNode void setContext('gitlens:views:pullRequest:visible', visible); } - protected getRoot() { + protected getRoot(): PullRequestViewNode { return new PullRequestViewNode(this); } @@ -120,7 +126,7 @@ export class PullRequestView extends ViewBase<'pullRequest', PullRequestViewNode ]; } - protected override filterConfigurationChanged(e: ConfigurationChangeEvent) { + protected override filterConfigurationChanged(e: ConfigurationChangeEvent): boolean { const changed = super.filterConfigurationChanged(e); if ( !changed && diff --git a/src/views/remotesView.ts b/src/views/remotesView.ts index b7f9d309015e0..d24a908a712cd 100644 --- a/src/views/remotesView.ts +++ b/src/views/remotesView.ts @@ -36,7 +36,7 @@ export class RemotesRepositoryNode extends RepositoryFolderNode { if (!branch.remote) return undefined; const { repoPath } = branch; @@ -213,7 +213,10 @@ export class RemotesView extends ViewBase<'remotes', RemotesViewNode, RemotesVie }); } - async findCommit(commit: GitCommit | { repoPath: string; ref: string }, token?: CancellationToken) { + async findCommit( + commit: GitCommit | { repoPath: string; ref: string }, + token?: CancellationToken, + ): Promise { const { repoPath } = commit; // Get all the remote branches the commit is on @@ -256,7 +259,7 @@ export class RemotesView extends ViewBase<'remotes', RemotesViewNode, RemotesVie }); } - findRemote(remote: GitRemote, token?: CancellationToken) { + async findRemote(remote: GitRemote, token?: CancellationToken): Promise { const { repoPath } = remote; return this.findNode((n: any) => n.remote?.name === remote.name, { @@ -276,14 +279,14 @@ export class RemotesView extends ViewBase<'remotes', RemotesViewNode, RemotesVie } @gate(() => '') - revealBranch( + async revealBranch( branch: GitBranchReference, options?: { select?: boolean; focus?: boolean; expand?: boolean | number; }, - ) { + ): Promise { return window.withProgress( { location: ProgressLocation.Notification, @@ -312,7 +315,7 @@ export class RemotesView extends ViewBase<'remotes', RemotesViewNode, RemotesVie focus?: boolean; expand?: boolean | number; }, - ) { + ): Promise { return window.withProgress( { location: ProgressLocation.Notification, @@ -334,14 +337,14 @@ export class RemotesView extends ViewBase<'remotes', RemotesViewNode, RemotesVie } @gate(() => '') - revealRemote( + async revealRemote( remote: GitRemote, options?: { select?: boolean; focus?: boolean; expand?: boolean | number; }, - ) { + ): Promise { return window.withProgress( { location: ProgressLocation.Notification, @@ -363,7 +366,7 @@ export class RemotesView extends ViewBase<'remotes', RemotesViewNode, RemotesVie async revealRepository( repoPath: string, options?: { select?: boolean; focus?: boolean; expand?: boolean | number }, - ) { + ): Promise { const node = await this.findNode(n => n instanceof RepositoryFolderNode && n.repoPath === repoPath, { maxDepth: 1, canTraverse: n => n instanceof RemotesViewNode || n instanceof RepositoryFolderNode, diff --git a/src/views/repositoriesView.ts b/src/views/repositoriesView.ts index f24287ebae80a..f9a861e49031f 100644 --- a/src/views/repositoriesView.ts +++ b/src/views/repositoriesView.ts @@ -20,6 +20,7 @@ import { executeCommand } from '../system/-webview/command'; import { configuration } from '../system/-webview/configuration'; import { setContext } from '../system/-webview/context'; import { gate } from '../system/decorators/-webview/gate'; +import type { ViewNode } from './nodes/abstract/viewNode'; import { BranchesNode } from './nodes/branchesNode'; import { BranchNode } from './nodes/branchNode'; import { BranchOrTagFolderNode } from './nodes/branchOrTagFolderNode'; @@ -51,7 +52,7 @@ export class RepositoriesView extends ViewBase<'repositories', RepositoriesNode, return this._onDidChangeAutoRefresh.event; } - protected getRoot() { + protected getRoot(): RepositoriesNode { return new RepositoriesNode(this); } @@ -235,7 +236,7 @@ export class RepositoriesView extends ViewBase<'repositories', RepositoriesNode, ]; } - protected override filterConfigurationChanged(e: ConfigurationChangeEvent) { + protected override filterConfigurationChanged(e: ConfigurationChangeEvent): boolean { const changed = super.filterConfigurationChanged(e); if ( !changed && @@ -257,7 +258,7 @@ export class RepositoriesView extends ViewBase<'repositories', RepositoriesNode, return true; } - protected override onConfigurationChanged(e: ConfigurationChangeEvent) { + protected override onConfigurationChanged(e: ConfigurationChangeEvent): void { if (configuration.changed(e, `views.${this.configKey}.autoRefresh` as const)) { void this.setAutoRefresh(configuration.get('views.repositories.autoRefresh')); } @@ -265,11 +266,11 @@ export class RepositoriesView extends ViewBase<'repositories', RepositoriesNode, super.onConfigurationChanged(e); } - get autoRefresh() { + get autoRefresh(): boolean { return this.config.autoRefresh && this.container.storage.getWorkspace('views:repositories:autoRefresh', true); } - findBranch(branch: GitBranchReference, token?: CancellationToken) { + findBranch(branch: GitBranchReference, token?: CancellationToken): Promise { const { repoPath } = branch; if (branch.remote) { @@ -318,7 +319,10 @@ export class RepositoriesView extends ViewBase<'repositories', RepositoriesNode, }); } - async findCommit(commit: GitCommit | { repoPath: string; ref: string }, token?: CancellationToken) { + async findCommit( + commit: GitCommit | { repoPath: string; ref: string }, + token?: CancellationToken, + ): Promise { const { repoPath } = commit; // Get all the branches the commit is on @@ -393,7 +397,7 @@ export class RepositoriesView extends ViewBase<'repositories', RepositoriesNode, }); } - findContributor(contributor: GitContributor, token?: CancellationToken) { + findContributor(contributor: GitContributor, token?: CancellationToken): Promise { const { repoPath, username, email, name } = contributor; return this.findNode( @@ -419,7 +423,7 @@ export class RepositoriesView extends ViewBase<'repositories', RepositoriesNode, ); } - findRemote(remote: GitRemote, token?: CancellationToken) { + findRemote(remote: GitRemote, token?: CancellationToken): Promise { const { repoPath } = remote; return this.findNode((n: any) => n.remote?.name === remote.name, { @@ -439,7 +443,7 @@ export class RepositoriesView extends ViewBase<'repositories', RepositoriesNode, }); } - findStash(stash: GitStashReference, token?: CancellationToken) { + findStash(stash: GitStashReference, token?: CancellationToken): Promise { const { repoPath } = stash; return this.findNode((n: any) => n.commit?.ref === stash.ref, { @@ -458,7 +462,7 @@ export class RepositoriesView extends ViewBase<'repositories', RepositoriesNode, }); } - findTag(tag: GitTagReference, token?: CancellationToken) { + findTag(tag: GitTagReference, token?: CancellationToken): Promise { const { repoPath } = tag; return this.findNode((n: any) => n.tag?.ref === tag.ref, { @@ -478,7 +482,7 @@ export class RepositoriesView extends ViewBase<'repositories', RepositoriesNode, }); } - findWorktree(worktree: GitWorktree, token?: CancellationToken) { + findWorktree(worktree: GitWorktree, token?: CancellationToken): Promise { const { repoPath, uri } = worktree; const url = uri.toString(); @@ -499,14 +503,14 @@ export class RepositoriesView extends ViewBase<'repositories', RepositoriesNode, } @gate(() => '') - revealBranch( + async revealBranch( branch: GitBranchReference, options?: { select?: boolean; focus?: boolean; expand?: boolean | number; }, - ) { + ): Promise { return window.withProgress( { location: ProgressLocation.Notification, @@ -535,7 +539,7 @@ export class RepositoriesView extends ViewBase<'repositories', RepositoriesNode, focus?: boolean; expand?: boolean | number; }, - ) { + ): Promise { const node = await this.findNode(n => n instanceof BranchesNode && n.repoPath === repoPath, { maxDepth: 2, canTraverse: n => { @@ -565,7 +569,7 @@ export class RepositoriesView extends ViewBase<'repositories', RepositoriesNode, focus?: boolean; expand?: boolean | number; }, - ) { + ): Promise { return window.withProgress( { location: ProgressLocation.Notification, @@ -594,7 +598,7 @@ export class RepositoriesView extends ViewBase<'repositories', RepositoriesNode, focus?: boolean; expand?: boolean | number; }, - ) { + ): Promise { return window.withProgress( { location: ProgressLocation.Notification, @@ -613,14 +617,14 @@ export class RepositoriesView extends ViewBase<'repositories', RepositoriesNode, } @gate(() => '') - revealRemote( + async revealRemote( remote: GitRemote, options?: { select?: boolean; focus?: boolean; expand?: boolean | number; }, - ) { + ): Promise { return window.withProgress( { location: ProgressLocation.Notification, @@ -646,7 +650,7 @@ export class RepositoriesView extends ViewBase<'repositories', RepositoriesNode, focus?: boolean; expand?: boolean | number; }, - ) { + ): Promise { const node = await this.findNode(n => n instanceof RepositoryNode && n.repoPath === repoPath, { maxDepth: 1, canTraverse: n => n instanceof RepositoriesNode, @@ -667,7 +671,7 @@ export class RepositoriesView extends ViewBase<'repositories', RepositoriesNode, focus?: boolean; expand?: boolean | number; }, - ) { + ): Promise { return window.withProgress( { location: ProgressLocation.Notification, @@ -696,7 +700,7 @@ export class RepositoriesView extends ViewBase<'repositories', RepositoriesNode, focus?: boolean; expand?: boolean | number; }, - ) { + ): Promise { const node = await this.findNode(n => n instanceof StashesNode && n.repoPath === repoPath, { maxDepth: 2, canTraverse: n => { @@ -719,14 +723,14 @@ export class RepositoriesView extends ViewBase<'repositories', RepositoriesNode, } @gate(() => '') - revealTag( + async revealTag( tag: GitTagReference, options?: { select?: boolean; focus?: boolean; expand?: boolean | number; }, - ) { + ): Promise { return window.withProgress( { location: ProgressLocation.Notification, @@ -755,7 +759,7 @@ export class RepositoriesView extends ViewBase<'repositories', RepositoriesNode, focus?: boolean; expand?: boolean | number; }, - ) { + ): Promise { const node = await this.findNode(n => n instanceof TagsNode && n.repoPath === repoPath, { maxDepth: 2, canTraverse: n => { @@ -778,14 +782,14 @@ export class RepositoriesView extends ViewBase<'repositories', RepositoriesNode, } @gate(() => '') - revealWorktree( + async revealWorktree( worktree: GitWorktree, options?: { select?: boolean; focus?: boolean; expand?: boolean | number; }, - ) { + ): Promise { return window.withProgress( { location: ProgressLocation.Notification, @@ -811,7 +815,7 @@ export class RepositoriesView extends ViewBase<'repositories', RepositoriesNode, focus?: boolean; expand?: boolean | number; }, - ) { + ): Promise { const node = await this.findNode(n => n instanceof WorktreesNode && n.repoPath === repoPath, { maxDepth: 2, canTraverse: n => { @@ -873,7 +877,7 @@ export class RepositoriesView extends ViewBase<'repositories', RepositoriesNode, ); } - toggleSection( + async toggleSection( key: | 'showBranches' | 'showCommits' @@ -885,11 +889,11 @@ export class RepositoriesView extends ViewBase<'repositories', RepositoriesNode, | 'showWorktrees' | 'showUpstreamStatus', enabled: boolean, - ) { + ): Promise { return configuration.updateEffective(`views.${this.configKey}.${key}` as const, enabled); } - toggleSectionByNode( + async toggleSectionByNode( node: | BranchesNode | BranchNode @@ -902,7 +906,7 @@ export class RepositoriesView extends ViewBase<'repositories', RepositoriesNode, | TagsNode | WorktreesNode, enabled: boolean, - ) { + ): Promise { if (node instanceof BranchesNode) { return configuration.updateEffective(`views.${this.configKey}.showBranches` as const, enabled); } diff --git a/src/views/scmGroupedView.ts b/src/views/scmGroupedView.ts index f664bd28f1ce3..fda39bf5e9a0d 100644 --- a/src/views/scmGroupedView.ts +++ b/src/views/scmGroupedView.ts @@ -25,11 +25,11 @@ export class ScmGroupedView implements Disposable { this._view = this.setView(this.views.lastSelectedScmGroupedView!); } - dispose() { + dispose(): void { this._view?.dispose(); } - get view() { + get view(): TreeViewByType[GroupableTreeViewTypes] | undefined { return this._view; } diff --git a/src/views/searchAndCompareView.ts b/src/views/searchAndCompareView.ts index f4033023236cc..40e7d0ad5f681 100644 --- a/src/views/searchAndCompareView.ts +++ b/src/views/searchAndCompareView.ts @@ -35,7 +35,7 @@ export class SearchAndCompareViewNode extends ViewNode<'search-compare', SearchA super('search-compare', unknownGitUri, view); } - override dispose() { + override dispose(): void { super.dispose(); disposeChildren(this._children); } @@ -79,7 +79,7 @@ export class SearchAndCompareViewNode extends ViewNode<'search-compare', SearchA return item; } - addOrReplace(results: CompareResultsNode | SearchResultsNode) { + addOrReplace(results: CompareResultsNode | SearchResultsNode): void { const children = [...this.children]; if (children.includes(results)) return; @@ -90,7 +90,7 @@ export class SearchAndCompareViewNode extends ViewNode<'search-compare', SearchA } @log() - async clear() { + async clear(): Promise { if (this.children.length === 0) return; this.removeComparePicker(true); @@ -102,7 +102,7 @@ export class SearchAndCompareViewNode extends ViewNode<'search-compare', SearchA } @log({ args: { 0: n => n.toString() } }) - dismiss(node: ComparePickerNode | CompareResultsNode | SearchResultsNode) { + dismiss(node: ComparePickerNode | CompareResultsNode | SearchResultsNode): void { if (node === this.comparePicker) { this.removeComparePicker(); @@ -127,7 +127,7 @@ export class SearchAndCompareViewNode extends ViewNode<'search-compare', SearchA @gate() @debug() - override async refresh(reset: boolean = false) { + override async refresh(reset: boolean = false): Promise { const children = this.children; if (children.length === 0) return; @@ -139,7 +139,7 @@ export class SearchAndCompareViewNode extends ViewNode<'search-compare', SearchA ); } - async compareWithSelected(repoPath?: string, ref?: string | StoredNamedRef) { + async compareWithSelected(repoPath?: string, ref?: string | StoredNamedRef): Promise { const selectedRef = this.comparePicker?.selectedRef; if (selectedRef == null) return; @@ -181,7 +181,11 @@ export class SearchAndCompareViewNode extends ViewNode<'search-compare', SearchA await this.view.compare(repoPath, selectedRef.ref, ref); } - async selectForCompare(repoPath?: string, ref?: string | StoredNamedRef, options?: { prompt?: boolean }) { + async selectForCompare( + repoPath?: string, + ref?: string | StoredNamedRef, + options?: { prompt?: boolean }, + ): Promise { if (repoPath == null) { repoPath = (await getRepositoryOrShowPicker('Compare'))?.path; } @@ -279,7 +283,7 @@ export class SearchAndCompareView extends ViewBase< return this.container.prereleaseOrDebugging; } - protected getRoot() { + protected getRoot(): SearchAndCompareViewNode { return new SearchAndCompareViewNode(this); } @@ -316,7 +320,7 @@ export class SearchAndCompareView extends ViewBase< ]; } - protected override filterConfigurationChanged(e: ConfigurationChangeEvent) { + protected override filterConfigurationChanged(e: ConfigurationChangeEvent): boolean { const changed = super.filterConfigurationChanged(e); if ( !changed && @@ -334,11 +338,11 @@ export class SearchAndCompareView extends ViewBase< return true; } - clear() { + clear(): Promise | undefined { return this.root?.clear(); } - dismissNode(node: ViewNode) { + dismissNode(node: ViewNode): void { if ( this.root == null || (!(node instanceof ComparePickerNode) && @@ -374,11 +378,11 @@ export class SearchAndCompareView extends ViewBase< ); } - compareWithSelected(repoPath?: string, ref?: string | StoredNamedRef) { + compareWithSelected(repoPath?: string, ref?: string | StoredNamedRef): void { void this.ensureRoot().compareWithSelected(repoPath, ref); } - selectForCompare(repoPath?: string, ref?: string | StoredNamedRef, options?: { prompt?: boolean }) { + selectForCompare(repoPath?: string, ref?: string | StoredNamedRef, options?: { prompt?: boolean }): void { void this.ensureRoot().selectForCompare(repoPath, ref, options); } @@ -403,7 +407,7 @@ export class SearchAndCompareView extends ViewBase< }, results?: Promise | GitLog, updateNode?: SearchResultsNode, - ) { + ): Promise { if (!this.visible) { await this.show({ preserveFocus: reveal?.focus !== true }); } @@ -424,7 +428,7 @@ export class SearchAndCompareView extends ViewBase< ); } - getStoredNodes() { + getStoredNodes(): (CompareResultsNode | SearchResultsNode)[] { const stored = this.container.storage.getWorkspace('views:searchAndCompare:pinned'); if (stored == null) return []; @@ -459,11 +463,11 @@ export class SearchAndCompareView extends ViewBase< return nodes; } - clearStorage() { + clearStorage(): Promise { return this.container.storage.deleteWorkspace('views:searchAndCompare:pinned'); } - async updateStorage(id: string, item?: StoredSearchAndCompareItem, silent: boolean = false) { + async updateStorage(id: string, item?: StoredSearchAndCompareItem, silent: boolean = false): Promise { let stored = this.container.storage.getWorkspace('views:searchAndCompare:pinned'); stored = updateRecordValue(stored, id, item); await this.container.storage.storeWorkspace('views:searchAndCompare:pinned', stored); @@ -477,7 +481,7 @@ export class SearchAndCompareView extends ViewBase< async revealRepository( repoPath: string, options?: { select?: boolean; focus?: boolean; expand?: boolean | number }, - ) { + ): Promise { const node = await this.findNode(n => n instanceof RepositoryFolderNode && n.repoPath === repoPath, { maxDepth: 1, canTraverse: n => n instanceof SearchAndCompareViewNode || n instanceof RepositoryFolderNode, diff --git a/src/views/stashesView.ts b/src/views/stashesView.ts index 0d0199157d533..c88f35bfac17b 100644 --- a/src/views/stashesView.ts +++ b/src/views/stashesView.ts @@ -28,7 +28,7 @@ export class StashesRepositoryNode extends RepositoryFolderNode { const { repoPath } = stash; return this.findNode((n: any) => n.commit?.ref === stash.ref, { @@ -180,7 +180,7 @@ export class StashesView extends ViewBase<'stashes', StashesViewNode, StashesVie async revealRepository( repoPath: string, options?: { select?: boolean; focus?: boolean; expand?: boolean | number }, - ) { + ): Promise { const node = await this.findNode(n => n instanceof RepositoryFolderNode && n.repoPath === repoPath, { maxDepth: 1, canTraverse: n => n instanceof StashesViewNode || n instanceof RepositoryFolderNode, @@ -201,7 +201,7 @@ export class StashesView extends ViewBase<'stashes', StashesViewNode, StashesVie focus?: boolean; expand?: boolean | number; }, - ) { + ): Promise { return window.withProgress( { location: ProgressLocation.Notification, diff --git a/src/views/tagsView.ts b/src/views/tagsView.ts index dc32fd59e1261..835ea93304b81 100644 --- a/src/views/tagsView.ts +++ b/src/views/tagsView.ts @@ -29,7 +29,7 @@ export class TagsRepositoryNode extends RepositoryFolderNode return this.child.getChildren(); } - protected changed(e: RepositoryChangeEvent) { + protected changed(e: RepositoryChangeEvent): boolean { return e.changed(RepositoryChange.Tags, RepositoryChange.Unknown, RepositoryChangeComparisonMode.Any); } } @@ -102,7 +102,7 @@ export class TagsView extends ViewBase<'tags', TagsViewNode, TagsViewConfig> { return this.container.prereleaseOrDebugging; } - protected getRoot() { + protected getRoot(): TagsViewNode { return new TagsViewNode(this); } @@ -143,7 +143,7 @@ export class TagsView extends ViewBase<'tags', TagsViewNode, TagsViewConfig> { ]; } - protected override filterConfigurationChanged(e: ConfigurationChangeEvent) { + protected override filterConfigurationChanged(e: ConfigurationChangeEvent): boolean { const changed = super.filterConfigurationChanged(e); if ( !changed && @@ -164,7 +164,7 @@ export class TagsView extends ViewBase<'tags', TagsViewNode, TagsViewConfig> { return true; } - findTag(tag: GitTagReference, token?: CancellationToken) { + findTag(tag: GitTagReference, token?: CancellationToken): Promise { const { repoPath } = tag; return this.findNode((n: any) => n.tag?.ref === tag.ref, { @@ -187,7 +187,7 @@ export class TagsView extends ViewBase<'tags', TagsViewNode, TagsViewConfig> { async revealRepository( repoPath: string, options?: { select?: boolean; focus?: boolean; expand?: boolean | number }, - ) { + ): Promise { const node = await this.findNode(n => n instanceof RepositoryFolderNode && n.repoPath === repoPath, { maxDepth: 1, canTraverse: n => n instanceof TagsViewNode || n instanceof RepositoryFolderNode, @@ -201,14 +201,14 @@ export class TagsView extends ViewBase<'tags', TagsViewNode, TagsViewConfig> { } @gate(() => '') - revealTag( + async revealTag( tag: GitTagReference, options?: { select?: boolean; focus?: boolean; expand?: boolean | number; }, - ) { + ): Promise { return window.withProgress( { location: ProgressLocation.Notification, diff --git a/src/views/viewBase.ts b/src/views/viewBase.ts index 06f427e1d3213..85e786979f233 100644 --- a/src/views/viewBase.ts +++ b/src/views/viewBase.ts @@ -287,7 +287,7 @@ export abstract class ViewBase< this.disposables.push(...this.registerCommands()); } - dispose() { + dispose(): void { this._disposed = true; this._nodeState?.dispose(); this._nodeState = undefined; @@ -324,7 +324,7 @@ export abstract class ViewBase< return true; } - protected filterConfigurationChanged(e: ConfigurationChangeEvent) { + protected filterConfigurationChanged(e: ConfigurationChangeEvent): boolean { if (!configuration.changed(e, 'views')) return false; if (configuration.changed(e, `views.${this.configKey}` as const)) return true; @@ -382,7 +382,9 @@ export abstract class ViewBase< } } - getQualifiedCommand(command: TreeViewCommandSuffixesByViewType) { + getQualifiedCommand( + command: TreeViewCommandSuffixesByViewType, + ): `gitlens.views.${Type}.${TreeViewCommandSuffixesByViewType}` { return `gitlens.views.${this.type}.${command}` as const; } @@ -394,7 +396,7 @@ export abstract class ViewBase< } } - protected initialize(options: { canSelectMany?: boolean; showCollapseAll?: boolean } = {}) { + protected initialize(options?: { canSelectMany?: boolean; showCollapseAll?: boolean }): void { this.tree = window.createTreeView(this.grouped ? 'gitlens.views.scm.grouped' : this.id, { ...options, treeDataProvider: this, @@ -427,7 +429,7 @@ export abstract class ViewBase< } } - protected ensureRoot(force: boolean = false) { + protected ensureRoot(force: boolean = false): RootNode { if (this.root == null || force) { this.root?.dispose(); this.root = this.getRoot(); @@ -466,7 +468,7 @@ export abstract class ViewBase< return node.getTreeItem(); } - getViewDescription(count?: number) { + getViewDescription(count?: number): string | undefined { return ( `${this.grouped ? `${this.name.toLocaleLowerCase()} ` : ''}${count != null ? `(${count})` : ''}` || undefined @@ -477,15 +479,15 @@ export abstract class ViewBase< return node.resolveTreeItem?.(item, token) ?? item; } - protected onElementCollapsed(e: TreeViewExpansionEvent) { + protected onElementCollapsed(e: TreeViewExpansionEvent): void { this._onDidChangeNodeCollapsibleState.fire({ ...e, state: TreeItemCollapsibleState.Collapsed }); } - protected onElementExpanded(e: TreeViewExpansionEvent) { + protected onElementExpanded(e: TreeViewExpansionEvent): void { this._onDidChangeNodeCollapsibleState.fire({ ...e, state: TreeItemCollapsibleState.Expanded }); } - protected onCheckboxStateChanged(e: TreeCheckboxChangeEvent) { + protected onCheckboxStateChanged(e: TreeCheckboxChangeEvent): void { try { for (const [node, state] of e.items) { if (node.id == null) { @@ -500,12 +502,12 @@ export abstract class ViewBase< } } - protected onSelectionChanged(e: TreeViewSelectionChangeEvent) { + protected onSelectionChanged(e: TreeViewSelectionChangeEvent): void { this._onDidChangeSelection.fire(e); this.notifySelections(); } - protected onVisibilityChanged(e: TreeViewVisibilityChangeEvent) { + protected onVisibilityChanged(e: TreeViewVisibilityChangeEvent): void { if (e.visible) { void this.container.usage.track(`${this.trackingFeature}:shown`).catch(); } @@ -698,7 +700,7 @@ export abstract class ViewBase< focus?: boolean; expand?: boolean | number; }, - ) { + ): Promise { // Not sure why I need to reveal each parent, but without it the node won't be revealed const nodes: ViewNode[] = []; @@ -720,7 +722,7 @@ export abstract class ViewBase< } @debug() - async refresh(reset: boolean = false) { + async refresh(reset: boolean = false): Promise { // If we are resetting, make sure to clear any saved node state if (reset) { this.nodeState.reset(); @@ -732,7 +734,7 @@ export abstract class ViewBase< } @debug['refreshNode']>({ args: { 0: n => n.toString() } }) - async refreshNode(node: ViewNode, reset: boolean = false, force: boolean = false) { + async refreshNode(node: ViewNode, reset: boolean = false, force: boolean = false): Promise { const cancel = await node.refresh?.(reset); if (!force && cancel === true) return; @@ -747,7 +749,7 @@ export abstract class ViewBase< focus?: boolean; expand?: boolean | number; }, - ) { + ): Promise { if (this.tree == null) return; try { @@ -759,7 +761,7 @@ export abstract class ViewBase< } @log() - async show(options?: { preserveFocus?: boolean }) { + async show(options?: { preserveFocus?: boolean }): Promise { const scope = getLogScope(); try { @@ -779,7 +781,7 @@ export abstract class ViewBase< } // @debug({ args: { 0: (n: ViewNode) => n.toString() }, singleLine: true }) - getNodeLastKnownLimit(node: PageableViewNode) { + getNodeLastKnownLimit(node: PageableViewNode): number | undefined { return this._lastKnownLimits.get(node.id); } @@ -791,7 +793,7 @@ export abstract class ViewBase< limit: number | { until: string | undefined } | undefined, previousNode?: ViewNode, context?: Record, - ) { + ): Promise { if (previousNode != null) { await this.reveal(previousNode, { select: true }); } @@ -804,12 +806,12 @@ export abstract class ViewBase< args: { 0: n => n.toString() }, singleLine: true, }) - resetNodeLastKnownLimit(node: PageableViewNode) { + resetNodeLastKnownLimit(node: PageableViewNode): void { this._lastKnownLimits.delete(node.id); } @debug['triggerNodeChange']>({ args: { 0: n => n?.toString() } }) - triggerNodeChange(node?: ViewNode) { + triggerNodeChange(node?: ViewNode): void { // Since the root node won't actually refresh, force everything this._onDidChangeTreeData.fire(node != null && node !== this.root ? node : undefined); } @@ -890,14 +892,14 @@ export class ViewNodeState implements Disposable { private _store: Map> | undefined; private _stickyStore: Map> | undefined; - dispose() { + dispose(): void { this.reset(); this._stickyStore?.clear(); this._stickyStore = undefined; } - reset() { + reset(): void { this._store?.clear(); this._store = undefined; } @@ -979,7 +981,7 @@ export class ViewNodeState implements Disposable { } } -export function disposeChildren(oldChildren: ViewNode[] | undefined, newChildren?: ViewNode[]) { +export function disposeChildren(oldChildren: ViewNode[] | undefined, newChildren?: ViewNode[]): void { if (!oldChildren?.length) return; const children = newChildren?.length ? oldChildren.filter(c => !newChildren.includes(c)) : [...oldChildren]; diff --git a/src/views/viewCommands.ts b/src/views/viewCommands.ts index c865dc582279a..25308b75c510b 100644 --- a/src/views/viewCommands.ts +++ b/src/views/viewCommands.ts @@ -452,7 +452,7 @@ export class ViewCommands implements Disposable { ); } - dispose() { + dispose(): void { this._disposable.dispose(); } diff --git a/src/views/views.ts b/src/views/views.ts index 6ff50f6e513a9..215de8cc6dbce 100644 --- a/src/views/views.ts +++ b/src/views/views.ts @@ -33,6 +33,7 @@ import { DraftsView } from './draftsView'; import { FileHistoryView } from './fileHistoryView'; import { LaunchpadView } from './launchpadView'; import { LineHistoryView } from './lineHistoryView'; +import type { ViewNode } from './nodes/abstract/viewNode'; import { PullRequestView } from './pullRequestView'; import { RemotesView } from './remotesView'; import { RepositoriesView } from './repositoriesView'; @@ -62,7 +63,7 @@ export class Views implements Disposable { private readonly _disposable: Disposable; private _lastSelectedScmGroupedView: GroupableTreeViewTypes | undefined; - get lastSelectedScmGroupedView() { + get lastSelectedScmGroupedView(): GroupableTreeViewTypes | undefined { if (!this._scmGroupedViews?.size) return undefined; if (!this._lastSelectedScmGroupedView || !this._scmGroupedViews.has(this._lastSelectedScmGroupedView)) { @@ -79,7 +80,7 @@ export class Views implements Disposable { private _scmGroupedView: ScmGroupedView | undefined; private _scmGroupedViews: Set | undefined; - get scmGroupedViews() { + get scmGroupedViews(): Set | undefined { return this._scmGroupedViews; } @@ -128,7 +129,7 @@ export class Views implements Disposable { } } - dispose() { + dispose(): void { this._scmGroupedView?.dispose(); this._branchesView?.dispose(); this._commitsView?.dispose(); @@ -564,7 +565,7 @@ export class Views implements Disposable { } private _commitDetailsView!: ReturnType; - get commitDetails() { + get commitDetails(): ReturnType { return this._commitDetailsView; } @@ -584,17 +585,17 @@ export class Views implements Disposable { } private _graphView!: ReturnType; - get graph() { + get graph(): ReturnType { return this._graphView; } private _graphDetailsView!: ReturnType; - get graphDetails() { + get graphDetails(): ReturnType { return this._graphDetailsView; } private _homeView!: ReturnType; - get home() { + get home(): ReturnType { return this._homeView; } @@ -609,7 +610,7 @@ export class Views implements Disposable { // } private _patchDetailsView!: ReturnType; - get patchDetails() { + get patchDetails(): ReturnType { return this._patchDetailsView; } @@ -644,7 +645,7 @@ export class Views implements Disposable { } private _timelineView!: ReturnType; - get timeline() { + get timeline(): ReturnType { return this._timelineView; } @@ -665,7 +666,7 @@ export class Views implements Disposable { focus?: boolean; expand?: boolean | number; }, - ) { + ): Promise { const branches = branch.remote ? this.remotes : this.branches; const view = branches.canReveal ? branches : this.repositories; @@ -681,7 +682,7 @@ export class Views implements Disposable { focus?: boolean; expand?: boolean | number; }, - ) { + ): Promise { const { commits } = this; const view = commits.canReveal ? commits : this.repositories; @@ -697,7 +698,7 @@ export class Views implements Disposable { focus?: boolean; expand?: boolean | number; }, - ) { + ): Promise { const { contributors } = this; const view = contributors.canReveal ? contributors : this.repositories; @@ -713,7 +714,7 @@ export class Views implements Disposable { focus?: boolean; expand?: boolean | number; }, - ) { + ): Promise { const { remotes } = this; const view = remotes.canReveal ? remotes : this.repositories; @@ -730,7 +731,7 @@ export class Views implements Disposable { focus?: boolean; expand?: boolean | number; }, - ) { + ): Promise { const view = useView == null || useView.canReveal === false ? this.repositories : useView; const node = await view.revealRepository(repoPath, options); @@ -745,7 +746,7 @@ export class Views implements Disposable { focus?: boolean; expand?: boolean | number; }, - ) { + ): Promise { const { stashes } = this; const view = stashes.canReveal ? stashes : this.repositories; @@ -761,7 +762,7 @@ export class Views implements Disposable { focus?: boolean; expand?: boolean | number; }, - ) { + ): Promise { const { tags } = this; const view = tags.canReveal ? tags : this.repositories; @@ -777,7 +778,7 @@ export class Views implements Disposable { focus?: boolean; expand?: boolean | number; }, - ) { + ): Promise { const { worktrees } = this; const view = worktrees.canReveal ? worktrees : this.repositories; diff --git a/src/views/workspacesView.ts b/src/views/workspacesView.ts index ce28072392f16..607e64a2fa051 100644 --- a/src/views/workspacesView.ts +++ b/src/views/workspacesView.ts @@ -72,7 +72,7 @@ export class WorkspacesViewNode extends ViewNode<'workspaces', WorkspacesView> { @gate() @debug() - override refresh() { + override refresh(): void { if (this._children == null) return; disposeChildren(this._children); @@ -91,12 +91,12 @@ export class WorkspacesView extends ViewBase<'workspaces', WorkspacesViewNode, W this.disposables.push(container.workspaces.onDidResetWorkspaces(() => void this.refresh(true))); } - override dispose() { + override dispose(): void { this._disposable?.dispose(); super.dispose(); } - protected getRoot() { + protected getRoot(): WorkspacesViewNode { return new WorkspacesViewNode(this); } @@ -105,7 +105,7 @@ export class WorkspacesView extends ViewBase<'workspaces', WorkspacesViewNode, W return super.show(options); } - async findWorkspaceNode(workspaceId: string, token?: CancellationToken) { + async findWorkspaceNode(workspaceId: string, token?: CancellationToken): Promise { return this.findNode((n: any) => n.workspace?.id === workspaceId, { allowPaging: false, maxDepth: 2, @@ -125,7 +125,7 @@ export class WorkspacesView extends ViewBase<'workspaces', WorkspacesViewNode, W focus?: boolean; expand?: boolean | number; }, - ) { + ): Promise { return window.withProgress( { location: ProgressLocation.Notification, @@ -313,7 +313,7 @@ export class WorkspacesView extends ViewBase<'workspaces', WorkspacesViewNode, W ]; } - protected override filterConfigurationChanged(e: ConfigurationChangeEvent) { + protected override filterConfigurationChanged(e: ConfigurationChangeEvent): boolean { const changed = super.filterConfigurationChanged(e); if ( !changed && diff --git a/src/views/worktreesView.ts b/src/views/worktreesView.ts index bddaae3d2eb2f..7702ec6ba47aa 100644 --- a/src/views/worktreesView.ts +++ b/src/views/worktreesView.ts @@ -31,7 +31,7 @@ export class WorktreesRepositoryNode extends RepositoryFolderNode { const { repoPath, uri } = worktree; const url = uri.toString(); @@ -236,7 +236,7 @@ export class WorktreesView extends ViewBase<'worktrees', WorktreesViewNode, Work async revealRepository( repoPath: string, options?: { select?: boolean; focus?: boolean; expand?: boolean | number }, - ) { + ): Promise { const node = await this.findNode(n => n instanceof RepositoryFolderNode && n.repoPath === repoPath, { maxDepth: 1, canTraverse: n => n instanceof WorktreesViewNode || n instanceof RepositoryFolderNode, @@ -250,14 +250,14 @@ export class WorktreesView extends ViewBase<'worktrees', WorktreesViewNode, Work } @gate(() => '') - revealWorktree( + async revealWorktree( worktree: GitWorktree, options?: { select?: boolean; focus?: boolean; expand?: boolean | number; }, - ) { + ): Promise { return window.withProgress( { location: ProgressLocation.Notification, diff --git a/src/vsls/guest.ts b/src/vsls/guest.ts index e4537bf309824..dc44ca8ee2c8d 100644 --- a/src/vsls/guest.ts +++ b/src/vsls/guest.ts @@ -12,7 +12,7 @@ import { GetRepositoriesForUriRequestType, GitCommandRequestType, GitLogStreamTo export class VslsGuestService implements Disposable { @log() - static async connect(api: LiveShare, container: Container) { + static async connect(api: LiveShare, container: Container): Promise { const scope = getLogScope(); try { @@ -37,7 +37,7 @@ export class VslsGuestService implements Disposable { this.onAvailabilityChanged(_service.isServiceAvailable); } - dispose() { + dispose(): void { // nothing to dispose } diff --git a/src/vsls/host.ts b/src/vsls/host.ts index a129abd9a7807..1b29c06cd9628 100644 --- a/src/vsls/host.ts +++ b/src/vsls/host.ts @@ -55,7 +55,7 @@ export class VslsHostService implements Disposable { static ServiceId = 'proxy'; @log() - static async share(api: LiveShare, container: Container) { + static async share(api: LiveShare, container: Container): Promise { const service = await api.shareService(this.ServiceId); if (service == null) { throw new Error('Failed to share host service'); @@ -86,7 +86,7 @@ export class VslsHostService implements Disposable { this.onWorkspaceFoldersChanged(); } - dispose() { + dispose(): void { this._disposable.dispose(); void this._api.unshareService(VslsHostService.ServiceId); } diff --git a/src/vsls/vsls.ts b/src/vsls/vsls.ts index ca7272487ec47..41900bad8e195 100644 --- a/src/vsls/vsls.ts +++ b/src/vsls/vsls.ts @@ -1,6 +1,6 @@ -import type { ConfigurationChangeEvent, Extension } from 'vscode'; +import type { ConfigurationChangeEvent, Extension, Uri } from 'vscode'; import { Disposable, extensions, workspace } from 'vscode'; -import type { LiveShare, LiveShareExtension, SessionChangeEvent } from '../@types/vsls'; +import type { Contact, LiveShare, LiveShareExtension, SessionChangeEvent } from '../@types/vsls'; import { Schemes } from '../constants'; import type { Container } from '../container'; import { configuration } from '../system/-webview/configuration'; @@ -49,7 +49,7 @@ export class VslsController implements Disposable { ); } - dispose() { + dispose(): void { this._ready.fulfill(); this._disposable.dispose(); @@ -160,16 +160,16 @@ export class VslsController implements Disposable { return extensions.getExtension('ms-vsliveshare.vsliveshare'); } - get active() { + get active(): boolean | undefined { return configuration.get('liveshare.enabled') && this.getLiveShareExtension()?.isActive; } - get enabled() { + get enabled(): boolean { return configuration.get('liveshare.enabled'); } private _readonly: boolean = false; - get readonly() { + get readonly(): boolean { return this._readonly; } private setReadonly(value: boolean) { @@ -177,7 +177,7 @@ export class VslsController implements Disposable { void setContext('gitlens:readonly', value ? true : undefined); } - async guest() { + async guest(): Promise { if (this._guest != null) return this._guest; await this._ready.promise; @@ -185,7 +185,7 @@ export class VslsController implements Disposable { } @debug() - async getContact(email: string | undefined) { + async getContact(email: string | undefined): Promise { if (email == null) return undefined; const api = await this._api; @@ -222,7 +222,7 @@ export class VslsController implements Disposable { ); } - async invite(email: string | undefined) { + async invite(email: string | undefined): Promise { if (email == null) return undefined; const contact = await this.getContact(email); @@ -231,7 +231,7 @@ export class VslsController implements Disposable { return contact.invite(); } - async startSession() { + async startSession(): Promise { const api = await this._api; if (api == null) return undefined; diff --git a/src/webviews/apps/commitDetails/commitDetails.ts b/src/webviews/apps/commitDetails/commitDetails.ts index a75e3a008fb02..3b0f4fba5002d 100644 --- a/src/webviews/apps/commitDetails/commitDetails.ts +++ b/src/webviews/apps/commitDetails/commitDetails.ts @@ -13,7 +13,7 @@ export class CommitDetailsApp extends App> { super('CommitDetailsApp'); } - override onInitialize() { + override onInitialize(): void { const component = document.getElementById('app') as GlCommitDetailsApp; component.state = this.state; DOM.on>(component, 'state-changed', e => { diff --git a/src/webviews/apps/commitDetails/components/commit-details-app.ts b/src/webviews/apps/commitDetails/components/commit-details-app.ts index f17635d1df81a..6d435a9f119dd 100644 --- a/src/webviews/apps/commitDetails/components/commit-details-app.ts +++ b/src/webviews/apps/commitDetails/components/commit-details-app.ts @@ -48,8 +48,8 @@ import { ExecuteCommand } from '../../../protocol'; import type { CreatePatchMetadataEventDetail } from '../../plus/patchDetails/components/gl-patch-create'; import type { IssuePullRequest } from '../../shared/components/rich/issue-pull-request'; import type { WebviewPane, WebviewPaneExpandedChangeEventDetail } from '../../shared/components/webview-pane'; -import type { Disposable } from '../../shared/dom'; import { DOM } from '../../shared/dom'; +import type { Disposable } from '../../shared/events'; import { assertsSerialized, HostIpc } from '../../shared/ipc'; import type { GlCommitDetails } from './gl-commit-details'; import type { FileChangeListItemDetail } from './gl-details-base'; @@ -88,16 +88,16 @@ export class GlCommitDetailsApp extends LitElement { draftState: DraftState = { inReview: false }; @state() - get isUncommitted() { + get isUncommitted(): boolean { return this.state?.commit?.sha === uncommittedSha; } - get hasCommit() { + get hasCommit(): boolean { return this.state?.commit != null; } @state() - get isStash() { + get isStash(): boolean { return this.state?.commit?.stashNumber != null; } @@ -181,7 +181,7 @@ export class GlCommitDetailsApp extends LitElement { rootStyle.setProperty('--gitlens-tree-indent', `${this.indentPreference}px`); } - override updated(changedProperties: Map) { + override updated(changedProperties: Map): void { if (changedProperties.has('state')) { this.updateDocumentProperties(); if (this.state?.inReview != null && this.state.inReview !== this.draftState.inReview) { @@ -190,7 +190,7 @@ export class GlCommitDetailsApp extends LitElement { } } - override connectedCallback() { + override connectedCallback(): void { super.connectedCallback(); this._hostIpc = new HostIpc('commit-details'); @@ -350,14 +350,14 @@ export class GlCommitDetailsApp extends LitElement { } } - override disconnectedCallback() { + override disconnectedCallback(): void { this._disposables.forEach(d => d.dispose()); this._disposables = []; super.disconnectedCallback(); } - renderTopInspect() { + private renderTopInspect() { if (this.state?.commit == null) return nothing; return html``; } - renderTopWip() { + private renderTopWip() { if (this.state?.wip == null) return nothing; return html``; @@ -404,7 +404,7 @@ export class GlCommitDetailsApp extends LitElement { // )} } - renderWipTooltipContent() { + private renderWipTooltipContent() { if (this.wipStatus == null) return 'Overview'; return html` @@ -444,7 +444,7 @@ export class GlCommitDetailsApp extends LitElement { `; } - renderTopSection() { + private renderTopSection() { const isWip = this.state?.mode === 'wip'; return html` @@ -492,7 +492,7 @@ export class GlCommitDetailsApp extends LitElement { `; } - override render() { + override render(): unknown { const wip = this.state?.wip; return html` @@ -529,7 +529,7 @@ export class GlCommitDetailsApp extends LitElement { `; } - protected override createRenderRoot() { + protected override createRenderRoot(): HTMLElement { return this; } @@ -595,7 +595,7 @@ export class GlCommitDetailsApp extends LitElement { this.onCommandClickedCore('gitlens.switchAIModel'); } - async onExplainCommit(_e: MouseEvent) { + private async onExplainCommit(_e: MouseEvent) { try { const result = await this._hostIpc.sendRequest(ExplainRequest, undefined); if (result.error) { diff --git a/src/webviews/apps/commitDetails/components/gl-commit-details.ts b/src/webviews/apps/commitDetails/components/gl-commit-details.ts index b8e9795eae4f1..d285304110ae8 100644 --- a/src/webviews/apps/commitDetails/components/gl-commit-details.ts +++ b/src/webviews/apps/commitDetails/components/gl-commit-details.ts @@ -44,12 +44,12 @@ export class GlCommitDetails extends GlDetailsBase { state?: Serialized; @state() - get isStash() { + get isStash(): boolean { return this.state?.commit?.stashNumber != null; } @state() - get shortSha() { + get shortSha(): string { return this.state?.commit?.shortSha ?? ''; } @@ -86,7 +86,7 @@ export class GlCommitDetails extends GlDetailsBase { return actions; } - override updated(changedProperties: Map) { + override updated(changedProperties: Map): void { if (changedProperties.has('explain')) { this.explainBusy = false; this.querySelector('[data-region="commit-explanation"]')?.scrollIntoView(); @@ -474,7 +474,7 @@ export class GlCommitDetails extends GlDetailsBase { `; } - override render() { + override render(): unknown { if (this.state?.commit == null) { return this.renderEmptyContent(); } @@ -492,7 +492,7 @@ export class GlCommitDetails extends GlDetailsBase { `; } - onExplainChanges(e: MouseEvent | KeyboardEvent) { + private onExplainChanges(e: MouseEvent | KeyboardEvent) { if (this.explainBusy === true || (e instanceof KeyboardEvent && e.key !== 'Enter')) { e.preventDefault(); e.stopPropagation(); diff --git a/src/webviews/apps/commitDetails/components/gl-details-base.ts b/src/webviews/apps/commitDetails/components/gl-details-base.ts index af38e6f9f73d9..29735cbfcb035 100644 --- a/src/webviews/apps/commitDetails/components/gl-details-base.ts +++ b/src/webviews/apps/commitDetails/components/gl-details-base.ts @@ -3,6 +3,7 @@ import { html, LitElement } from 'lit'; import { property } from 'lit/decorators.js'; import { when } from 'lit/directives/when.js'; import type { TextDocumentShowOptions } from 'vscode'; +import type { ViewFilesLayout } from '../../../../config'; import type { HierarchicalItem } from '../../../../system/array'; import { makeHierarchical } from '../../../../system/array'; import { pluralize } from '../../../../system/string'; @@ -46,11 +47,11 @@ export class GlDetailsBase extends LitElement { @property({ attribute: 'empty-text' }) emptyText? = 'No Files'; - get fileLayout() { + get fileLayout(): ViewFilesLayout { return this.preferences?.files?.layout ?? 'auto'; } - get isCompact() { + get isCompact(): boolean { return this.preferences?.files?.compact ?? true; } @@ -58,13 +59,13 @@ export class GlDetailsBase extends LitElement { return this.preferences?.indentGuides ?? 'none'; } - get filesChangedPaneLabel() { + get filesChangedPaneLabel(): string { const fileCount = this.files?.length ?? 0; const filesLabel = fileCount > 0 ? pluralize('file', fileCount) : 'Files'; return `${filesLabel} changed`; } - protected renderChangedFiles(mode: Mode, subtitle?: TemplateResult<1>) { + protected renderChangedFiles(mode: Mode, subtitle?: TemplateResult<1>): TemplateResult<1> { const fileCount = this.files?.length ?? 0; const isTree = this.isTree(fileCount); let value = 'tree'; @@ -120,7 +121,7 @@ export class GlDetailsBase extends LitElement { `; } - protected onShareWipChanges(_e: Event, staged: boolean, hasFiles: boolean) { + protected onShareWipChanges(_e: Event, staged: boolean, hasFiles: boolean): void { if (!hasFiles) return; const event = new CustomEvent('share-wip', { detail: { @@ -130,12 +131,12 @@ export class GlDetailsBase extends LitElement { this.dispatchEvent(event); } - protected override createRenderRoot() { + protected override createRenderRoot(): HTMLElement { return this; } // Tree Model changes - protected isTree(count: number) { + protected isTree(count: number): boolean { if (this.fileLayout === 'auto') { return count > (this.preferences?.files?.threshold ?? 5); } @@ -361,7 +362,7 @@ export class GlDetailsBase extends LitElement { }; } - protected renderTreeFileModel(treeModel: TreeModel[]) { + protected renderTreeFileModel(treeModel: TreeModel[]): TemplateResult<1> { return html`): void; - protected onTreeItemActionClicked(e: CustomEvent) { + protected onTreeItemActionClicked(e: CustomEvent): void { if (!e.detail.context || !e.detail.action) return; const action = e.detail.action; @@ -410,12 +411,13 @@ export class GlDetailsBase extends LitElement { protected onTreeItemChecked?(_e: CustomEvent): void; // protected onTreeItemSelected?(_e: CustomEvent): void; - protected onTreeItemSelected(e: CustomEvent) { + protected onTreeItemSelected(e: CustomEvent): void { if (!e.detail.context) return; this.onComparePrevious(e); } - onCreatePatch(_e: CustomEvent, isAll = false) { + + private onCreatePatch(_e: CustomEvent, isAll = false) { const event = new CustomEvent('create-patch', { detail: { checked: isAll ? true : 'staged', @@ -423,7 +425,8 @@ export class GlDetailsBase extends LitElement { }); this.dispatchEvent(event); } - onOpenFile(e: CustomEvent) { + + private onOpenFile(e: CustomEvent) { if (!e.detail.context) return; const [file] = e.detail.context; @@ -436,7 +439,7 @@ export class GlDetailsBase extends LitElement { this.dispatchEvent(event); } - onOpenFileOnRemote(e: CustomEvent) { + private onOpenFileOnRemote(e: CustomEvent) { if (!e.detail.context) return; const [file] = e.detail.context; @@ -449,7 +452,7 @@ export class GlDetailsBase extends LitElement { this.dispatchEvent(event); } - onCompareWorking(e: CustomEvent) { + private onCompareWorking(e: CustomEvent) { if (!e.detail.context) return; const [file] = e.detail.context; @@ -462,7 +465,7 @@ export class GlDetailsBase extends LitElement { this.dispatchEvent(event); } - onComparePrevious(e: CustomEvent) { + private onComparePrevious(e: CustomEvent) { if (!e.detail.context) return; const [file] = e.detail.context; @@ -475,7 +478,7 @@ export class GlDetailsBase extends LitElement { this.dispatchEvent(event); } - onMoreActions(e: CustomEvent) { + private onMoreActions(e: CustomEvent) { if (!e.detail.context) return; const [file] = e.detail.context; @@ -485,7 +488,7 @@ export class GlDetailsBase extends LitElement { this.dispatchEvent(event); } - onStageFile(e: CustomEvent) { + private onStageFile(e: CustomEvent) { if (!e.detail.context) return; const [file] = e.detail.context; @@ -498,7 +501,7 @@ export class GlDetailsBase extends LitElement { this.dispatchEvent(event); } - onUnstageFile(e: CustomEvent) { + private onUnstageFile(e: CustomEvent) { if (!e.detail.context) return; const [file] = e.detail.context; diff --git a/src/webviews/apps/commitDetails/components/gl-inspect-nav.ts b/src/webviews/apps/commitDetails/components/gl-inspect-nav.ts index e0023c30bb9c3..7d17c10897134 100644 --- a/src/webviews/apps/commitDetails/components/gl-inspect-nav.ts +++ b/src/webviews/apps/commitDetails/components/gl-inspect-nav.ts @@ -90,7 +90,7 @@ export class GlInspectNav extends LitElement { return actions; } - handleAction(e: Event) { + private handleAction(e: Event) { const targetEl = e.target as HTMLElement; const action = targetEl.dataset.action; if (action == null) return; @@ -103,11 +103,11 @@ export class GlInspectNav extends LitElement { } } - fireEvent(type: string, detail?: Record) { + private fireEvent(type: string, detail?: Record) { this.dispatchEvent(new CustomEvent(`gl-${type}`, { detail: detail })); } - override render() { + override render(): unknown { const pinLabel = this.pinned ? html`Unpin this Commit
Restores Automatic Following` : html`Pin this Commit
Suspends Automatic Following`; diff --git a/src/webviews/apps/commitDetails/components/gl-inspect-patch.ts b/src/webviews/apps/commitDetails/components/gl-inspect-patch.ts index 4174ed44896c6..9025b973a41f3 100644 --- a/src/webviews/apps/commitDetails/components/gl-inspect-patch.ts +++ b/src/webviews/apps/commitDetails/components/gl-inspect-patch.ts @@ -308,7 +308,7 @@ export class InspectPatch extends GlElement { }; } - override render() { + override render(): unknown { return html``; } - renderPrimaryAction() { + private renderPrimaryAction() { const canShare = this.draftsEnabled; if (this.isUnpublished && canShare) { return html`

@@ -221,7 +221,7 @@ export class GlWipDetails extends GlDetailsBase {

`; } - renderActions() { + private renderActions() { const primaryAction = this.renderPrimaryAction(); const secondaryAction = this.renderSecondaryAction(); if (primaryAction == null && secondaryAction == null) return nothing; @@ -229,7 +229,7 @@ export class GlWipDetails extends GlDetailsBase { return html`
${primaryAction}${secondaryAction}
`; } - renderSuggestedChanges() { + private renderSuggestedChanges() { if (this.codeSuggestions.length === 0) return nothing; // src="${this.issue!.author.avatarUrl}" // title="${this.issue!.author.name} (author)" @@ -264,7 +264,7 @@ export class GlWipDetails extends GlDetailsBase { `; } - renderPullRequest() { + private renderPullRequest() { if (this.wip?.pullRequest == null) return nothing; return html` @@ -310,7 +310,7 @@ export class GlWipDetails extends GlDetailsBase { `; } - renderIncomingOutgoing() { + private renderIncomingOutgoing() { if (this.branchState == null || (this.branchState.ahead === 0 && this.branchState.behind === 0)) return nothing; return html` @@ -332,7 +332,7 @@ export class GlWipDetails extends GlDetailsBase { `; } - renderPatchCreation() { + private renderPatchCreation() { if (!this.inReview) return nothing; return html``; } - override render() { + override render(): unknown { if (this.wip == null) return nothing; return html` @@ -372,15 +372,15 @@ export class GlWipDetails extends GlDetailsBase { return [openFile, { icon: 'plus', label: 'Stage changes', action: 'file-stage' }]; } - onDataActionClick(name: string) { + private onDataActionClick(name: string) { void this.dispatchEvent(new CustomEvent('data-action', { detail: { name: name } })); } - onToggleReviewMode(inReview: boolean) { + private onToggleReviewMode(inReview: boolean) { this.dispatchEvent(new CustomEvent('draft-state-changed', { detail: { inReview: inReview } })); } - onShowCodeSuggestion(id: string) { + private onShowCodeSuggestion(id: string) { this.dispatchEvent(new CustomEvent('gl-show-code-suggestion', { detail: { id: id } })); } } diff --git a/src/webviews/apps/home/components/feature-nav.ts b/src/webviews/apps/home/components/feature-nav.ts index 3f89e426e0447..33e84a04f68f1 100644 --- a/src/webviews/apps/home/components/feature-nav.ts +++ b/src/webviews/apps/home/components/feature-nav.ts @@ -23,7 +23,7 @@ export class GlFeatureNav extends GlElement { @state() private _state!: State; - get orgAllowsDrafts() { + get orgAllowsDrafts(): boolean { return this._state.orgSettings.drafts; } @@ -46,7 +46,7 @@ export class GlFeatureNav extends GlElement { return true; } - override render() { + override render(): unknown { return html` ${when( this.blockRepoFeatures, diff --git a/src/webviews/apps/home/components/integration-banner.ts b/src/webviews/apps/home/components/integration-banner.ts index d2b1113ad02a7..d157746b56029 100644 --- a/src/webviews/apps/home/components/integration-banner.ts +++ b/src/webviews/apps/home/components/integration-banner.ts @@ -42,7 +42,7 @@ export class GlIntegrationBanner extends LitElement { @query('gl-button') private _button!: GlButton; - override render() { + override render(): unknown { if (this.closed || this._state.hasAnyIntegrationConnected || this._state.integrationBannerCollapsed) { return nothing; } @@ -78,7 +78,7 @@ export class GlIntegrationBanner extends LitElement { }); } - override focus() { + override focus(): void { this._button.focus(); } } diff --git a/src/webviews/apps/home/components/onboarding.ts b/src/webviews/apps/home/components/onboarding.ts index 484f90a379902..ecf08df120c1e 100644 --- a/src/webviews/apps/home/components/onboarding.ts +++ b/src/webviews/apps/home/components/onboarding.ts @@ -30,7 +30,7 @@ export class GlOnboarding extends LitElement { @query('#open-walkthrough') private _openWalkthroughButton!: GlButton; - override render() { + override render(): unknown { if (!this._state.showWalkthroughProgress) { return undefined; } diff --git a/src/webviews/apps/home/components/preview-banner.ts b/src/webviews/apps/home/components/preview-banner.ts index e188a83d37170..f87108bca7ba2 100644 --- a/src/webviews/apps/home/components/preview-banner.ts +++ b/src/webviews/apps/home/components/preview-banner.ts @@ -76,11 +76,11 @@ export class GlPreviewBanner extends LitElement { @query('button') private _button!: HTMLButtonElement; - get isNewInstall() { + get isNewInstall(): boolean { return this._state.newInstall; } - override render() { + override render(): unknown { if (this._state.previewEnabled !== true) { return html` @@ -132,7 +132,7 @@ export class GlPreviewBanner extends LitElement { }); } - override focus() { + override focus(): void { this._button?.focus(); } } diff --git a/src/webviews/apps/home/components/promo-banner.ts b/src/webviews/apps/home/components/promo-banner.ts index 7dd3908d13672..70f4c4552bd12 100644 --- a/src/webviews/apps/home/components/promo-banner.ts +++ b/src/webviews/apps/home/components/promo-banner.ts @@ -1,6 +1,7 @@ import { consume } from '@lit/context'; import { css, html, LitElement, nothing } from 'lit'; import { customElement, property, state } from 'lit/decorators.js'; +import type { Promo } from '../../../../plus/gk/models/promo'; import { getApplicablePromo } from '../../../../plus/gk/utils/promo.utils'; import type { State } from '../../../home/protocol'; import { stateContext } from '../context'; @@ -32,15 +33,15 @@ export class GlPromoBanner extends LitElement { private _state!: State; @property({ type: Boolean, reflect: true, attribute: 'has-promo' }) - get hasPromos() { + get hasPromos(): boolean | undefined { return this.promo == null ? undefined : true; } - get promo() { + get promo(): Promo | undefined { return getApplicablePromo(this._state.subscription.state, 'home'); } - override render() { + override render(): unknown { if (!this.promo) { return nothing; } diff --git a/src/webviews/apps/home/components/repo-alerts.ts b/src/webviews/apps/home/components/repo-alerts.ts index 5fe598d8787ae..0f9535213b658 100644 --- a/src/webviews/apps/home/components/repo-alerts.ts +++ b/src/webviews/apps/home/components/repo-alerts.ts @@ -39,7 +39,7 @@ export class GlRepoAlerts extends GlElement { ]; @property({ type: Boolean, reflect: true, attribute: 'has-alerts' }) - get hasAlerts() { + get hasAlerts(): boolean | undefined { return this.alertVisibility.header !== true ? undefined : true; } @@ -72,7 +72,7 @@ export class GlRepoAlerts extends GlElement { return sections; } - override render() { + override render(): unknown { if (this._state == null || !this.alertVisibility.header) { return; } diff --git a/src/webviews/apps/home/home.ts b/src/webviews/apps/home/home.ts index 1dc578e1cd7fd..6454ea7a9d31f 100644 --- a/src/webviews/apps/home/home.ts +++ b/src/webviews/apps/home/home.ts @@ -35,7 +35,7 @@ export class GlHomeApp extends GlApp { private badgeSource = { source: 'home', detail: 'badge' }; - protected override createStateProvider(state: State, ipc: HostIpc) { + protected override createStateProvider(state: State, ipc: HostIpc): HomeStateProvider { this.disposables.push((this._overviewState = new OverviewState(ipc))); return new HomeStateProvider(this, state, ipc); @@ -55,7 +55,7 @@ export class GlHomeApp extends GlApp { ); } - override render() { + override render(): unknown { return html`
diff --git a/src/webviews/apps/home/stateProvider.ts b/src/webviews/apps/home/stateProvider.ts index 83619e2e4bf4a..b2561dbaaddaf 100644 --- a/src/webviews/apps/home/stateProvider.ts +++ b/src/webviews/apps/home/stateProvider.ts @@ -22,7 +22,7 @@ export class HomeStateProvider implements StateProvider { private readonly provider: ContextProvider<{ __context__: State }, ReactiveElementHost>; private readonly _state: State; - get state() { + get state(): State { return this._state; } @@ -90,7 +90,7 @@ export class HomeStateProvider implements StateProvider { }); } - dispose() { + dispose(): void { this.disposable.dispose(); } } diff --git a/src/webviews/apps/plus/graph/GraphWrapper.tsx b/src/webviews/apps/plus/graph/GraphWrapper.tsx index 0e6bf53d4b8b2..2699ab38a890e 100644 --- a/src/webviews/apps/plus/graph/GraphWrapper.tsx +++ b/src/webviews/apps/plus/graph/GraphWrapper.tsx @@ -266,7 +266,7 @@ export function GraphWrapper({ onSearch, onSearchPromise, onSearchOpenInView, -}: GraphWrapperProps) { +}: GraphWrapperProps): React.JSX.Element { const graphRef = useRef(null); const [rows, setRows] = useState(state.rows ?? []); diff --git a/src/webviews/apps/plus/graph/actions/fetchButton.tsx b/src/webviews/apps/plus/graph/actions/fetchButton.tsx index d469f2194b69b..7d64911fb6508 100644 --- a/src/webviews/apps/plus/graph/actions/fetchButton.tsx +++ b/src/webviews/apps/plus/graph/actions/fetchButton.tsx @@ -15,7 +15,7 @@ export const FetchButton = ({ state: State; fetchedText: string | undefined; remote: ReactNode; -}) => { +}): React.JSX.Element => { return ( { +}): React.JSX.Element => { const remote = branchState?.upstream ? {branchState?.upstream} : 'remote'; const lastFetchedDate = lastFetched && new Date(lastFetched); diff --git a/src/webviews/apps/plus/graph/actions/pushPullButton.tsx b/src/webviews/apps/plus/graph/actions/pushPullButton.tsx index d8a4afb435002..110b481d87bc4 100644 --- a/src/webviews/apps/plus/graph/actions/pushPullButton.tsx +++ b/src/webviews/apps/plus/graph/actions/pushPullButton.tsx @@ -18,7 +18,7 @@ export const PushPullButton = ({ fetchedText: string | undefined; branchName: string | undefined; remote: ReactNode; -}) => { +}): React.JSX.Element | null => { let isBehind = false; let isAhead = false; if (branchState) { diff --git a/src/webviews/apps/plus/graph/graph.tsx b/src/webviews/apps/plus/graph/graph.tsx index c59789943ef20..cccda8ee1d245 100644 --- a/src/webviews/apps/plus/graph/graph.tsx +++ b/src/webviews/apps/plus/graph/graph.tsx @@ -63,6 +63,7 @@ import { import type { IpcMessage, IpcNotification } from '../../../protocol'; import { DidChangeHostWindowFocusNotification } from '../../../protocol'; import { App } from '../../shared/appBase'; +import type { Disposable } from '../../shared/events'; import type { ThemeChangeEvent } from '../../shared/theme'; import { GraphWrapper } from './GraphWrapper'; import './graph.scss'; @@ -88,7 +89,7 @@ export class GraphApp extends App { } @log() - protected override onBind() { + protected override onBind(): Disposable[] { const disposables = super.onBind?.() ?? []; // disposables.push(DOM.on(window, 'keyup', e => this.onKeyUp(e))); @@ -149,7 +150,7 @@ export class GraphApp extends App { // } // } - protected override onMessageReceived(msg: IpcMessage) { + protected override onMessageReceived(msg: IpcMessage): void { const scope = getLogScope(); switch (true) { @@ -327,7 +328,7 @@ export class GraphApp extends App { } } - protected override onThemeUpdated(e: ThemeChangeEvent) { + protected override onThemeUpdated(e: ThemeChangeEvent): void { const rootStyle = document.documentElement.style; const backgroundColor = Color.from(e.colors.background); @@ -425,7 +426,7 @@ export class GraphApp extends App { } @debug({ args: false, singleLine: true }) - protected override setState(state: State, type?: IpcNotification | InternalNotificationType) { + protected override setState(state: State, type?: IpcNotification | InternalNotificationType): void { const themingChanged = this.ensureTheming(state); this.state = state; diff --git a/src/webviews/apps/plus/graph/hover/graphHover.ts b/src/webviews/apps/plus/graph/hover/graphHover.ts index db1cd2c06a065..f5f0ecad9b948 100644 --- a/src/webviews/apps/plus/graph/hover/graphHover.ts +++ b/src/webviews/apps/plus/graph/hover/graphHover.ts @@ -61,7 +61,7 @@ export class GlGraphHover extends GlElement { private hoveredSha: string | undefined; private unhoverTimer: ReturnType | undefined; - override render() { + override render(): unknown { if (!this.markdown) { this.hide(); return; @@ -109,18 +109,18 @@ export class GlGraphHover extends GlElement { } } - reset() { + reset(): void { this.recalculated = false; this.hoverMarkdownCache.clear(); } - onParentMouseLeave = () => { + private onParentMouseLeave = () => { this.hide(); }; private _showCoreDebounced: Deferrable | undefined = undefined; - onRowHovered(row: GraphRow, anchor: Anchor) { + onRowHovered(row: GraphRow, anchor: Anchor): void { clearTimeout(this.unhoverTimer); if (this.requestMarkdown == null) return; // Break if we are already showing the hover for the same row @@ -155,7 +155,7 @@ export class GlGraphHover extends GlElement { } } - onRowUnhovered(_row: GraphRow, relatedTarget: EventTarget | null) { + onRowUnhovered(_row: GraphRow, relatedTarget: EventTarget | null): void { this.recalculated = false; clearTimeout(this.unhoverTimer); @@ -170,7 +170,7 @@ export class GlGraphHover extends GlElement { this.unhoverTimer = setTimeout(() => this.hide(), 250); } - onWindowKeydown = (e: KeyboardEvent) => { + private onWindowKeydown = (e: KeyboardEvent) => { if (e.key === 'Escape') { e.stopPropagation(); this.hide(); @@ -205,7 +205,7 @@ export class GlGraphHover extends GlElement { window.addEventListener('keydown', this.onWindowKeydown); } - hide() { + hide(): void { this._showCoreDebounced?.cancel(); clearTimeout(this.unhoverTimer); this.parentElement?.removeEventListener('mouseleave', this.onParentMouseLeave); diff --git a/src/webviews/apps/plus/graph/minimap/minimap-container.ts b/src/webviews/apps/plus/graph/minimap/minimap-container.ts index 90523fee77041..cec3e6a642662 100644 --- a/src/webviews/apps/plus/graph/minimap/minimap-container.ts +++ b/src/webviews/apps/plus/graph/minimap/minimap-container.ts @@ -101,7 +101,7 @@ export class GlGraphMinimapContainer extends GlElement { @query('#minimap') private minimap: GlGraphMinimap | undefined; - override render() { + override render(): unknown { if (this.disabled) return nothing; return html``; } - select(date: number | Date | undefined, trackOnly: boolean = false) { + select(date: number | Date | undefined, trackOnly: boolean = false): void { if (this.disabled) return; this.minimap?.select(date, trackOnly); } - unselect(date?: number | Date, focus: boolean = false) { + unselect(date?: number | Date, focus: boolean = false): void { if (this.disabled) return; this.minimap?.unselect(date, focus); } diff --git a/src/webviews/apps/plus/graph/minimap/minimap.ts b/src/webviews/apps/plus/graph/minimap/minimap.ts index 3bf3a4964a161..fa1c1b2512cb1 100644 --- a/src/webviews/apps/plus/graph/minimap/minimap.ts +++ b/src/webviews/apps/plus/graph/minimap/minimap.ts @@ -572,7 +572,7 @@ export class GlGraphMinimap extends GlElement { } } - select(date: number | Date | undefined, trackOnly: boolean = false) { + select(date: number | Date | undefined, trackOnly: boolean = false): void { if (date == null) { this.unselect(); @@ -595,7 +595,7 @@ export class GlGraphMinimap extends GlElement { } } - unselect(date?: number | Date, focus: boolean = false) { + unselect(date?: number | Date, focus: boolean = false): void { if (focus) { this.getInternalChart()?.hideGridFocus(); @@ -1075,7 +1075,7 @@ export class GlGraphMinimap extends GlElement { this.onActiveDayChanged(); } - override render() { + override render(): unknown { return html`
diff --git a/src/webviews/apps/plus/graph/sidebar/sidebar.ts b/src/webviews/apps/plus/graph/sidebar/sidebar.ts index 3e31e8f5482d0..a365f21817c5d 100644 --- a/src/webviews/apps/plus/graph/sidebar/sidebar.ts +++ b/src/webviews/apps/plus/graph/sidebar/sidebar.ts @@ -87,7 +87,7 @@ export class GlGraphSideBar extends LitElement { autoRun: false, }); - override connectedCallback() { + override connectedCallback(): void { super.connectedCallback(); this._disposable = this._ipc.onReceiveMessage(msg => { @@ -105,7 +105,7 @@ export class GlGraphSideBar extends LitElement { }); } - override disconnectedCallback() { + override disconnectedCallback(): void { super.disconnectedCallback(); this._disposable?.dispose(); @@ -128,7 +128,7 @@ export class GlGraphSideBar extends LitElement { return this._counts; } - override render() { + override render(): unknown { if (!this.enabled) return nothing; if (this._counts == null) { diff --git a/src/webviews/apps/plus/home/components/active-work.ts b/src/webviews/apps/plus/home/components/active-work.ts index 1ead50c2a9741..0796680c15bd9 100644 --- a/src/webviews/apps/plus/home/components/active-work.ts +++ b/src/webviews/apps/plus/home/components/active-work.ts @@ -65,7 +65,7 @@ export class GlActiveWork extends SignalWatcher(LitElement) { @consume({ context: overviewStateContext }) private _overviewState!: OverviewState; - override connectedCallback() { + override connectedCallback(): void { super.connectedCallback(); if (this._homeState.repositories.openCount > 0) { @@ -73,7 +73,7 @@ export class GlActiveWork extends SignalWatcher(LitElement) { } } - override render() { + override render(): unknown { if (this._homeState.discovering) { return this.renderLoader(); } @@ -221,7 +221,7 @@ export class GlActiveBranchCard extends GlBranchCardBase { this.toggleExpanded(true); } - override render() { + override render(): unknown { return html` ${this.renderBranchIndicator()}${this.renderBranchItem( html`${this.renderBranchStateActions()}${this.renderBranchActions()}`, @@ -368,7 +368,7 @@ export class GlActiveBranchCard extends GlBranchCardBase { return wrappedActions(); } - protected renderBranchIndicator() { + protected renderBranchIndicator(): TemplateResult | undefined { const wip = this.wip; if (wip?.pausedOpStatus == null) return undefined; @@ -378,11 +378,11 @@ export class GlActiveBranchCard extends GlBranchCardBase { >`; } - protected getBranchActions() { + protected getBranchActions(): TemplateResult[] { return []; } - protected getPrActions() { + protected getPrActions(): TemplateResult[] { return [ html`; - get autolinks() { + get autolinks(): Awaited { return this._autolinks; } private _autolinksPromise!: GetOverviewBranch['autolinks']; - get autolinksPromise() { + get autolinksPromise(): GetOverviewBranch['autolinks'] { return this._autolinksPromise; } set autolinksPromise(value: GetOverviewBranch['autolinks']) { @@ -272,12 +272,12 @@ export abstract class GlBranchCardBase extends GlElement { @state() private _contributors!: Awaited; - get contributors() { + get contributors(): Awaited { return this._contributors; } private _contributorsPromise!: GetOverviewBranch['contributors']; - get contributorsPromise() { + get contributorsPromise(): GetOverviewBranch['contributors'] { return this._contributorsPromise; } set contributorsPromise(value: GetOverviewBranch['contributors']) { @@ -292,12 +292,12 @@ export abstract class GlBranchCardBase extends GlElement { @state() private _issues!: Awaited; - get issues() { + get issues(): Awaited { return this._issues; } private _issuesPromise!: GetOverviewBranch['issues']; - get issuesPromise() { + get issuesPromise(): GetOverviewBranch['issues'] { return this._issuesPromise; } set issuesPromise(value: GetOverviewBranch['issues']) { @@ -312,12 +312,12 @@ export abstract class GlBranchCardBase extends GlElement { @state() private _pr!: Awaited; - get pr() { + get pr(): Awaited { return this._pr; } private _prPromise!: GetOverviewBranch['pr']; - get prPromise() { + get prPromise(): GetOverviewBranch['pr'] { return this._prPromise; } set prPromise(value: GetOverviewBranch['pr']) { @@ -338,12 +338,12 @@ export abstract class GlBranchCardBase extends GlElement { @state() private _launchpadItem!: Awaited>['launchpad']>; - get launchpadItem() { + get launchpadItem(): Awaited>['launchpad']> { return this._launchpadItem; } private _launchpadItemPromise!: NonNullable>['launchpad']; - get launchpadItemPromise() { + get launchpadItemPromise(): NonNullable>['launchpad'] { return this._launchpadItemPromise; } set launchpadItemPromise(value: NonNullable>['launchpad']) { @@ -358,12 +358,12 @@ export abstract class GlBranchCardBase extends GlElement { @state() private _mergeTarget!: Awaited; - get mergeTarget() { + get mergeTarget(): Awaited { return this._mergeTarget; } private _mergeTargetPromise!: GetOverviewBranch['mergeTarget']; - get mergeTargetPromise() { + get mergeTargetPromise(): GetOverviewBranch['mergeTarget'] { return this._mergeTargetPromise; } set mergeTargetPromise(value: GetOverviewBranch['mergeTarget']) { @@ -378,12 +378,12 @@ export abstract class GlBranchCardBase extends GlElement { @state() private _wip!: Awaited; - get wip() { + get wip(): Awaited { return this._wip; } private _wipPromise!: GetOverviewBranch['wip']; - get wipPromise() { + get wipPromise(): GetOverviewBranch['wip'] { return this._wipPromise; } set wipPromise(value: GetOverviewBranch['wip']) { @@ -420,11 +420,11 @@ export abstract class GlBranchCardBase extends GlElement { }; } - get isWorktree() { + get isWorktree(): boolean { return this.branch.worktree != null; } - get cardIndicator() { + get cardIndicator(): GlCard['indicator'] { return getLaunchpadItemGrouping(getLaunchpadItemGroup(this.pr, this.launchpadItem)) ?? 'base'; } @@ -473,12 +473,12 @@ export abstract class GlBranchCardBase extends GlElement { } } - override connectedCallback() { + override connectedCallback(): void { super.connectedCallback(); this.attachFocusListener(); } - override disconnectedCallback() { + override disconnectedCallback(): void { super.disconnectedCallback(); this.eventController?.abort(); } @@ -499,7 +499,7 @@ export abstract class GlBranchCardBase extends GlElement { this.toggleExpanded(true); } - protected renderIssues() { + protected renderIssues(): TemplateResult | NothingType { const { autolinks, issues } = this; const issuesSource = issues?.length ? issues : autolinks; if (!issuesSource?.length) return nothing; @@ -519,7 +519,7 @@ export abstract class GlBranchCardBase extends GlElement { `; } - protected renderWip() { + protected renderWip(): TemplateResult | NothingType { const workingTreeState = this.wip?.workingTreeState; if (workingTreeState == null) return nothing; @@ -538,10 +538,10 @@ export abstract class GlBranchCardBase extends GlElement { `; } - protected renderAvatars() { + protected renderAvatars(): TemplateResult | NothingType { const { contributors } = this; - if (!contributors?.length) return undefined; + if (!contributors?.length) return nothing; return html` ({ name: a.name, src: a.avatarUrl }))} @@ -549,7 +549,7 @@ export abstract class GlBranchCardBase extends GlElement { >`; } - protected renderTracking(showWip = false) { + protected renderTracking(showWip = false): TemplateResult | NothingType { if (this.branch.upstream == null) return nothing; const ahead = this.branch.state.ahead ?? 0; const behind = this.branch.state.behind ?? 0; @@ -608,7 +608,7 @@ export abstract class GlBranchCardBase extends GlElement { } protected abstract getBranchActions(): TemplateResult[]; - protected renderBranchActions() { + protected renderBranchActions(): TemplateResult | NothingType { const actions = this.getBranchActions?.(); if (!actions?.length) return nothing; @@ -616,18 +616,18 @@ export abstract class GlBranchCardBase extends GlElement { } protected abstract getPrActions(): TemplateResult[]; - protected renderPrActions() { + protected renderPrActions(): TemplateResult | NothingType { const actions = this.getPrActions?.(); if (!actions?.length) return nothing; return html`${actions}`; } - protected createCommandLink(command: Commands, args?: T | any) { + protected createCommandLink(command: Commands, args?: T | any): string { return createCommandLink(command, args ?? this.branchRef); } - protected renderTimestamp() { + protected renderTimestamp(): TemplateResult | NothingType { const { timestamp } = this.branch; if (timestamp == null) return nothing; @@ -640,7 +640,7 @@ export abstract class GlBranchCardBase extends GlElement { protected abstract renderBranchIndicator?(): TemplateResult | undefined; - protected renderBranchItem(actionsSection?: TemplateResult | NothingType) { + protected renderBranchItem(actionsSection?: TemplateResult | NothingType): TemplateResult | NothingType { const wip = this.renderWip(); const tracking = this.renderTracking(); const avatars = this.renderAvatars(); @@ -695,7 +695,7 @@ export abstract class GlBranchCardBase extends GlElement { >`; } - protected renderPrItem() { + protected renderPrItem(): TemplateResult | NothingType { if (!this.pr) { if (this.branch.upstream?.missing === false && this.expanded) { return html` @@ -735,7 +735,7 @@ export abstract class GlBranchCardBase extends GlElement { `; } - protected renderLaunchpadItem() { + protected renderLaunchpadItem(): TemplateResult | NothingType { if (this.launchpadItem == null) return nothing; const group = getLaunchpadItemGroup(this.pr, this.launchpadItem); @@ -780,7 +780,7 @@ export abstract class GlBranchCardBase extends GlElement { : nothing}`; } - protected renderMergeTargetStatus() { + protected renderMergeTargetStatus(): TemplateResult | NothingType { if (!this.branch.mergeTarget) return nothing; return html``; } - protected renderIssuesItem() { + protected renderIssuesItem(): TemplateResult | NothingType { const issues = [...(this.issues ?? []), ...(this.autolinks ?? [])]; if (!issues.length) { if (!this.expanded) return nothing; @@ -826,7 +826,7 @@ export abstract class GlBranchCardBase extends GlElement { `; } - toggleExpanded(expanded = !this.expanded) { + toggleExpanded(expanded = !this.expanded): void { this.expanded = expanded; queueMicrotask(() => { @@ -837,7 +837,7 @@ export abstract class GlBranchCardBase extends GlElement { @customElement('gl-branch-card') export class GlBranchCard extends GlBranchCardBase { - override render() { + override render(): unknown { return html`
@@ -847,7 +847,7 @@ export class GlBranchCard extends GlBranchCardBase { `; } - protected getBranchActions() { + protected getBranchActions(): TemplateResult[] { const actions = []; if (this.branch.worktree) { @@ -890,7 +890,7 @@ export class GlBranchCard extends GlBranchCardBase { return actions; } - protected getPrActions() { + protected getPrActions(): TemplateResult[] { return [ html`
@@ -78,12 +78,12 @@ export class GlBranchSection extends LitElement { @queryAll('gl-branch-card') private branchCards!: GlBranchCardBase[]; - override connectedCallback() { + override connectedCallback(): void { super.connectedCallback(); this.addEventListener('gl-branch-card-expand-toggled', this.onCardExpanded.bind(this)); } - override disconnectedCallback() { + override disconnectedCallback(): void { super.disconnectedCallback(); this.removeEventListener('gl-branch-card-expand-toggled', this.onCardExpanded.bind(this)); } @@ -114,7 +114,7 @@ export class GlBranchSection extends LitElement { return `${this.label} (${this.branches.length})`; } - override render() { + override render(): unknown { return html` ${this.renderSectionLabel()} diff --git a/src/webviews/apps/plus/home/components/branch-threshold-filter.ts b/src/webviews/apps/plus/home/components/branch-threshold-filter.ts index ec7523d3e820b..035b60efea657 100644 --- a/src/webviews/apps/plus/home/components/branch-threshold-filter.ts +++ b/src/webviews/apps/plus/home/components/branch-threshold-filter.ts @@ -43,7 +43,7 @@ export abstract class GlObjectSelect extends protected abstract getLabel(option: T): L; protected abstract onChange?(e: InputEvent): unknown; - override render() { + override render(): unknown { if (!this.options) { return; } @@ -64,13 +64,15 @@ export class GlBranchThresholdFilter extends GlObjectSelect<{ value: OverviewRecentThreshold | OverviewStaleThreshold; label: string; }> { - protected getValue(option: { value: OverviewRecentThreshold | OverviewStaleThreshold }) { + protected getValue(option: { + value: OverviewRecentThreshold | OverviewStaleThreshold; + }): OverviewRecentThreshold | 'OneYear' { return option.value; } - protected getLabel(option: { label: string }) { + protected getLabel(option: { label: string }): string { return option.label; } - protected onChange(e: InputEvent) { + protected onChange(e: InputEvent): void { const event = new CustomEvent('gl-change', { detail: { threshold: (e.target as HTMLSelectElement).value as OverviewRecentThreshold | OverviewStaleThreshold, diff --git a/src/webviews/apps/plus/home/components/launchpad.ts b/src/webviews/apps/plus/home/components/launchpad.ts index ed94354b8fac6..a5938ee9a003f 100644 --- a/src/webviews/apps/plus/home/components/launchpad.ts +++ b/src/webviews/apps/plus/home/components/launchpad.ts @@ -111,15 +111,15 @@ export class GlLaunchpad extends SignalWatcher(LitElement) { return rsp; }); - get startWorkCommand() { + get startWorkCommand(): string { return createCommandLink('gitlens.home.startWork', undefined); } - get createBranchCommand() { + get createBranchCommand(): string { return createCommandLink('gitlens.home.createBranch', undefined); } - override connectedCallback() { + override connectedCallback(): void { super.connectedCallback(); this._disposable.push( @@ -135,13 +135,13 @@ export class GlLaunchpad extends SignalWatcher(LitElement) { this._summaryState.run(); } - override disconnectedCallback() { + override disconnectedCallback(): void { super.disconnectedCallback(); this._disposable.forEach(d => d.dispose()); } - override render() { + override render(): unknown { return html` Launchpad diff --git a/src/webviews/apps/plus/home/components/merge-target-status.ts b/src/webviews/apps/plus/home/components/merge-target-status.ts index 37c834a67110a..83d5bf3e8144c 100644 --- a/src/webviews/apps/plus/home/components/merge-target-status.ts +++ b/src/webviews/apps/plus/home/components/merge-target-status.ts @@ -202,7 +202,7 @@ export class GlMergeTargetStatus extends LitElement { @state() private _target: Awaited; - get target() { + get target(): Awaited { return this._target; } @@ -253,7 +253,7 @@ export class GlMergeTargetStatus extends LitElement { }; } - override render() { + override render(): unknown { if (!this.status && !this.conflicts) return nothing; let icon; diff --git a/src/webviews/apps/plus/home/components/overview.ts b/src/webviews/apps/plus/home/components/overview.ts index e43ddad0353df..c8a707029913c 100644 --- a/src/webviews/apps/plus/home/components/overview.ts +++ b/src/webviews/apps/plus/home/components/overview.ts @@ -38,7 +38,7 @@ export class GlOverview extends SignalWatcher(LitElement) { @consume({ context: overviewStateContext }) private _overviewState!: OverviewState; - override connectedCallback() { + override connectedCallback(): void { super.connectedCallback(); if (this._homeState.repositories.openCount > 0) { @@ -46,7 +46,7 @@ export class GlOverview extends SignalWatcher(LitElement) { } } - override render() { + override render(): unknown { if (this._homeState.discovering) { return this.renderLoader(); } diff --git a/src/webviews/apps/plus/home/components/overviewState.ts b/src/webviews/apps/plus/home/components/overviewState.ts index 18874feeb8391..592a88a5634af 100644 --- a/src/webviews/apps/plus/home/components/overviewState.ts +++ b/src/webviews/apps/plus/home/components/overviewState.ts @@ -52,13 +52,13 @@ export class OverviewState extends AsyncComputedState { }); } - dispose() { + dispose(): void { this._disposable?.dispose(); } filter = signalObject>({}); - async changeRepository() { + async changeRepository(): Promise { await this._ipc.sendRequest(ChangeOverviewRepository, undefined); this.run(true); } diff --git a/src/webviews/apps/plus/patchDetails/components/gl-draft-details.ts b/src/webviews/apps/plus/patchDetails/components/gl-draft-details.ts index 05b00edbabdc5..25fed917bf93f 100644 --- a/src/webviews/apps/plus/patchDetails/components/gl-draft-details.ts +++ b/src/webviews/apps/plus/patchDetails/components/gl-draft-details.ts @@ -117,11 +117,11 @@ export class GlDraftDetails extends GlTreeBase { return this.state.draft; } - get isCodeSuggestion() { + get isCodeSuggestion(): boolean { return this.cloudDraft?.type === 'suggested_pr_change'; } - get canSubmit() { + get canSubmit(): boolean { return this.selectedPatches.length > 0; // return this.state.draft?.repoPath != null && this.state.draft?.baseRef != null; } @@ -132,7 +132,7 @@ export class GlDraftDetails extends GlTreeBase { defineGkElement(Avatar, Button, Popover, Menu, MenuItem); } - override updated(changedProperties: Map) { + override updated(changedProperties: Map): void { if (changedProperties.has('explain')) { this.explainBusy = false; this.querySelector('[data-region="ai-explanation"]')?.scrollIntoView(); @@ -315,7 +315,7 @@ export class GlDraftDetails extends GlTreeBase { return models; } - renderUserSelection(userSelection: DraftUserSelection, role: DraftRole) { + private renderUserSelection(userSelection: DraftUserSelection, role: DraftRole) { if (userSelection.change === 'delete') return undefined; const selectionRole = userSelection.pendingRole ?? userSelection.user!.role; @@ -376,7 +376,7 @@ export class GlDraftDetails extends GlTreeBase { `; } - renderUserSelectionList(draft: CloudDraftDetails, includeOwner = false) { + private renderUserSelectionList(draft: CloudDraftDetails, includeOwner = false) { if (!draft.userSelections?.length) return undefined; let userSelections = draft.userSelections; @@ -397,7 +397,7 @@ export class GlDraftDetails extends GlTreeBase { `; } - renderPatchPermissions() { + private renderPatchPermissions() { const draft = this.cloudDraft; if (draft == null) return undefined; @@ -489,7 +489,7 @@ export class GlDraftDetails extends GlTreeBase { `; } - renderCodeSuggectionActions() { + private renderCodeSuggectionActions() { if ( !this.isCodeSuggestion || this.cloudDraft == null || @@ -513,7 +513,7 @@ export class GlDraftDetails extends GlTreeBase { `; } - renderPatches() { + private renderPatches() { // // const path = this.state.draft?.repoPath; // const repo = this.state.draft?.repoName; // const base = this.state.draft?.baseRef; @@ -588,7 +588,7 @@ export class GlDraftDetails extends GlTreeBase { `; } - renderActionbar() { + private renderActionbar() { const draft = this.state?.draft; if (draft == null) return undefined; @@ -631,7 +631,7 @@ export class GlDraftDetails extends GlTreeBase { `; } - renderDraftInfo() { + private renderDraftInfo() { if (this.state.draft?.title == null) return nothing; let badge = undefined; @@ -646,7 +646,7 @@ export class GlDraftDetails extends GlTreeBase { `; } - override render() { + override render(): unknown { if (this.state?.draft == null) { return html`
${this.renderEmptyContent()}
`; } @@ -664,7 +664,7 @@ export class GlDraftDetails extends GlTreeBase { `; } - protected override createRenderRoot() { + protected override createRenderRoot(): HTMLElement { return this; } @@ -693,7 +693,7 @@ export class GlDraftDetails extends GlTreeBase { this.emit('gl-patch-details-update-permissions'); } - onExplainChanges(e: MouseEvent | KeyboardEvent) { + private onExplainChanges(e: MouseEvent | KeyboardEvent) { if (this.explainBusy === true || (e instanceof KeyboardEvent && e.key !== 'Enter')) { e.preventDefault(); e.stopPropagation(); @@ -703,7 +703,7 @@ export class GlDraftDetails extends GlTreeBase { this.explainBusy = true; } - override onTreeItemActionClicked(e: CustomEvent) { + override onTreeItemActionClicked(e: CustomEvent): void { if (!e.detail.context || !e.detail.action) return; const action = e.detail.action; @@ -728,14 +728,14 @@ export class GlDraftDetails extends GlTreeBase { } } - fireFileEvent(name: string, file: DraftPatchFileChange, showOptions?: TextDocumentShowOptions) { + fireFileEvent(name: string, file: DraftPatchFileChange, showOptions?: TextDocumentShowOptions): void { const event = new CustomEvent(name, { detail: { ...file, showOptions: showOptions }, }); this.dispatchEvent(event); } - onCompareWorking(e: CustomEvent) { + private onCompareWorking(e: CustomEvent) { if (!e.detail.context) return; const [file] = e.detail.context; @@ -748,7 +748,7 @@ export class GlDraftDetails extends GlTreeBase { }); } - onOpenFile(e: CustomEvent) { + private onOpenFile(e: CustomEvent) { if (!e.detail.context) return; const [file] = e.detail.context; @@ -761,7 +761,7 @@ export class GlDraftDetails extends GlTreeBase { }); } - override onTreeItemChecked(e: CustomEvent) { + override onTreeItemChecked(e: CustomEvent): void { if (!e.detail.context) return; const [gkRepositoryId] = e.detail.context; @@ -786,7 +786,7 @@ export class GlDraftDetails extends GlTreeBase { this.dispatchEvent(event); } - override onTreeItemSelected(e: CustomEvent) { + override onTreeItemSelected(e: CustomEvent): void { const { node, context } = e.detail; if (node.branch === true || context == null) return; @@ -794,7 +794,7 @@ export class GlDraftDetails extends GlTreeBase { this.emit('gl-patch-file-compare-previous', { ...file }); } - onApplyPatch(_e?: MouseEvent | KeyboardEvent, target: 'current' | 'branch' | 'worktree' = 'current') { + private onApplyPatch(_e?: MouseEvent | KeyboardEvent, target: 'current' | 'branch' | 'worktree' = 'current') { if (this.canSubmit === false) { this.validityMessage = 'Please select changes to apply'; return; @@ -809,11 +809,11 @@ export class GlDraftDetails extends GlTreeBase { }); } - onArchiveDraft(reason: DraftReasonEventDetail['reason']) { + private onArchiveDraft(reason: DraftReasonEventDetail['reason']) { this.emit('gl-draft-archive', { reason: reason }); } - onSelectApplyOption(e: CustomEvent<{ target: MenuItem }>) { + private onSelectApplyOption(e: CustomEvent<{ target: MenuItem }>) { if (this.canSubmit === false) { this.validityMessage = 'Please select changes to apply'; return; @@ -825,7 +825,7 @@ export class GlDraftDetails extends GlTreeBase { } } - onChangePatchBase(_e?: MouseEvent | KeyboardEvent) { + private onChangePatchBase(_e?: MouseEvent | KeyboardEvent) { const evt = new CustomEvent('change-patch-base', { detail: { draft: this.state.draft!, @@ -834,7 +834,7 @@ export class GlDraftDetails extends GlTreeBase { this.dispatchEvent(evt); } - onSelectPatchRepo(_e?: MouseEvent | KeyboardEvent) { + private onSelectPatchRepo(_e?: MouseEvent | KeyboardEvent) { const evt = new CustomEvent('select-patch-repo', { detail: { draft: this.state.draft!, @@ -843,17 +843,17 @@ export class GlDraftDetails extends GlTreeBase { this.dispatchEvent(evt); } - onShowInGraph(_e?: MouseEvent | KeyboardEvent) { + private onShowInGraph(_e?: MouseEvent | KeyboardEvent) { this.emit('gl-patch-details-graph-show-patch', { draft: this.state.draft! }); } - onCopyCloudLink() { + private onCopyCloudLink() { this.emit('gl-patch-details-copy-cloud-link', { draft: this.state.draft! }); this._copiedLink = true; setTimeout(() => (this._copiedLink = false), 1000); } - onShareLocalPatch() { + private onShareLocalPatch() { this.emit('gl-patch-details-share-local-patch', { draft: this.state.draft! }); } @@ -921,7 +921,10 @@ export class GlDraftDetails extends GlTreeBase { // ]; // } - override getFileActions(_file: DraftPatchFileChange, _options?: Partial) { + override getFileActions( + _file: DraftPatchFileChange, + _options?: Partial, + ): { icon: string; label: string; action: string }[] { return [ { icon: 'go-to-file', diff --git a/src/webviews/apps/plus/patchDetails/components/gl-patch-create.ts b/src/webviews/apps/plus/patchDetails/components/gl-patch-create.ts index ab4f5b583fcfe..1da52038780b5 100644 --- a/src/webviews/apps/plus/patchDetails/components/gl-patch-create.ts +++ b/src/webviews/apps/plus/patchDetails/components/gl-patch-create.ts @@ -4,6 +4,7 @@ import { customElement, property, query, state } from 'lit/decorators.js'; import { map } from 'lit/directives/map.js'; import { repeat } from 'lit/directives/repeat.js'; import { when } from 'lit/directives/when.js'; +import type { ViewFilesLayout } from '../../../../../config'; import { urls } from '../../../../../constants'; import type { GitFileChangeShape } from '../../../../../git/models/fileChange'; import type { DraftRole, DraftVisibility } from '../../../../../plus/drafts/models/drafts'; @@ -97,19 +98,19 @@ export class GlPatchCreate extends GlTreeBase { @state() validityMessage?: string; - get create() { + get create(): NonNullable { return this.state!.create!; } - get createChanges() { + get createChanges(): Change[] { return Object.values(this.create.changes); } - get createEntries() { + get createEntries(): [string, Change][] { return Object.entries(this.create.changes); } - get hasWipChanges() { + get hasWipChanges(): boolean { return this.createChanges.some(change => change?.type === 'wip'); } @@ -119,23 +120,23 @@ export class GlPatchCreate extends GlTreeBase { return this.createEntries.filter(([, change]) => change.checked !== false); } - get canSubmit() { + get canSubmit(): boolean { return this.create.title != null && this.create.title.length > 0 && this.selectedChanges.length > 0; } - get fileLayout() { + get fileLayout(): ViewFilesLayout { return this.state?.preferences?.files?.layout ?? 'auto'; } - get isCompact() { + get isCompact(): boolean { return this.state?.preferences?.files?.compact ?? true; } - get filesModified() { + get filesModified(): number { return flatCount(this.createChanges, c => c.files?.length ?? 0); } - get draftVisibility() { + get draftVisibility(): DraftVisibility { return this.state?.create?.visibility ?? 'public'; } @@ -145,7 +146,7 @@ export class GlPatchCreate extends GlTreeBase { defineGkElement(Avatar, Button, Menu, MenuItem, Popover); } - override updated(changedProperties: Map) { + override updated(changedProperties: Map): void { if (changedProperties.has('state')) { this.creationBusy = false; } @@ -154,13 +155,13 @@ export class GlPatchCreate extends GlTreeBase { this.generateAiButton.scrollIntoView(); } } - protected override firstUpdated() { + protected override firstUpdated(): void { window.requestAnimationFrame(() => { this.titleInput.focus(); }); } - renderUserSelection(userSelection: DraftUserSelection) { + private renderUserSelection(userSelection: DraftUserSelection) { const role = userSelection.pendingRole!; const options = new Map([ ['admin', 'admin'], @@ -208,7 +209,7 @@ export class GlPatchCreate extends GlTreeBase { `; } - renderUserSelectionList() { + private renderUserSelectionList() { if (this.state?.create?.userSelections == null || this.state?.create?.userSelections.length === 0) { return undefined; } @@ -226,7 +227,7 @@ export class GlPatchCreate extends GlTreeBase { `; } - renderForm() { + private renderForm() { let visibilityIcon: string | undefined; switch (this.draftVisibility) { case 'private': @@ -401,7 +402,7 @@ export class GlPatchCreate extends GlTreeBase { // @changeset-unstaged-checked=${this.onUnstagedChecked} // > // - override render() { + override render(): unknown { return html`
${this.renderChangedFiles()}
@@ -447,7 +448,7 @@ export class GlPatchCreate extends GlTreeBase { // >`; // } - override onTreeItemChecked(e: CustomEvent) { + override onTreeItemChecked(e: CustomEvent): void { console.log(e); // this.onRepoChecked() if (e.detail.context == null || e.detail.context.length < 1) return; @@ -474,7 +475,7 @@ export class GlPatchCreate extends GlTreeBase { }); } - override onTreeItemSelected(e: CustomEvent) { + override onTreeItemSelected(e: CustomEvent): void { if (!e.detail.context) return; const [file] = e.detail.context; @@ -740,11 +741,11 @@ export class GlPatchCreate extends GlTreeBase { }); } - protected override createRenderRoot() { + protected override createRenderRoot(): HTMLElement { return this; } - override onTreeItemActionClicked(e: CustomEvent) { + override onTreeItemActionClicked(e: CustomEvent): void { if (!e.detail.context || !e.detail.action) return; const action = e.detail.action; @@ -767,7 +768,7 @@ export class GlPatchCreate extends GlTreeBase { } } - onOpenFile(e: CustomEvent) { + private onOpenFile(e: CustomEvent) { if (!e.detail.context) return; const [file] = e.detail.context; @@ -780,7 +781,7 @@ export class GlPatchCreate extends GlTreeBase { }); } - onStageFile(e: CustomEvent) { + private onStageFile(e: CustomEvent) { if (!e.detail.context) return; const [file] = e.detail.context; @@ -793,7 +794,7 @@ export class GlPatchCreate extends GlTreeBase { }); } - onUnstageFile(e: CustomEvent) { + private onUnstageFile(e: CustomEvent) { if (!e.detail.context) return; const [file] = e.detail.context; @@ -806,15 +807,18 @@ export class GlPatchCreate extends GlTreeBase { }); } - onShowInGraph(_e: CustomEvent) { + private onShowInGraph(_e: CustomEvent) { // this.emit('gl-patch-details-graph-show-patch', { draft: this.state!.create! }); } - onCancel() { + private onCancel() { this.emit('gl-patch-create-cancelled'); } - override getFileActions(file: GitFileChangeShape, _options?: Partial) { + override getFileActions( + file: GitFileChangeShape, + _options?: Partial, + ): { icon: string; label: string; action: string }[] { const openFile = { icon: 'go-to-file', label: 'Open file', @@ -830,7 +834,11 @@ export class GlPatchCreate extends GlTreeBase { return [openFile, { icon: 'plus', label: 'Stage changes', action: 'file-stage' }]; } - override getRepoActions(_name: string, _path: string, _options?: Partial) { + override getRepoActions( + _name: string, + _path: string, + _options?: Partial, + ): { icon: string; label: string; action: string }[] { return [ { icon: 'gl-graph', diff --git a/src/webviews/apps/plus/patchDetails/components/gl-tree-base.ts b/src/webviews/apps/plus/patchDetails/components/gl-tree-base.ts index 0781b009c4e30..181fc372b061d 100644 --- a/src/webviews/apps/plus/patchDetails/components/gl-tree-base.ts +++ b/src/webviews/apps/plus/patchDetails/components/gl-tree-base.ts @@ -1,3 +1,4 @@ +import type { TemplateResult } from 'lit'; import { html, nothing } from 'lit'; import type { GitFileChangeShape } from '../../../../../git/models/fileChange'; import type { HierarchicalItem } from '../../../../../system/array'; @@ -20,7 +21,7 @@ export class GlTreeBase extends GlElement { protected onTreeItemChecked?(_e: CustomEvent): void; protected onTreeItemSelected?(_e: CustomEvent): void; - protected renderLoading() { + protected renderLoading(): TemplateResult { return html`
@@ -34,7 +35,7 @@ export class GlTreeBase extends GlElement { `; } - protected renderLayoutAction(layout: string) { + protected renderLayoutAction(layout: string): TemplateResult | typeof nothing { if (!layout) return nothing; let value = 'tree'; @@ -61,7 +62,7 @@ export class GlTreeBase extends GlElement { return html``; } - protected renderTreeView(treeModel: TreeModel[], guides: 'none' | 'onHover' | 'always' = 'none') { + protected renderTreeView(treeModel: TreeModel[], guides: 'none' | 'onHover' | 'always' = 'none'): TemplateResult { return html` { @@ -108,13 +108,13 @@ export class GlPatchDetailsApp extends GlElement { rootStyle.setProperty('--gitlens-tree-indent', `${this.indentPreference}px`); } - override updated(changedProperties: Map) { + override updated(changedProperties: Map): void { if (changedProperties.has('state')) { this.updateDocumentProperties(); } } - override render() { + override render(): unknown { return html`
@@ -140,7 +140,7 @@ export class GlPatchDetailsApp extends GlElement { // this.fireEvent('gl-patch-details-copy-cloud-link'); // } - protected override createRenderRoot() { + protected override createRenderRoot(): HTMLElement { return this; } } diff --git a/src/webviews/apps/plus/patchDetails/patchDetails.ts b/src/webviews/apps/plus/patchDetails/patchDetails.ts index 84a27d38a1ee2..1bbfef6996717 100644 --- a/src/webviews/apps/plus/patchDetails/patchDetails.ts +++ b/src/webviews/apps/plus/patchDetails/patchDetails.ts @@ -40,6 +40,7 @@ import type { IpcMessage } from '../../../protocol'; import { ExecuteCommand } from '../../../protocol'; import { App } from '../../shared/appBase'; import { DOM } from '../../shared/dom'; +import type { Disposable } from '../../shared/events'; import type { ApplyPatchDetail, DraftReasonEventDetail, @@ -74,11 +75,11 @@ export class PatchDetailsApp extends App> { super('PatchDetailsApp'); } - override onInitialize() { + override onInitialize(): void { this.debouncedAttachState(); } - override onBind() { + override onBind(): Disposable[] { const disposables = [ DOM.on('[data-switch-value]', 'click', e => this.onToggleFilesLayout(e)), DOM.on('[data-action="ai-explain"]', 'click', e => this.onAIExplain(e)), @@ -170,7 +171,7 @@ export class PatchDetailsApp extends App> { return disposables; } - protected override onMessageReceived(msg: IpcMessage) { + protected override onMessageReceived(msg: IpcMessage): void { switch (true) { // case DidChangeRichStateNotificationType.method: // onIpc(DidChangeRichStateNotificationType, msg, params => { @@ -356,7 +357,7 @@ export class PatchDetailsApp extends App> { this.onCommandClickedCore('gitlens.switchAIModel'); } - async onAIExplain(_e: MouseEvent) { + private async onAIExplain(_e: MouseEvent) { try { const result = await this.sendRequest(ExplainRequest, undefined); diff --git a/src/webviews/apps/plus/shared/components/account-chip.ts b/src/webviews/apps/plus/shared/components/account-chip.ts index 453f6e39fd2a3..8d987230437ed 100644 --- a/src/webviews/apps/plus/shared/components/account-chip.ts +++ b/src/webviews/apps/plus/shared/components/account-chip.ts @@ -249,7 +249,7 @@ export class GLAccountChip extends LitElement { return hasAccountFromSubscriptionState(this.subscriptionState); } - get isReactivatedTrial() { + get isReactivatedTrial(): boolean { return ( this.subscriptionState === SubscriptionState.ProTrial && (this.subscription?.plan.effective.trialReactivationCount ?? 0) > 0 @@ -281,11 +281,11 @@ export class GLAccountChip extends LitElement { return getSubscriptionTimeRemaining(this.subscription, 'days') ?? 0; } - override focus() { + override focus(): void { this._chip.focus(); } - override render() { + override render(): unknown { return html` ${this.accountAvatar @@ -341,7 +341,7 @@ export class GLAccountChip extends LitElement { `; } - show() { + show(): void { void this._popover.show(); this.focus(); } diff --git a/src/webviews/apps/plus/shared/components/feature-gate-plus-state.ts b/src/webviews/apps/plus/shared/components/feature-gate-plus-state.ts index 9a48868396314..fc70056c5628a 100644 --- a/src/webviews/apps/plus/shared/components/feature-gate-plus-state.ts +++ b/src/webviews/apps/plus/shared/components/feature-gate-plus-state.ts @@ -106,13 +106,13 @@ export class GlFeatureGatePlusState extends LitElement { @property({ type: String }) webroot?: string; - protected override firstUpdated() { + protected override firstUpdated(): void { if (this.appearance === 'alert') { queueMicrotask(() => this.button.focus()); } } - override render() { + override render(): unknown { if (this.state == null) { this.hidden = true; return undefined; diff --git a/src/webviews/apps/plus/shared/components/home-header.ts b/src/webviews/apps/plus/shared/components/home-header.ts index 0d8d458cdeecd..9d655b64276f9 100644 --- a/src/webviews/apps/plus/shared/components/home-header.ts +++ b/src/webviews/apps/plus/shared/components/home-header.ts @@ -62,7 +62,7 @@ export class GLHomeHeader extends LitElement { @query('gl-account-chip') private accountChip!: GLAccountChip; - override render() { + override render(): unknown { return html`
@@ -71,7 +71,7 @@ export class GLHomeHeader extends LitElement { `; } - show() { + show(): void { this.accountChip.show(); } } diff --git a/src/webviews/apps/plus/shared/components/integrations-chip.ts b/src/webviews/apps/plus/shared/components/integrations-chip.ts index 9d7aa3afc503e..c90fb5a285ec3 100644 --- a/src/webviews/apps/plus/shared/components/integrations-chip.ts +++ b/src/webviews/apps/plus/shared/components/integrations-chip.ts @@ -149,11 +149,11 @@ export class GLIntegrationsChip extends LitElement { return this._state.integrations; } - override focus() { + override focus(): void { this._chip.focus(); } - override render() { + override render(): unknown { const anyConnected = this.hasConnectedIntegrations; const statusFilter = createIconBasedStatusFilter(this.integrations); return html` diff --git a/src/webviews/apps/plus/shared/components/merge-rebase-status.ts b/src/webviews/apps/plus/shared/components/merge-rebase-status.ts index 5e5d1e7db3d38..f5412142239c7 100644 --- a/src/webviews/apps/plus/shared/components/merge-rebase-status.ts +++ b/src/webviews/apps/plus/shared/components/merge-rebase-status.ts @@ -105,7 +105,7 @@ export class GlMergeConflictWarning extends LitElement { return createCommandLink(command as Commands, args); } - override render() { + override render(): unknown { if (this.pausedOpStatus == null) return nothing; return html` diff --git a/src/webviews/apps/plus/timeline/components/chart.ts b/src/webviews/apps/plus/timeline/components/chart.ts index 0cf590bf204c7..008597aefa75d 100644 --- a/src/webviews/apps/plus/timeline/components/chart.ts +++ b/src/webviews/apps/plus/timeline/components/chart.ts @@ -71,7 +71,7 @@ export class GlTimelineChart extends GlElement { @state() private _data: Awaited | null = null; - get data() { + get data(): Awaited | null { return this._data; } @@ -80,7 +80,7 @@ export class GlTimelineChart extends GlElement { private _dataPromise!: NonNullable; @property({ type: Object }) - get dataPromise() { + get dataPromise(): NonNullable { return this._dataPromise; } set dataPromise(value: NonNullable) { @@ -130,7 +130,7 @@ export class GlTimelineChart extends GlElement { super.update(changedProperties); } - protected override render() { + protected override render(): unknown { // Don't render anything if the data is still loading if (this.data === null) return nothing; @@ -141,13 +141,13 @@ export class GlTimelineChart extends GlElement { return html`
`; } - reset() { + reset(): void { // this._chart?.unselect(); this._chart?.unzoom(); this.zoomed = false; } - zoom(factor: number) { + zoom(factor: number): void { if (!this._chart) return; const d = this._chart.zoom(); @@ -169,7 +169,7 @@ export class GlTimelineChart extends GlElement { private _zoomedDomain: [string, string] | undefined; @log({ args: false }) - async updateChart(dataPromise: State['dataset']) { + async updateChart(dataPromise: State['dataset']): Promise { if (this._loading?.pending) return; const abortController = this._abortController; diff --git a/src/webviews/apps/plus/timeline/stateProvider.ts b/src/webviews/apps/plus/timeline/stateProvider.ts index 01bf58f2056f0..6bad3fb07cbfd 100644 --- a/src/webviews/apps/plus/timeline/stateProvider.ts +++ b/src/webviews/apps/plus/timeline/stateProvider.ts @@ -14,7 +14,7 @@ export class TimelineStateProvider implements StateProvider { private readonly provider: ContextProvider<{ __context__: State }, ReactiveElementHost>; private _state: State; - get state() { + get state(): State { return this._state; } @@ -45,7 +45,7 @@ export class TimelineStateProvider implements StateProvider { }); } - dispose() { + dispose(): void { this.disposable.dispose(); } } diff --git a/src/webviews/apps/plus/timeline/timeline.ts b/src/webviews/apps/plus/timeline/timeline.ts index 2edae98a95f4a..f4916f721172a 100644 --- a/src/webviews/apps/plus/timeline/timeline.ts +++ b/src/webviews/apps/plus/timeline/timeline.ts @@ -28,10 +28,10 @@ export class GlTimelineApp extends GlApp { @query('#chart') private _chart?: GlTimelineChart; - protected override createStateProvider(state: State, ipc: HostIpc) { + protected override createStateProvider(state: State, ipc: HostIpc): TimelineStateProvider { return new TimelineStateProvider(this, state, ipc); } - protected override onPersistState(state: State) { + protected override onPersistState(state: State): void { this._ipc.setState({ period: state.period, uri: state.uri }); } @@ -47,11 +47,11 @@ export class GlTimelineApp extends GlApp { super.disconnectedCallback(); } - get allowed() { + get allowed(): boolean | 'mixed' { return this.state.access?.allowed ?? false; } - get header() { + get header(): { title: string; description: string } { let title = this.state.title; let description; @@ -69,33 +69,33 @@ export class GlTimelineApp extends GlApp { @state() private _loading = true; - get loading() { + get loading(): boolean { return this.state.dataset != null && this.uri != null && this._loading; } - get period() { + get period(): Period { return this.state.period; } - get subscription() { + get subscription(): State['access']['subscription']['current'] | undefined { return this.state.access?.subscription?.current; } - get sha() { + get sha(): string | undefined { return this.state.sha; } - get uri() { + get uri(): string | undefined { return this.state.uri; } - get uriType() { + get uriType(): State['uriType'] { return this.state.uriType; } @state() private _zoomed = false; - get zoomed() { + get zoomed(): boolean { return this._zoomed; } @@ -107,7 +107,7 @@ export class GlTimelineApp extends GlApp { super.willUpdate(changedProperties); } - override render() { + override render(): unknown { return html` ${this.allowed ? html` { super('SettingsApp'); } - protected override onInitialize() { + protected override onInitialize(): void { // Add scopes if available const scopes = document.getElementById('scopes') as HTMLSelectElement; if (scopes != null && this.state.scopes.length > 1) { @@ -84,7 +85,7 @@ export class SettingsApp extends App { } } - protected override onBind() { + protected override onBind(): Disposable[] { const disposables = super.onBind?.() ?? []; disposables.push( @@ -136,7 +137,7 @@ export class SettingsApp extends App { return disposables; } - protected override onMessageReceived(msg: IpcMessage) { + protected override onMessageReceived(msg: IpcMessage): void { switch (true) { case DidOpenAnchorNotification.is(msg): this.scrollToAnchor(msg.params.anchor, msg.params.scrollBehavior); diff --git a/src/webviews/apps/shared/app.ts b/src/webviews/apps/shared/app.ts index bd39189dcffb5..e0f009470ebf8 100644 --- a/src/webviews/apps/shared/app.ts +++ b/src/webviews/apps/shared/app.ts @@ -42,7 +42,7 @@ export abstract class GlApp< @property({ type: Object, noAccessor: true }) private bootstrap!: State; - get state() { + get state(): State { return this._stateProvider.state; } @@ -53,9 +53,9 @@ export abstract class GlApp< private _stateProvider!: StateProvider; protected abstract createStateProvider(state: State, ipc: HostIpc): StateProvider; - protected onPersistState(_state: State) {} + protected onPersistState(_state: State): void {} - override connectedCallback() { + override connectedCallback(): void { super.connectedCallback(); this._logger = new LoggerContext(this.name); @@ -103,7 +103,7 @@ export abstract class GlApp< } } - override disconnectedCallback() { + override disconnectedCallback(): void { super.disconnectedCallback(); this._logger.log('disconnected'); @@ -113,7 +113,7 @@ export abstract class GlApp< this.disposables.forEach(d => d.dispose()); } - override render() { + override render(): unknown { return html``; } diff --git a/src/webviews/apps/shared/appBase.ts b/src/webviews/apps/shared/appBase.ts index c24c7b146f2c5..81bed743ca0d2 100644 --- a/src/webviews/apps/shared/appBase.ts +++ b/src/webviews/apps/shared/appBase.ts @@ -144,7 +144,7 @@ export abstract class App< private _inputFocused?: boolean; private bindDisposables: Disposable[] | undefined; - protected bind() { + protected bind(): void { document.querySelectorAll('a').forEach(a => { if (a.href === a.title) { a.removeAttribute('title'); @@ -206,7 +206,7 @@ export abstract class App< return this._hostIpc.sendRequest(requestType, params); } - protected setState(state: Partial) { + protected setState(state: Partial): void { this._api.setState(state); } } diff --git a/src/webviews/apps/shared/components/accordion/accordion.ts b/src/webviews/apps/shared/components/accordion/accordion.ts index eff0d6e5af2ea..f2c3d04896076 100644 --- a/src/webviews/apps/shared/components/accordion/accordion.ts +++ b/src/webviews/apps/shared/components/accordion/accordion.ts @@ -73,11 +73,11 @@ export class GlAccordion extends LitElement { @property({ type: Boolean }) open = false; - get headerId() { + get headerId(): string { return `gl-accordion-header-${this.id ?? Math.random().toString(36).substring(2, 9)}`; } - override render() { + override render(): unknown { return html`
diff --git a/src/webviews/apps/shared/components/actions/action-item.ts b/src/webviews/apps/shared/components/actions/action-item.ts index da2ba86bc7a82..f06fe50df960a 100644 --- a/src/webviews/apps/shared/components/actions/action-item.ts +++ b/src/webviews/apps/shared/components/actions/action-item.ts @@ -67,7 +67,7 @@ export class ActionItem extends LitElement { @query('a') private defaultFocusEl!: HTMLAnchorElement; - override render() { + override render(): unknown { return html` `; } diff --git a/src/webviews/apps/shared/components/avatar/avatar-list.ts b/src/webviews/apps/shared/components/avatar/avatar-list.ts index f2b3d4e05a364..842534e6d84d9 100644 --- a/src/webviews/apps/shared/components/avatar/avatar-list.ts +++ b/src/webviews/apps/shared/components/avatar/avatar-list.ts @@ -20,7 +20,7 @@ export class GlAvatarList extends LitElement { @property({ type: Array }) avatars: AvatarShape[] = []; - override render() { + override render(): unknown { return html`${this.renderList()}`; } @@ -81,7 +81,7 @@ export class GlAvatarGroup extends LitElement { `, ]; - override render() { + override render(): unknown { return html``; } } diff --git a/src/webviews/apps/shared/components/avatar/avatar.ts b/src/webviews/apps/shared/components/avatar/avatar.ts index d9f3ee4ca187c..9b4402a6b03a3 100644 --- a/src/webviews/apps/shared/components/avatar/avatar.ts +++ b/src/webviews/apps/shared/components/avatar/avatar.ts @@ -55,7 +55,7 @@ export class GlAvatar extends LitElement { @property() href?: string; - override render() { + override render(): unknown { if (this.name) { return html`${this.renderAvatar()}`; } diff --git a/src/webviews/apps/shared/components/badges/badge.ts b/src/webviews/apps/shared/components/badges/badge.ts index 594bfebcd5ad9..3996b616907d9 100644 --- a/src/webviews/apps/shared/components/badges/badge.ts +++ b/src/webviews/apps/shared/components/badges/badge.ts @@ -6,7 +6,7 @@ import { badgeBase } from './badges.css'; export class Badge extends LitElement { static override styles = [badgeBase]; - override render() { + override render(): unknown { return html``; } } diff --git a/src/webviews/apps/shared/components/branch-icon.ts b/src/webviews/apps/shared/components/branch-icon.ts index 9704935a1a517..8b1378ded4a8c 100644 --- a/src/webviews/apps/shared/components/branch-icon.ts +++ b/src/webviews/apps/shared/components/branch-icon.ts @@ -69,7 +69,7 @@ export class GlBranchIcon extends LitElement { @property({ type: Boolean }) worktree: boolean = false; - override render() { + override render(): unknown { return html`${this.renderIcon()}${this.renderTooltipContent()}`; diff --git a/src/webviews/apps/shared/components/branch-name.ts b/src/webviews/apps/shared/components/branch-name.ts index d47a79de557bc..b1dee0d3bfd62 100644 --- a/src/webviews/apps/shared/components/branch-name.ts +++ b/src/webviews/apps/shared/components/branch-name.ts @@ -1,3 +1,4 @@ +import type { TemplateResult } from 'lit'; import { css, html, LitElement } from 'lit'; import { customElement, property } from 'lit/decorators.js'; import './code-icon'; @@ -38,7 +39,7 @@ export class GlBranchName extends LitElement { @property({ type: Boolean }) worktree = false; - override render() { + override render(): unknown { return html``; } diff --git a/src/webviews/apps/shared/components/button-container.ts b/src/webviews/apps/shared/components/button-container.ts index feceb58f2b4ef..b7d59da83ab33 100644 --- a/src/webviews/apps/shared/components/button-container.ts +++ b/src/webviews/apps/shared/components/button-container.ts @@ -43,7 +43,7 @@ export class ButtonContainer extends LitElement { @property({ reflect: true }) gap?: 'wide'; - override render() { + override render(): unknown { return html`
`; } } diff --git a/src/webviews/apps/shared/components/button.ts b/src/webviews/apps/shared/components/button.ts index a41ad5b428afb..97d85843f4678 100644 --- a/src/webviews/apps/shared/components/button.ts +++ b/src/webviews/apps/shared/components/button.ts @@ -212,7 +212,7 @@ export class GlButton extends LitElement { href?: string; @property({ reflect: true }) - override get role() { + override get role(): 'link' | 'button' { return this.href ? 'link' : 'button'; } @@ -230,7 +230,7 @@ export class GlButton extends LitElement { } } - protected override render() { + protected override render(): unknown { if (this.tooltip) { return html`${this.renderControl()} { return { card: true, 'card--focusable': this.focusable, @@ -70,7 +70,7 @@ export class GlCard extends LitElement { }; } - override render() { + override render(): unknown { if (this.href != null) { return html`
${this.renderContent()} `; } - override render() { + override render(): unknown { return html`
`; } diff --git a/src/webviews/apps/shared/components/menu/menu-label.ts b/src/webviews/apps/shared/components/menu/menu-label.ts index 1f4f1de1631e6..c88717fcbf4e9 100644 --- a/src/webviews/apps/shared/components/menu/menu-label.ts +++ b/src/webviews/apps/shared/components/menu/menu-label.ts @@ -22,7 +22,7 @@ export class MenuLabel extends LitElement { `, ]; - override render() { + override render(): unknown { return html``; } } diff --git a/src/webviews/apps/shared/components/menu/menu-list.ts b/src/webviews/apps/shared/components/menu/menu-list.ts index a496b926a211f..06e9f38bd78c6 100644 --- a/src/webviews/apps/shared/components/menu/menu-list.ts +++ b/src/webviews/apps/shared/components/menu/menu-list.ts @@ -21,7 +21,7 @@ export class MenuList extends LitElement { this.role = 'listbox'; } - override render() { + override render(): unknown { return html``; } } diff --git a/src/webviews/apps/shared/components/overlays/popover.ts b/src/webviews/apps/shared/components/overlays/popover.ts index 3c7884549bf1d..886925cf43fc9 100644 --- a/src/webviews/apps/shared/components/overlays/popover.ts +++ b/src/webviews/apps/shared/components/overlays/popover.ts @@ -202,7 +202,7 @@ export class GlPopover extends GlElement { @property({ type: Boolean }) hoist = false; - get currentPlacement() { + get currentPlacement(): SlPopup['placement'] { return (this.popup?.getAttribute('data-current-placement') ?? this.placement) as SlPopup['placement']; } @@ -217,7 +217,7 @@ export class GlPopover extends GlElement { this.addEventListener('mouseout', this.handleMouseOut); } - override disconnectedCallback() { + override disconnectedCallback(): void { // Cleanup this event in case the popover is removed while open this.closeWatcher?.destroy(); document.removeEventListener('focusin', this.handlePopupBlur); @@ -227,7 +227,7 @@ export class GlPopover extends GlElement { super.disconnectedCallback(); } - override firstUpdated() { + override firstUpdated(): void { this.body.hidden = !this.open; // If the popover is visible on init, update its position @@ -237,7 +237,7 @@ export class GlPopover extends GlElement { } } - override render() { + override render(): unknown { return html`
`; } } diff --git a/src/webviews/apps/shared/components/promo.ts b/src/webviews/apps/shared/components/promo.ts index 3747346a32114..c87f3bbcfb67f 100644 --- a/src/webviews/apps/shared/components/promo.ts +++ b/src/webviews/apps/shared/components/promo.ts @@ -55,11 +55,11 @@ export class GlPromo extends LitElement { type: 'link' | 'info' = 'info'; @property({ reflect: true, type: Boolean, attribute: 'has-promo' }) - get hasPromo() { + get hasPromo(): boolean { return this.promo != null; } - override render() { + override render(): unknown { if (!this.promo) return; const promoHtml = this.renderPromo(this.promo); diff --git a/src/webviews/apps/shared/components/radio/radio-group.ts b/src/webviews/apps/shared/components/radio/radio-group.ts index 93fbecb73fd38..3dceaac9a61c1 100644 --- a/src/webviews/apps/shared/components/radio/radio-group.ts +++ b/src/webviews/apps/shared/components/radio/radio-group.ts @@ -26,7 +26,7 @@ export class RadioGroup extends GlElement { @queryAssignedElements({ flatten: true }) private radioEls!: Radio[]; - override firstUpdated() { + override firstUpdated(): void { this.role = 'group'; } @@ -40,11 +40,11 @@ export class RadioGroup extends GlElement { }); } - override render() { + override render(): unknown { return html` this.updateRadioElements(true)}>`; } - setValue(value: string) { + setValue(value: string): void { this.value = value; const event = new CustomEvent('gl-change-value'); this.dispatchEvent(event); diff --git a/src/webviews/apps/shared/components/radio/radio.ts b/src/webviews/apps/shared/components/radio/radio.ts index ca8b2417d337d..02daeff8bd665 100644 --- a/src/webviews/apps/shared/components/radio/radio.ts +++ b/src/webviews/apps/shared/components/radio/radio.ts @@ -35,23 +35,23 @@ export class Radio extends GlElement { set parentGroup(value: RadioGroup | undefined) { this._parentGroup = value; } - get parentGroup() { + get parentGroup(): RadioGroup | undefined { return this._parentGroup; } - handleClick() { + private handleClick() { if (this.value) { this.parentGroup?.setValue(this.value); } } - renderCircle() { + private renderCircle() { if (!this.checked) return undefined; return html``; } - override render() { + override render(): unknown { return html`