From 420462421d87a05c926501f8d4235f7660217924 Mon Sep 17 00:00:00 2001 From: Veetaha Date: Sun, 2 Feb 2020 21:12:59 +0200 Subject: vscode extension cleanup: migrate to prefer-const tslint rule --- editors/code/src/color_theme.ts | 2 +- editors/code/src/commands/index.ts | 2 +- editors/code/src/ctx.ts | 2 +- editors/code/src/highlighting.ts | 6 +++--- editors/code/src/inlay_hints.ts | 6 +++--- editors/code/tslint.json | 3 ++- 6 files changed, 11 insertions(+), 10 deletions(-) (limited to 'editors/code') diff --git a/editors/code/src/color_theme.ts b/editors/code/src/color_theme.ts index d816f617d..71113d374 100644 --- a/editors/code/src/color_theme.ts +++ b/editors/code/src/color_theme.ts @@ -69,7 +69,7 @@ function loadThemeNamed(themeName: string): ColorTheme { ); } - let themePaths = vscode.extensions.all + const themePaths = vscode.extensions.all .filter(isTheme) .flatMap(ext => { return ext.packageJSON.contributes.themes diff --git a/editors/code/src/commands/index.ts b/editors/code/src/commands/index.ts index dc075aa82..4501809e2 100644 --- a/editors/code/src/commands/index.ts +++ b/editors/code/src/commands/index.ts @@ -21,7 +21,7 @@ function collectGarbage(ctx: Ctx): Cmd { function showReferences(ctx: Ctx): Cmd { return (uri: string, position: lc.Position, locations: lc.Location[]) => { - let client = ctx.client; + const client = ctx.client; if (client) { vscode.commands.executeCommand( 'editor.action.showReferences', diff --git a/editors/code/src/ctx.ts b/editors/code/src/ctx.ts index a2a4e42a9..b882a8e52 100644 --- a/editors/code/src/ctx.ts +++ b/editors/code/src/ctx.ts @@ -20,7 +20,7 @@ export class Ctx { } async restartServer() { - let old = this.client; + const old = this.client; if (old) { await old.stop(); } diff --git a/editors/code/src/highlighting.ts b/editors/code/src/highlighting.ts index fc7cd5a1c..3d190c3ad 100644 --- a/editors/code/src/highlighting.ts +++ b/editors/code/src/highlighting.ts @@ -40,7 +40,7 @@ export function activateHighlighting(ctx: Ctx) { async (editor: vscode.TextEditor | undefined) => { if (!editor || editor.document.languageId !== 'rust') return; if (!ctx.config.highlightingOn) return; - let client = ctx.client; + const client = ctx.client; if (!client) return; const params: lc.TextDocumentIdentifier = { @@ -106,7 +106,7 @@ class Highlighter { } public setHighlights(editor: vscode.TextEditor, highlights: Decoration[]) { - let client = this.ctx.client; + const client = this.ctx.client; if (!client) return; // Initialize decorations if necessary // @@ -175,7 +175,7 @@ function initDecorations(): Map { const res = new Map(); TAG_TO_SCOPES.forEach((scopes, tag) => { if (!scopes) throw `unmapped tag: ${tag}`; - let rule = theme.lookup(scopes); + const rule = theme.lookup(scopes); const decor = createDecorationFromTextmate(rule); res.set(tag, decor); }); diff --git a/editors/code/src/inlay_hints.ts b/editors/code/src/inlay_hints.ts index 6357e44f1..ae7510183 100644 --- a/editors/code/src/inlay_hints.ts +++ b/editors/code/src/inlay_hints.ts @@ -127,13 +127,13 @@ class HintsUpdater { } private async queryHints(documentUri: string): Promise { - let client = this.ctx.client; + const client = this.ctx.client; if (!client) return null; const request: InlayHintsParams = { textDocument: { uri: documentUri }, }; - let tokenSource = new vscode.CancellationTokenSource(); - let prev = this.pending.get(documentUri); + const tokenSource = new vscode.CancellationTokenSource(); + const prev = this.pending.get(documentUri); if (prev) prev.cancel(); this.pending.set(documentUri, tokenSource); try { diff --git a/editors/code/tslint.json b/editors/code/tslint.json index 318e02b4b..0df11b2f1 100644 --- a/editors/code/tslint.json +++ b/editors/code/tslint.json @@ -3,6 +3,7 @@ "semicolon": [ true, "always" - ] + ], + "prefer-const": true } } -- cgit v1.2.3