diff --git a/src/annotations/autolinks.ts b/src/annotations/autolinks.ts index a799637..faa112c 100644 --- a/src/annotations/autolinks.ts +++ b/src/annotations/autolinks.ts @@ -40,7 +40,7 @@ export class Autolinks implements Disposable { } dispose() { - this._disposable && this._disposable.dispose(); + this._disposable?.dispose(); } private onConfigurationChanged(e: ConfigurationChangeEvent) { diff --git a/src/annotations/fileAnnotationController.ts b/src/annotations/fileAnnotationController.ts index 44e5bb8..4aec22d 100644 --- a/src/annotations/fileAnnotationController.ts +++ b/src/annotations/fileAnnotationController.ts @@ -454,7 +454,7 @@ export class FileAnnotationController implements Disposable { if (this._annotationProviders.size === 0) { Logger.log('Remove all listener registrations for annotations'); - this._annotationsDisposable && this._annotationsDisposable.dispose(); + this._annotationsDisposable?.dispose(); this._annotationsDisposable = undefined; } diff --git a/src/codelens/codeLensProvider.ts b/src/codelens/codeLensProvider.ts index fed322b..65b2446 100644 --- a/src/codelens/codeLensProvider.ts +++ b/src/codelens/codeLensProvider.ts @@ -57,7 +57,7 @@ export class GitRecentChangeCodeLens extends CodeLens { } getBlame(): GitBlameLines | undefined { - return this.blame && this.blame(); + return this.blame?.(); } } diff --git a/src/git/formatters/commitFormatter.ts b/src/git/formatters/commitFormatter.ts index c60644d..54fc0d8 100644 --- a/src/git/formatters/commitFormatter.ts +++ b/src/git/formatters/commitFormatter.ts @@ -414,7 +414,7 @@ export class CommitFormatter extends Formatter { } get tips() { - const branchAndTagTips = this._options.getBranchAndTagTips && this._options.getBranchAndTagTips(this._item.sha); + const branchAndTagTips = this._options.getBranchAndTagTips?.(this._item.sha); if (branchAndTagTips == null) return emptyStr; return this._padOrTruncate(branchAndTagTips, this._options.tokenOptions.tips); diff --git a/src/trackers/documentTracker.ts b/src/trackers/documentTracker.ts index d00b3ba..0a1dc4c 100644 --- a/src/trackers/documentTracker.ts +++ b/src/trackers/documentTracker.ts @@ -80,7 +80,7 @@ export class DocumentTracker implements Disposable { } dispose() { - this._disposable && this._disposable.dispose(); + this._disposable?.dispose(); this.clear(); } diff --git a/src/trackers/trackedDocument.ts b/src/trackers/trackedDocument.ts index df1274c..1517819 100644 --- a/src/trackers/trackedDocument.ts +++ b/src/trackers/trackedDocument.ts @@ -38,7 +38,7 @@ export class TrackedDocument implements Disposable { dispose() { this._disposed = true; this.reset('dispose'); - this._disposable && this._disposable.dispose(); + this._disposable?.dispose(); } private async initialize(uri: Uri): Promise { diff --git a/src/views/viewBase.ts b/src/views/viewBase.ts index 436e79e..8760cfc 100644 --- a/src/views/viewBase.ts +++ b/src/views/viewBase.ts @@ -82,7 +82,7 @@ export abstract class ViewBase> implements TreeData } dispose() { - this._disposable && this._disposable.dispose(); + this._disposable?.dispose(); } getQualifiedCommand(command: string) { diff --git a/src/vsls/vsls.ts b/src/vsls/vsls.ts index 38560af..c25ef14 100644 --- a/src/vsls/vsls.ts +++ b/src/vsls/vsls.ts @@ -47,14 +47,9 @@ export class VslsController implements Disposable { } dispose() { - this._disposable && this._disposable.dispose(); - if (this._host !== undefined) { - this._host.dispose(); - } - - if (this._guest !== undefined) { - this._guest.dispose(); - } + this._disposable?.dispose(); + this._host?.dispose(); + this._guest?.dispose(); } private async initialize() { diff --git a/src/webviews/apps/shared/events.ts b/src/webviews/apps/shared/events.ts index 9854188..aaac26b 100644 --- a/src/webviews/apps/shared/events.ts +++ b/src/webviews/apps/shared/events.ts @@ -58,7 +58,7 @@ export class Emitter { this._options.onFirstListenerDidAdd(this); } - if (this._options && this._options.onListenerDidAdd) { + if (this._options?.onListenerDidAdd) { this._options.onListenerDidAdd(this, listener, thisArgs); } @@ -67,7 +67,7 @@ export class Emitter { result.dispose = Emitter._noop; if (!this._disposed) { remove(); - if (this._options && this._options.onLastListenerRemove) { + if (this._options?.onLastListenerRemove) { const hasListeners = this._listeners && !this._listeners.isEmpty(); if (!hasListeners) { this._options.onLastListenerRemove(this); diff --git a/src/webviews/webviewBase.ts b/src/webviews/webviewBase.ts index 5a76e37..b813d34 100644 --- a/src/webviews/webviewBase.ts +++ b/src/webviews/webviewBase.ts @@ -63,7 +63,7 @@ export abstract class WebviewBase implements Disposable { dispose() { this.disposable.dispose(); - this._disposablePanel && this._disposablePanel.dispose(); + this._disposablePanel?.dispose(); } protected onShowCommand() { @@ -75,7 +75,7 @@ export abstract class WebviewBase implements Disposable { } private onPanelDisposed() { - this._disposablePanel && this._disposablePanel.dispose(); + this._disposablePanel?.dispose(); this._panel = undefined; }