Skip to content

Commit bd6d0b1

Browse files
committed
(es)lint: fixes
1 parent 08080b4 commit bd6d0b1

27 files changed

+106
-86
lines changed

package-lock.json

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/commands/find-buf.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export const findBuf = new Command(
6666
);
6767

6868
const findBufInPath = async (): Promise<BufVersion | null> => {
69-
let bufPath = await which(bufFilename, { nothrow: true });
69+
const bufPath = await which(bufFilename, { nothrow: true });
7070

7171
if (bufPath) {
7272
return BufVersion.fromPath(bufPath);

src/commands/index.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,30 @@
1+
/* eslint-disable @typescript-eslint/no-explicit-any */
12
import * as vscode from "vscode";
23

34
import { BufContext } from "../context";
45

5-
type CommandCallback<T extends unknown = any> = (
6-
...args: any
7-
) => Promise<T> | T;
6+
type CommandCallback<T = any> = (...args: any) => Promise<T> | T;
87

9-
export type CommandFactory<T extends unknown = any> = (
8+
export type CommandFactory<T = any> = (
109
ctx: vscode.ExtensionContext,
1110
bufCtx: BufContext
1211
) => CommandCallback<T>;
1312

1413
export enum CommandType {
1514
// Commands to run buf commands e.g. generate
16-
// eslint-disable-next-line @typescript-eslint/naming-convention
1715
COMMAND_BUF,
1816

1917
// Extension commands
20-
// eslint-disable-next-line @typescript-eslint/naming-convention
2118
COMMAND_EXTENSION,
2219

2320
// Commands to setup the extension e.g. install buf
24-
// eslint-disable-next-line @typescript-eslint/naming-convention
2521
COMMAND_SETUP,
2622

2723
// Internal commands. Note: these are not registered in the command palette
28-
// eslint-disable-next-line @typescript-eslint/naming-convention
2924
COMMAND_INTERNAL,
3025
}
3126

32-
export class Command<T extends unknown = any> {
27+
export class Command<T = any> {
3328
constructor(
3429
public readonly command: string,
3530
public readonly type: CommandType,

src/commands/install-buf.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const installBuf = new Command(
3535
const release = await github.latestRelease();
3636
const asset = await github.findAsset(release);
3737

38-
var bufPath = await install(ctx, release, asset, abort);
38+
const bufPath = await install(ctx, release, asset, abort);
3939

4040
bufCtx.buf = await BufVersion.fromPath(bufPath);
4141
vscode.window.showInformationMessage(
@@ -76,7 +76,9 @@ export const install = async (
7676

7777
// If we made it to this point, the binary is valid, reuse it.
7878
return downloadBin;
79-
} catch {}
79+
} catch {
80+
// Ignore errors, we will download it.
81+
}
8082

8183
// If we've fallen out here.. lets proceed to download.
8284
log.info(`Downloading ${asset.name} to ${downloadBin}...`);

src/commands/restart-buf.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export const restartBuf = new Command(
5151

5252
const traceFile = config.get<string>("trace");
5353

54-
if (!!traceFile) {
54+
if (traceFile) {
5555
const trace = { BUF_TRACE: traceFile };
5656
buf.options = { env: { ...process.env, ...trace } };
5757
}
@@ -107,7 +107,7 @@ export const restartBuf = new Command(
107107
);
108108

109109
const getBufArgs = () => {
110-
let bufArgs = config.get<string[]>("arguments");
110+
const bufArgs = config.get<string[]>("arguments");
111111

112112
if (config.get<string>("debug")) {
113113
bufArgs.push("--debug");

src/commands/show-commands.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,15 @@ export const showCommands = new Command(
1010
"buf.showCommands",
1111
CommandType.COMMAND_EXTENSION,
1212
() => {
13-
let quickPickList: BufQuickPickItem[] = [];
13+
const quickPickList: BufQuickPickItem[] = [];
1414

1515
const pkgJSON = vscode.extensions.getExtension(extensionId)?.packageJSON;
1616
if (pkgJSON.contributes && pkgJSON.contributes.commands) {
17-
const commands: any[] = pkgJSON.contributes.commands;
17+
const commands: {
18+
command: string;
19+
title: string;
20+
description: string;
21+
}[] = pkgJSON.contributes.commands;
1822
const bufCommands: BufQuickPickItem[] = [];
1923
const extCommands: BufQuickPickItem[] = [];
2024
const setupCommands: BufQuickPickItem[] = [];

src/commands/update-buf.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import * as github from "../github";
55
import { Command, CommandType, loadBufModules, restartBuf } from ".";
66
import { install } from "./install-buf";
77
import { log } from "../util";
8-
import { BufVersion } from "../version";
8+
import { BufVersion, Upgrade } from "../version";
99

1010
export const updateBuf = new Command(
1111
"buf.update",
@@ -17,12 +17,16 @@ export const updateBuf = new Command(
1717
return;
1818
}
1919

20+
let release: github.Release;
21+
let asset: github.Asset;
22+
let upgrade: Upgrade;
23+
2024
// Gather all the version information to see if there's an upgrade.
2125
try {
2226
log.info("Checking for buf update...");
23-
var release = await github.latestRelease();
24-
var asset = await github.findAsset(release); // Ensure a binary for this platform.
25-
var upgrade = await bufCtx.buf?.hasUpgrade(release);
27+
release = await github.latestRelease();
28+
asset = await github.findAsset(release); // Ensure a binary for this platform.
29+
upgrade = await bufCtx.buf?.hasUpgrade(release);
2630
} catch (e) {
2731
log.info(`Failed to check for buf update: ${e}`);
2832

src/config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ function substitute<T>(val: T): T {
2828
val = val.map((x) => substitute(x)) as unknown as T;
2929
} else if (typeof val === "object" && val !== null) {
3030
// Substitute values but not keys, so we don't deal with collisions.
31+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
3132
const result = {} as { [k: string]: any };
32-
for (let [k, v] of Object.entries(val)) {
33+
for (const [k, v] of Object.entries(val)) {
3334
result[k] = substitute(v);
3435
}
3536
val = result as T;

src/context.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,10 @@ export type BufFile = {
88
};
99

1010
export enum ServerStatus {
11-
// eslint-disable-next-line @typescript-eslint/naming-convention
1211
SERVER_DISABLED,
13-
// eslint-disable-next-line @typescript-eslint/naming-convention
1412
SERVER_STARTING,
15-
// eslint-disable-next-line @typescript-eslint/naming-convention
1613
SERVER_RUNNING,
17-
// eslint-disable-next-line @typescript-eslint/naming-convention
1814
SERVER_STOPPED,
19-
// eslint-disable-next-line @typescript-eslint/naming-convention
2015
SERVER_ERRORED,
2116
}
2217

src/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import * as status from "./status";
66
import { BufContext, ServerStatus } from "./context";
77
import { log } from "./util";
88

9-
let bufCtx = new BufContext();
9+
const bufCtx = new BufContext();
1010

1111
export async function activate(ctx: vscode.ExtensionContext) {
1212
status.activate(ctx, bufCtx);

0 commit comments

Comments
 (0)