diff options
author | Johannes <johannes.rieken@gmail.com> | 2022-06-09 11:19:56 +0300 |
---|---|---|
committer | Johannes <johannes.rieken@gmail.com> | 2022-06-09 11:19:56 +0300 |
commit | 43c31079ee2a55f111ff9e81bbb1ac12397a9b05 (patch) | |
tree | 2572a4fd7c53cae1a992bae8cf6a161078400ce7 /src | |
parent | 0f6f41890b447ddce374813daed1234eb3942539 (diff) |
manual fixing of prefer-const violations
Diffstat (limited to 'src')
32 files changed, 85 insertions, 89 deletions
diff --git a/src/vs/base/browser/touch.ts b/src/vs/base/browser/touch.ts index 5fe42ba71cb..37cf61a979c 100644 --- a/src/vs/base/browser/touch.ts +++ b/src/vs/base/browser/touch.ts @@ -292,9 +292,9 @@ export class Gesture extends Disposable { const now = Date.now(); // velocity: old speed + accel_over_time - let deltaT = now - t1, - delta_pos_x = 0, delta_pos_y = 0, - stopped = true; + const deltaT = now - t1; + let delta_pos_x = 0, delta_pos_y = 0; + let stopped = true; vX += Gesture.SCROLL_FRICTION * deltaT; vY += Gesture.SCROLL_FRICTION * deltaT; diff --git a/src/vs/base/common/event.ts b/src/vs/base/common/event.ts index 08327f6dca0..71d1b811735 100644 --- a/src/vs/base/common/event.ts +++ b/src/vs/base/common/event.ts @@ -60,8 +60,7 @@ export namespace Event { return (listener, thisArgs = null, disposables?) => { // we need this, in case the event fires during the listener call let didFire = false; - let result: IDisposable; - result = event(e => { + const result = event(e => { if (didFire) { return; } else if (result) { diff --git a/src/vs/base/common/json.ts b/src/vs/base/common/json.ts index db725117b2b..dadcbaf74f1 100644 --- a/src/vs/base/common/json.ts +++ b/src/vs/base/common/json.ts @@ -200,12 +200,12 @@ export interface JSONVisitor { */ export function createScanner(text: string, ignoreTrivia: boolean = false): JSONScanner { - let pos = 0, - len = text.length, - value: string = '', - tokenOffset = 0, - token: SyntaxKind = SyntaxKind.Unknown, - scanError: ScanError = ScanError.None; + let pos = 0; + const len = text.length; + let value: string = ''; + let tokenOffset = 0; + let token: SyntaxKind = SyntaxKind.Unknown; + let scanError: ScanError = ScanError.None; function scanHexDigits(count: number): number { let digits = 0; @@ -1315,11 +1315,11 @@ export function visit(text: string, visitor: JSONVisitor, options: ParseOptions */ export function stripComments(text: string, replaceCh?: string): string { - let _scanner = createScanner(text), - parts: string[] = [], - kind: SyntaxKind, - offset = 0, - pos: number; + const _scanner = createScanner(text); + const parts: string[] = []; + let kind: SyntaxKind; + let offset = 0; + let pos: number; do { pos = _scanner.getPosition(); diff --git a/src/vs/base/common/resources.ts b/src/vs/base/common/resources.ts index 4bcd8fb899f..ee48280997a 100644 --- a/src/vs/base/common/resources.ts +++ b/src/vs/base/common/resources.ts @@ -240,7 +240,8 @@ export class ExtUri implements IExtUri { const relativePath = paths.relative(originalFSPath(from), originalFSPath(to)); return isWindows ? extpath.toSlashes(relativePath) : relativePath; } - let fromPath = from.path || '/', toPath = to.path || '/'; + let fromPath = from.path || '/'; + const toPath = to.path || '/'; if (this._ignorePathCasing(from)) { // make casing of fromPath match toPath let i = 0; diff --git a/src/vs/base/common/strings.ts b/src/vs/base/common/strings.ts index 3849f6905cd..28425d89a40 100644 --- a/src/vs/base/common/strings.ts +++ b/src/vs/base/common/strings.ts @@ -404,8 +404,8 @@ export function startsWithIgnoreCase(str: string, candidate: string): boolean { */ export function commonPrefixLength(a: string, b: string): number { - let i: number, - len = Math.min(a.length, b.length); + const len = Math.min(a.length, b.length); + let i: number; for (i = 0; i < len; i++) { if (a.charCodeAt(i) !== b.charCodeAt(i)) { @@ -421,8 +421,8 @@ export function commonPrefixLength(a: string, b: string): number { */ export function commonSuffixLength(a: string, b: string): number { - let i: number, - len = Math.min(a.length, b.length); + const len = Math.min(a.length, b.length); + let i: number; const aLastIndex = a.length - 1; const bLastIndex = b.length - 1; diff --git a/src/vs/base/parts/ipc/common/ipc.net.ts b/src/vs/base/parts/ipc/common/ipc.net.ts index 034f4a2c9ff..5d464d87e87 100644 --- a/src/vs/base/parts/ipc/common/ipc.net.ts +++ b/src/vs/base/parts/ipc/common/ipc.net.ts @@ -675,7 +675,8 @@ class Queue<T> { } public toArray(): T[] { - let result: T[] = [], resultLen = 0; + const result: T[] = []; + let resultLen = 0; let it = this._first; while (it) { result[resultLen++] = it.data; diff --git a/src/vs/base/test/common/scrollable.test.ts b/src/vs/base/test/common/scrollable.test.ts index 22a6bfd1971..17c9eacce57 100644 --- a/src/vs/base/test/common/scrollable.test.ts +++ b/src/vs/base/test/common/scrollable.test.ts @@ -45,7 +45,8 @@ suite('SmoothScrollingOperation', () => { function simulateSmoothScroll(from: number, to: number): [number, number][] { const scrollable = new TestSmoothScrollingOperation(from, to, VIEWPORT_HEIGHT, 0, ANIMATION_DURATION); - let result: [number, number][] = [], resultLen = 0; + const result: [number, number][] = []; + let resultLen = 0; result[resultLen++] = extractLines(scrollable, 0); result[resultLen++] = extractLines(scrollable, 25); result[resultLen++] = extractLines(scrollable, 50); diff --git a/src/vs/editor/browser/viewParts/lines/viewLines.ts b/src/vs/editor/browser/viewParts/lines/viewLines.ts index 592fae0011c..e0ff5f222c4 100644 --- a/src/vs/editor/browser/viewParts/lines/viewLines.ts +++ b/src/vs/editor/browser/viewParts/lines/viewLines.ts @@ -412,7 +412,8 @@ export class ViewLines extends ViewPart implements IVisibleLinesHost<ViewLine>, return null; } - let visibleRanges: LineVisibleRanges[] = [], visibleRangesLen = 0; + const visibleRanges: LineVisibleRanges[] = []; + let visibleRangesLen = 0; const domReadingContext = new DomReadingContext(this.domNode.domNode, this._textRangeRestingSpot); let nextLineModelLineNumber: number = 0; diff --git a/src/vs/editor/common/model/pieceTreeTextBuffer/pieceTreeBase.ts b/src/vs/editor/common/model/pieceTreeTextBuffer/pieceTreeBase.ts index cfd8e3d31a6..ae32355c72c 100644 --- a/src/vs/editor/common/model/pieceTreeTextBuffer/pieceTreeBase.ts +++ b/src/vs/editor/common/model/pieceTreeTextBuffer/pieceTreeBase.ts @@ -1768,11 +1768,10 @@ export class PieceTreeBase { return ''; } const buffer = this._buffers[node.piece.bufferIndex]; - let currentContent; const piece = node.piece; const startOffset = this.offsetInBuffer(piece.bufferIndex, piece.start); const endOffset = this.offsetInBuffer(piece.bufferIndex, piece.end); - currentContent = buffer.buffer.substring(startOffset, endOffset); + const currentContent = buffer.buffer.substring(startOffset, endOffset); return currentContent; } diff --git a/src/vs/editor/common/viewModel/viewModelLines.ts b/src/vs/editor/common/viewModel/viewModelLines.ts index f2cb108aced..c154683272b 100644 --- a/src/vs/editor/common/viewModel/viewModelLines.ts +++ b/src/vs/editor/common/viewModel/viewModelLines.ts @@ -943,7 +943,8 @@ export class ViewModelLinesFromProjectedModel implements IViewModelLines { }); // Eliminate duplicate decorations that might have intersected our visible ranges multiple times - let finalResult: IModelDecoration[] = [], finalResultLen = 0; + const finalResult: IModelDecoration[] = []; + let finalResultLen = 0; let prevDecId: string | null = null; for (const dec of result) { const decId = dec.id; diff --git a/src/vs/editor/contrib/bracketMatching/browser/bracketMatching.ts b/src/vs/editor/contrib/bracketMatching/browser/bracketMatching.ts index 3a1b7b73788..d43fb6f30db 100644 --- a/src/vs/editor/contrib/bracketMatching/browser/bracketMatching.ts +++ b/src/vs/editor/contrib/bracketMatching/browser/bracketMatching.ts @@ -275,7 +275,8 @@ export class BracketMatchingController extends Disposable implements IEditorCont } this._recomputeBrackets(); - let newDecorations: IModelDeltaDecoration[] = [], newDecorationsLen = 0; + const newDecorations: IModelDeltaDecoration[] = []; + let newDecorationsLen = 0; for (const bracketData of this._lastBracketsData) { const brackets = bracketData.brackets; if (brackets) { @@ -311,7 +312,8 @@ export class BracketMatchingController extends Disposable implements IEditorCont previousData = this._lastBracketsData; } - let positions: Position[] = [], positionsLen = 0; + const positions: Position[] = []; + let positionsLen = 0; for (let i = 0, len = selections.length; i < len; i++) { const selection = selections[i]; @@ -326,8 +328,10 @@ export class BracketMatchingController extends Disposable implements IEditorCont positions.sort(Position.compare); } - let newData: BracketsData[] = [], newDataLen = 0; - let previousIndex = 0, previousLen = previousData.length; + const newData: BracketsData[] = []; + let newDataLen = 0; + let previousIndex = 0; + const previousLen = previousData.length; for (let i = 0, len = positions.length; i < len; i++) { const position = positions[i]; diff --git a/src/vs/editor/contrib/message/browser/messageController.ts b/src/vs/editor/contrib/message/browser/messageController.ts index b22b6b7ceec..c6a91a6e8a5 100644 --- a/src/vs/editor/contrib/message/browser/messageController.ts +++ b/src/vs/editor/contrib/message/browser/messageController.ts @@ -130,13 +130,12 @@ class MessageWidget implements IContentWidget { private readonly _domNode: HTMLDivElement; static fadeOut(messageWidget: MessageWidget): IDisposable { - let handle: any; const dispose = () => { messageWidget.dispose(); clearTimeout(handle); messageWidget.getDomNode().removeEventListener('animationend', dispose); }; - handle = setTimeout(dispose, 110); + const handle = setTimeout(dispose, 110); messageWidget.getDomNode().addEventListener('animationend', dispose); messageWidget.getDomNode().classList.add('fadeOut'); return { dispose }; diff --git a/src/vs/editor/contrib/snippet/test/browser/snippetVariables.test.ts b/src/vs/editor/contrib/snippet/test/browser/snippetVariables.test.ts index fc53766a32e..286f02e7d74 100644 --- a/src/vs/editor/contrib/snippet/test/browser/snippetVariables.test.ts +++ b/src/vs/editor/contrib/snippet/test/browser/snippetVariables.test.ts @@ -351,7 +351,6 @@ suite('Snippet Variables Resolver', function () { test('Add workspace name and folder variables for snippets #68261', function () { let workspace: IWorkspace; - let resolver: VariableResolver; const workspaceService = new class implements IWorkspaceContextService { declare readonly _serviceBrand: undefined; _throw = () => { throw new Error(); }; @@ -367,7 +366,7 @@ suite('Snippet Variables Resolver', function () { isInsideWorkspace = this._throw; }; - resolver = new WorkspaceBasedVariableResolver(workspaceService); + const resolver = new WorkspaceBasedVariableResolver(workspaceService); // empty workspace workspace = new Workspace(''); diff --git a/src/vs/editor/test/common/model/pieceTreeTextBuffer/pieceTreeTextBuffer.test.ts b/src/vs/editor/test/common/model/pieceTreeTextBuffer/pieceTreeTextBuffer.test.ts index 313604495dc..d6382e4e7ac 100644 --- a/src/vs/editor/test/common/model/pieceTreeTextBuffer/pieceTreeTextBuffer.test.ts +++ b/src/vs/editor/test/common/model/pieceTreeTextBuffer/pieceTreeTextBuffer.test.ts @@ -30,8 +30,8 @@ function randomStr(len: number) { len = 10; } return (function () { - let j, ref, results; - results = []; + let j, ref; + const results = []; for ( j = 1, ref = len; 1 <= ref ? j < ref : j > ref; diff --git a/src/vs/platform/extensions/common/extensionValidator.ts b/src/vs/platform/extensions/common/extensionValidator.ts index 75b35fb27a7..0a5e7d20d21 100644 --- a/src/vs/platform/extensions/common/extensionValidator.ts +++ b/src/vs/platform/extensions/common/extensionValidator.ts @@ -84,12 +84,12 @@ export function normalizeVersion(version: IParsedVersion | null): INormalizedVer return null; } - let majorBase = version.majorBase, - majorMustEqual = version.majorMustEqual, - minorBase = version.minorBase, - minorMustEqual = version.minorMustEqual, - patchBase = version.patchBase, - patchMustEqual = version.patchMustEqual; + const majorBase = version.majorBase; + const majorMustEqual = version.majorMustEqual; + const minorBase = version.minorBase; + let minorMustEqual = version.minorMustEqual; + const patchBase = version.patchBase; + let patchMustEqual = version.patchMustEqual; if (version.hasCaret) { if (majorBase === 0) { diff --git a/src/vs/platform/keybinding/common/keybindingResolver.ts b/src/vs/platform/keybinding/common/keybindingResolver.ts index e2cc248de2a..a76a8a8da14 100644 --- a/src/vs/platform/keybinding/common/keybindingResolver.ts +++ b/src/vs/platform/keybinding/common/keybindingResolver.ts @@ -242,7 +242,8 @@ export class KeybindingResolver { } // Reverse to get the most specific item first - let result: ResolvedKeybindingItem[] = [], resultLen = 0; + const result: ResolvedKeybindingItem[] = []; + let resultLen = 0; for (let i = items.length - 1; i >= 0; i--) { result[resultLen++] = items[i]; } diff --git a/src/vs/platform/keybinding/common/keybindingsRegistry.ts b/src/vs/platform/keybinding/common/keybindingsRegistry.ts index 75c0bd4dec2..76bd12cbd0a 100644 --- a/src/vs/platform/keybinding/common/keybindingsRegistry.ts +++ b/src/vs/platform/keybinding/common/keybindingsRegistry.ts @@ -130,7 +130,8 @@ class KeybindingsRegistryImpl implements IKeybindingsRegistry { } public setExtensionKeybindings(rules: IExtensionKeybindingRule[]): void { - let result: IKeybindingItem[] = [], keybindingsLen = 0; + const result: IKeybindingItem[] = []; + let keybindingsLen = 0; for (const rule of rules) { if (rule.keybinding.length > 0) { result[keybindingsLen++] = { diff --git a/src/vs/platform/request/node/requestService.ts b/src/vs/platform/request/node/requestService.ts index 042ae6be1b5..640526f89a9 100644 --- a/src/vs/platform/request/node/requestService.ts +++ b/src/vs/platform/request/node/requestService.ts @@ -114,7 +114,6 @@ export class RequestService extends Disposable implements IRequestService { private _request(options: NodeRequestOptions, token: CancellationToken): Promise<IRequestContext> { return Promises.withAsyncBody<IRequestContext>(async (c, e) => { - let req: http.ClientRequest; const endpoint = parseUrl(options.url!); const rawRequest = options.getRawRequest @@ -136,7 +135,7 @@ export class RequestService extends Disposable implements IRequestService { opts.auth = options.user + ':' + options.password; } - req = rawRequest(opts, (res: http.IncomingMessage) => { + const req = rawRequest(opts, (res: http.IncomingMessage) => { const followRedirects: number = isNumber(options.followRedirects) ? options.followRedirects : 3; if (res.statusCode && res.statusCode >= 300 && res.statusCode < 400 && followRedirects > 0 && res.headers['location']) { this._request({ diff --git a/src/vs/platform/terminal/common/terminalDataBuffering.ts b/src/vs/platform/terminal/common/terminalDataBuffering.ts index 07d42978b80..21432ca631e 100644 --- a/src/vs/platform/terminal/common/terminalDataBuffering.ts +++ b/src/vs/platform/terminal/common/terminalDataBuffering.ts @@ -25,8 +25,8 @@ export class TerminalDataBufferer implements IDisposable { } startBuffering(id: number, event: Event<string | IProcessDataEvent>, throttleBy: number = 5): IDisposable { - let disposable: IDisposable; - disposable = event((e: string | IProcessDataEvent) => { + + const disposable = event((e: string | IProcessDataEvent) => { const data = (typeof e === 'string' ? e : e.data); let buffer = this._terminalBufferMap.get(id); if (buffer) { diff --git a/src/vs/workbench/api/browser/mainThreadDocuments.ts b/src/vs/workbench/api/browser/mainThreadDocuments.ts index 1c68dca1c7d..1ef0daed53e 100644 --- a/src/vs/workbench/api/browser/mainThreadDocuments.ts +++ b/src/vs/workbench/api/browser/mainThreadDocuments.ts @@ -50,8 +50,6 @@ export class BoundModelReferenceCollection { add(uri: URI, ref: IReference<any>, length: number = 0): void { // const length = ref.object.textEditorModel.getValueLength(); - let handle: any; - let entry: { uri: URI; length: number; dispose(): void }; const dispose = () => { const idx = this._data.indexOf(entry); if (idx >= 0) { @@ -61,8 +59,8 @@ export class BoundModelReferenceCollection { this._data.splice(idx, 1); } }; - handle = setTimeout(dispose, this._maxAge); - entry = { uri, length, dispose }; + const handle = setTimeout(dispose, this._maxAge); + const entry = { uri, length, dispose }; this._data.push(entry); this._length += length; diff --git a/src/vs/workbench/api/browser/mainThreadDocumentsAndEditors.ts b/src/vs/workbench/api/browser/mainThreadDocumentsAndEditors.ts index 12b5786f94f..ee02d71d2dc 100644 --- a/src/vs/workbench/api/browser/mainThreadDocumentsAndEditors.ts +++ b/src/vs/workbench/api/browser/mainThreadDocumentsAndEditors.ts @@ -5,7 +5,6 @@ import { Event } from 'vs/base/common/event'; import { IDisposable, combinedDisposable, DisposableStore } from 'vs/base/common/lifecycle'; -import { URI } from 'vs/base/common/uri'; import { ICodeEditor, isCodeEditor, isDiffEditor, IActiveCodeEditor } from 'vs/editor/browser/editorBrowser'; import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService'; import { IEditor } from 'vs/editor/common/editorCommon'; @@ -317,12 +316,11 @@ export class MainThreadDocumentsAndEditors { private _onDelta(delta: DocumentAndEditorStateDelta): void { - let removedDocuments: URI[]; const removedEditors: string[] = []; const addedEditors: MainThreadTextEditor[] = []; // removed models - removedDocuments = delta.removedDocuments.map(m => m.uri); + const removedDocuments = delta.removedDocuments.map(m => m.uri); // added editors for (const apiEditor of delta.addedEditors) { diff --git a/src/vs/workbench/api/test/browser/extHostApiCommands.test.ts b/src/vs/workbench/api/test/browser/extHostApiCommands.test.ts index e948e2b7da0..a1424c0ce6f 100644 --- a/src/vs/workbench/api/test/browser/extHostApiCommands.test.ts +++ b/src/vs/workbench/api/test/browser/extHostApiCommands.test.ts @@ -24,7 +24,6 @@ import { ExtHostDocumentsAndEditors } from 'vs/workbench/api/common/extHostDocum import { MainContext, ExtHostContext } from 'vs/workbench/api/common/extHost.protocol'; import { ExtHostDiagnostics } from 'vs/workbench/api/common/extHostDiagnostics'; import type * as vscode from 'vscode'; -import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import 'vs/workbench/contrib/search/browser/search.contribution'; import { ILogService, NullLogService } from 'vs/platform/log/common/log'; import { ITextModel } from 'vs/editor/common/model'; @@ -94,7 +93,6 @@ suite('ExtHostLanguageFeatureCommands', function () { setUnexpectedErrorHandler(() => { }); // Use IInstantiationService to get typechecking when instantiating - let insta: IInstantiationService; rpcProtocol = new TestRPCProtocol(); const services = new ServiceCollection(); services.set(ILanguageFeaturesService, new SyncDescriptor(LanguageFeaturesService)); @@ -137,7 +135,7 @@ suite('ExtHostLanguageFeatureCommands', function () { services.set(ILanguageFeatureDebounceService, new SyncDescriptor(LanguageFeatureDebounceService)); services.set(IOutlineModelService, new SyncDescriptor(OutlineModelService)); - insta = new InstantiationService(services); + const insta = new InstantiationService(services); const extHostDocumentsAndEditors = new ExtHostDocumentsAndEditors(rpcProtocol, new NullLogService()); extHostDocumentsAndEditors.$acceptDocumentsAndEditorsDelta({ diff --git a/src/vs/workbench/contrib/comments/browser/commentNode.ts b/src/vs/workbench/contrib/comments/browser/commentNode.ts index 78f7ae0b901..7babdf9a73d 100644 --- a/src/vs/workbench/contrib/comments/browser/commentNode.ts +++ b/src/vs/workbench/contrib/comments/browser/commentNode.ts @@ -274,7 +274,6 @@ export class CommentNode<T extends IRange | ICellRange> extends Disposable { } private createReactionPicker(reactionGroup: languages.CommentReaction[]): ToggleReactionsAction { - let toggleReactionActionViewItem: DropdownMenuActionViewItem; const toggleReactionAction = this._register(new ToggleReactionsAction(() => { if (toggleReactionActionViewItem) { toggleReactionActionViewItem.show(); @@ -299,7 +298,7 @@ export class CommentNode<T extends IRange | ICellRange> extends Disposable { toggleReactionAction.menuActions = reactionMenuActions; - toggleReactionActionViewItem = new DropdownMenuActionViewItem( + const toggleReactionActionViewItem: DropdownMenuActionViewItem = new DropdownMenuActionViewItem( toggleReactionAction, (<ToggleReactionsAction>toggleReactionAction).menuActions, this.contextMenuService, diff --git a/src/vs/workbench/contrib/remote/browser/remoteExplorer.ts b/src/vs/workbench/contrib/remote/browser/remoteExplorer.ts index 935ba605c07..10abb46d232 100644 --- a/src/vs/workbench/contrib/remote/browser/remoteExplorer.ts +++ b/src/vs/workbench/contrib/remote/browser/remoteExplorer.ts @@ -131,10 +131,9 @@ export class ForwardedPortsView extends Disposable implements IWorkbenchContribu } private get entry(): IStatusbarEntry { - let text: string; let tooltip: string; const count = this.remoteExplorerService.tunnelModel.forwarded.size + this.remoteExplorerService.tunnelModel.detected.size; - text = `${count}`; + const text = `${count}`; if (count === 0) { tooltip = nls.localize('remote.forwardedPorts.statusbarTextNone', "No Ports Forwarded"); } else { diff --git a/src/vs/workbench/contrib/themes/browser/themes.test.contribution.ts b/src/vs/workbench/contrib/themes/browser/themes.test.contribution.ts index 6d4426b1845..8560807503e 100644 --- a/src/vs/workbench/contrib/themes/browser/themes.test.contribution.ts +++ b/src/vs/workbench/contrib/themes/browser/themes.test.contribution.ts @@ -99,7 +99,8 @@ class Snapper { private _themedTokenize(grammar: IGrammar, lines: string[]): IThemedToken[] { const colorMap = TokenizationRegistry.getColorMap(); let state: StackElement | null = null; - let result: IThemedToken[] = [], resultLen = 0; + const result: IThemedToken[] = []; + let resultLen = 0; for (let i = 0, len = lines.length; i < len; i++) { const line = lines[i]; diff --git a/src/vs/workbench/services/configuration/test/browser/configurationService.test.ts b/src/vs/workbench/services/configuration/test/browser/configurationService.test.ts index d36be57c247..1321ba55e70 100644 --- a/src/vs/workbench/services/configuration/test/browser/configurationService.test.ts +++ b/src/vs/workbench/services/configuration/test/browser/configurationService.test.ts @@ -66,7 +66,9 @@ const ROOT = URI.file('tests').with({ scheme: 'vscode-tests' }); suite('WorkspaceContextService - Folder', () => { - let folderName = 'Folder A', folder: URI, testObject: WorkspaceService; + const folderName = 'Folder A'; + let folder: URI; + let testObject: WorkspaceService; const disposables = new DisposableStore(); setup(async () => { diff --git a/src/vs/workbench/services/configurationResolver/test/electron-browser/configurationResolverService.test.ts b/src/vs/workbench/services/configurationResolver/test/electron-browser/configurationResolverService.test.ts index a8b7b479e61..a17e27f7917 100644 --- a/src/vs/workbench/services/configurationResolver/test/electron-browser/configurationResolverService.test.ts +++ b/src/vs/workbench/services/configurationResolver/test/electron-browser/configurationResolverService.test.ts @@ -245,8 +245,7 @@ suite('Configuration Resolver Service', () => { }); test('substitute many configuration variables', async () => { - let configurationService: IConfigurationService; - configurationService = new TestConfigurationService({ + const configurationService = new TestConfigurationService({ editor: { fontFamily: 'foo' }, @@ -262,8 +261,7 @@ suite('Configuration Resolver Service', () => { }); test('substitute one env variable and a configuration variable', async () => { - let configurationService: IConfigurationService; - configurationService = new TestConfigurationService({ + const configurationService = new TestConfigurationService({ editor: { fontFamily: 'foo' }, @@ -283,8 +281,7 @@ suite('Configuration Resolver Service', () => { }); test('substitute many env variable and a configuration variable', async () => { - let configurationService: IConfigurationService; - configurationService = new TestConfigurationService({ + const configurationService = new TestConfigurationService({ editor: { fontFamily: 'foo' }, @@ -304,8 +301,7 @@ suite('Configuration Resolver Service', () => { }); test('mixed types of configuration variables', async () => { - let configurationService: IConfigurationService; - configurationService = new TestConfigurationService({ + const configurationService = new TestConfigurationService({ editor: { fontFamily: 'foo', lineNumbers: 123, @@ -334,8 +330,7 @@ suite('Configuration Resolver Service', () => { }); test('uses original variable as fallback', async () => { - let configurationService: IConfigurationService; - configurationService = new TestConfigurationService({ + const configurationService = new TestConfigurationService({ editor: {} }); @@ -345,8 +340,7 @@ suite('Configuration Resolver Service', () => { }); test('configuration variables with invalid accessor', () => { - let configurationService: IConfigurationService; - configurationService = new TestConfigurationService({ + const configurationService = new TestConfigurationService({ editor: { fontFamily: 'foo' } diff --git a/src/vs/workbench/services/extensionManagement/browser/webExtensionsScannerService.ts b/src/vs/workbench/services/extensionManagement/browser/webExtensionsScannerService.ts index ddfd1f6b896..f60c7895643 100644 --- a/src/vs/workbench/services/extensionManagement/browser/webExtensionsScannerService.ts +++ b/src/vs/workbench/services/extensionManagement/browser/webExtensionsScannerService.ts @@ -108,7 +108,8 @@ export class WebExtensionsScannerService extends Disposable implements IWebExten private readCustomBuiltinExtensionsInfoFromEnv(): Promise<{ extensions: ExtensionInfo[]; extensionsToMigrate: [string, string][]; extensionLocations: URI[] }> { if (!this._customBuiltinExtensionsInfoPromise) { this._customBuiltinExtensionsInfoPromise = (async () => { - let extensions: ExtensionInfo[] = [], extensionLocations: URI[] = []; + let extensions: ExtensionInfo[] = []; + const extensionLocations: URI[] = []; const extensionsToMigrate: [string, string][] = []; const customBuiltinExtensionsInfo = this.environmentService.options && Array.isArray(this.environmentService.options.additionalBuiltinExtensions) ? this.environmentService.options.additionalBuiltinExtensions.map(additionalBuiltinExtension => isString(additionalBuiltinExtension) ? { id: additionalBuiltinExtension } : additionalBuiltinExtension) diff --git a/src/vs/workbench/services/keybinding/common/macLinuxKeyboardMapper.ts b/src/vs/workbench/services/keybinding/common/macLinuxKeyboardMapper.ts index dc4c43558a9..30a25ac9d0b 100644 --- a/src/vs/workbench/services/keybinding/common/macLinuxKeyboardMapper.ts +++ b/src/vs/workbench/services/keybinding/common/macLinuxKeyboardMapper.ts @@ -497,7 +497,8 @@ export class MacLinuxKeyboardMapper implements IKeyboardMapper { _registerLetterIfMissing(CharCode.Z, ScanCode.KeyZ, 'z', 'Z'); } - let mappings: IScanCodeMapping[] = [], mappingsLen = 0; + const mappings: IScanCodeMapping[] = []; + let mappingsLen = 0; for (const strScanCode in rawMappings) { if (rawMappings.hasOwnProperty(strScanCode)) { const scanCode = ScanCodeUtils.toEnum(strScanCode); diff --git a/src/vs/workbench/services/notification/common/notificationService.ts b/src/vs/workbench/services/notification/common/notificationService.ts index b18c46c2f4f..ea3df42e4f9 100644 --- a/src/vs/workbench/services/notification/common/notificationService.ts +++ b/src/vs/workbench/services/notification/common/notificationService.ts @@ -96,7 +96,7 @@ export class NotificationService extends Disposable implements INotificationServ const toDispose = new DisposableStore(); // Handle neverShowAgain option accordingly - let handle: INotificationHandle; + if (notification.neverShowAgain) { const scope = notification.neverShowAgain.scope === NeverShowAgainScope.WORKSPACE ? StorageScope.WORKSPACE : StorageScope.GLOBAL; const id = notification.neverShowAgain.id; @@ -134,7 +134,7 @@ export class NotificationService extends Disposable implements INotificationServ } // Show notification - handle = this.model.addNotification(notification); + const handle = this.model.addNotification(notification); // Cleanup when notification gets disposed Event.once(handle.onDidClose)(() => toDispose.dispose()); @@ -171,7 +171,7 @@ export class NotificationService extends Disposable implements INotificationServ } let choiceClicked = false; - let handle: INotificationHandle; + // Convert choices into primary/secondary actions const primaryActions: IAction[] = []; @@ -199,7 +199,7 @@ export class NotificationService extends Disposable implements INotificationServ // Show notification with actions const actions: INotificationActions = { primary: primaryActions, secondary: secondaryActions }; - handle = this.notify({ severity, message, actions, sticky: options?.sticky, silent: options?.silent }); + const handle = this.notify({ severity, message, actions, sticky: options?.sticky, silent: options?.silent }); Event.once(handle.onDidClose)(() => { diff --git a/src/vs/workbench/services/search/node/fileSearch.ts b/src/vs/workbench/services/search/node/fileSearch.ts index e6b9bb1633c..a7afc5cae5b 100644 --- a/src/vs/workbench/services/search/node/fileSearch.ts +++ b/src/vs/workbench/services/search/node/fileSearch.ts @@ -184,7 +184,7 @@ export class FileWalker { private cmdTraversal(folderQuery: IFolderQuery, onResult: (result: IRawFileMatch) => void, onMessage: (message: IProgressMessage) => void, cb: (err?: Error) => void): void { const rootFolder = folderQuery.folder.fsPath; const isMac = platform.isMacintosh; - let cmd: childProcess.ChildProcess; + const killCmd = () => cmd && cmd.kill(); killCmds.add(killCmd); @@ -196,10 +196,9 @@ export class FileWalker { let leftover = ''; const tree = this.initDirectoryTree(); - let noSiblingsClauses: boolean; const ripgrep = spawnRipgrepCmd(this.config, folderQuery, this.config.includePattern, this.folderExcludePatterns.get(folderQuery.folder.fsPath)!.expression); - cmd = ripgrep.cmd; - noSiblingsClauses = !Object.keys(ripgrep.siblingClauses).length; + const cmd = ripgrep.cmd; + const noSiblingsClauses = !Object.keys(ripgrep.siblingClauses).length; const escapedArgs = ripgrep.rgArgs.args .map(arg => arg.match(/^-/) ? arg : `'${arg}'`) diff --git a/src/vs/workbench/services/textfile/test/browser/textFileEditorModel.test.ts b/src/vs/workbench/services/textfile/test/browser/textFileEditorModel.test.ts index bb5c8048907..0fc86c74e4f 100644 --- a/src/vs/workbench/services/textfile/test/browser/textFileEditorModel.test.ts +++ b/src/vs/workbench/services/textfile/test/browser/textFileEditorModel.test.ts @@ -821,7 +821,7 @@ suite('Files - TextFileEditorModel', () => { }); async function testSaveFromSaveParticipant(model: TextFileEditorModel, async: boolean): Promise<void> { - let savePromise: Promise<boolean>; + let breakLoop = false; const participant = accessor.textFileService.files.addSaveParticipant({ @@ -845,7 +845,7 @@ suite('Files - TextFileEditorModel', () => { await model.resolve(); model.updateTextEditorModel(createTextBufferFactory('foo')); - savePromise = model.save(); + const savePromise = model.save(); await savePromise; participant.dispose(); |