Skip to content

Commit f6e82ee

Browse files
committed
chore: update to eslint 9
1 parent 9b6f8d1 commit f6e82ee

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+3291
-2428
lines changed

.eslintignore

Lines changed: 0 additions & 5 deletions
This file was deleted.

.eslintrc.yml

Lines changed: 0 additions & 83 deletions
This file was deleted.

bin/index.mts

Lines changed: 41 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
// WARNING: any imported files need to be added to files in package.json
44

55
import asar from "@electron/asar";
6+
import chalk from "chalk";
7+
import esbuild from "esbuild";
8+
import { sassPlugin } from "esbuild-sass-plugin";
69
import {
710
copyFileSync,
811
cpSync,
@@ -12,18 +15,16 @@ import {
1215
rmSync,
1316
writeFileSync,
1417
} from "fs";
15-
import esbuild from "esbuild";
1618
import path from "path";
19+
import type { PluginManifest, ThemeManifest } from "src/types";
1720
import updateNotifier from "update-notifier";
18-
import yargs, { ArgumentsCamelCase } from "yargs";
19-
import { hideBin } from "yargs/helpers";
20-
import chalk from "chalk";
21+
import { fileURLToPath, pathToFileURL } from "url";
2122
import WebSocket from "ws";
22-
import { release } from "./release.mjs";
23+
import yargs, { type ArgumentsCamelCase } from "yargs";
24+
import { hideBin } from "yargs/helpers";
2325
import { logBuildPlugin } from "../src/util.mjs";
24-
import { sassPlugin } from "esbuild-sass-plugin";
25-
import { fileURLToPath, pathToFileURL } from "url";
26-
import { AddonType, getAddonFolder, isMonoRepo, selectAddon } from "./mono.mjs";
26+
import { type AddonType, getAddonFolder, isMonoRepo, selectAddon } from "./mono.mjs";
27+
import { release } from "./release.mjs";
2728

2829
interface BaseArgs {
2930
watch?: boolean;
@@ -92,6 +93,7 @@ function tryPort(port: number): Promise<WebSocket | undefined> {
9293
return;
9394
}
9495

96+
// eslint-disable-next-line @typescript-eslint/no-base-to-string
9597
const message = JSON.parse(data.toString());
9698
if (message.evt !== "READY") {
9799
return;
@@ -185,7 +187,7 @@ async function reload(id: string): Promise<void> {
185187

186188
reloading = true;
187189

188-
await new Promise((resolve) => {
190+
await new Promise<void>((resolve) => {
189191
/**
190192
*
191193
* @param {import('ws').RawData} data
@@ -201,7 +203,8 @@ async function reload(id: string): Promise<void> {
201203
reloading = false;
202204
if (reloadAgain) {
203205
reloadAgain = false;
204-
resolve(await reload(id));
206+
await reload(id);
207+
resolve();
205208
return;
206209
}
207210

@@ -257,7 +260,7 @@ async function bundleAddon(
257260
if (!existsSync("bundle")) {
258261
mkdirSync("bundle");
259262
}
260-
asar.createPackage(distPath, `${outputName}.asar`);
263+
await asar.createPackage(distPath, `${outputName}.asar`);
261264
copyFileSync(`${distPath}/manifest.json`, `${outputName}.json`);
262265

263266
console.log(`Bundled ${manifest.name}`);
@@ -273,7 +276,7 @@ async function handleContexts(
273276
await context.watch();
274277
} else {
275278
await context.rebuild().catch(() => process.exit(1));
276-
context.dispose();
279+
await context.dispose();
277280
}
278281
}),
279282
);
@@ -304,15 +307,15 @@ function buildAddons(buildFn: (args: Args) => Promise<void>, args: Args, type: A
304307
const addons = getAddonFolder(type);
305308

306309
addons.forEach((addon) => {
307-
buildFn({ ...args, addon });
310+
void buildFn({ ...args, addon });
308311
});
309312
}
310313

311314
async function buildPlugin({ watch, noInstall, production, noReload, addon }: Args): Promise<void> {
312315
const manifestPath = addon
313316
? path.join(directory, "plugins", addon, "manifest.json")
314317
: path.join(directory, "manifest.json");
315-
const manifest = JSON.parse(readFileSync(manifestPath.toString(), "utf-8"));
318+
const manifest: PluginManifest = JSON.parse(readFileSync(manifestPath.toString(), "utf-8"));
316319
const distPath = addon ? `dist/${manifest.id}` : "dist";
317320
const folderPath = addon ? path.join(directory, "plugins", addon) : directory;
318321

@@ -405,7 +408,7 @@ async function buildPlugin({ watch, noInstall, production, noReload, addon }: Ar
405408
esbuild.context(
406409
overwrites({
407410
...common,
408-
entryPoints: [path.join(folderPath, manifest.renderer)],
411+
entryPoints: [path.join(folderPath, manifest.renderer!)],
409412
outfile: `${distPath}/renderer.js`,
410413
}),
411414
),
@@ -419,7 +422,7 @@ async function buildPlugin({ watch, noInstall, production, noReload, addon }: Ar
419422
esbuild.context(
420423
overwrites({
421424
...common,
422-
entryPoints: [path.join(folderPath, manifest.plaintextPatches)],
425+
entryPoints: [path.join(folderPath, manifest.plaintextPatches!)],
423426
outfile: `${distPath}/plaintextPatches.js`,
424427
}),
425428
),
@@ -442,7 +445,7 @@ async function buildTheme({ watch, noInstall, production, noReload, addon }: Arg
442445
const manifestPath = addon
443446
? path.join(directory, "themes", addon, "manifest.json")
444447
: "manifest.json";
445-
const manifest = JSON.parse(readFileSync(manifestPath.toString(), "utf-8"));
448+
const manifest: ThemeManifest = JSON.parse(readFileSync(manifestPath.toString(), "utf-8"));
446449
const distPath = addon ? `dist/${manifest.id}` : "dist";
447450
const folderPath = addon ? path.join(directory, "themes", addon) : directory;
448451

@@ -568,16 +571,20 @@ const { argv } = yargs(hideBin(process.argv))
568571
},
569572
async (argv) => {
570573
if (argv.addon === "plugin") {
571-
if (argv.all && isMonoRepo) return buildAddons(buildPlugin, argv, "plugins");
572-
else {
574+
if (argv.all && isMonoRepo) {
575+
buildAddons(buildPlugin, argv, "plugins");
576+
return;
577+
} else {
573578
const plugin = isMonoRepo ? await selectAddon("plugins") : undefined;
574-
buildPlugin({ ...argv, addon: plugin?.name });
579+
await buildPlugin({ ...argv, addon: plugin?.name });
575580
}
576581
} else if (argv.addon === "theme") {
577-
if (argv.all && isMonoRepo) return buildAddons(buildTheme, argv, "themes");
578-
else {
582+
if (argv.all && isMonoRepo) {
583+
buildAddons(buildTheme, argv, "themes");
584+
return;
585+
} else {
579586
const theme = isMonoRepo ? await selectAddon("themes") : undefined;
580-
buildTheme({ ...argv, addon: theme?.name });
587+
await buildTheme({ ...argv, addon: theme?.name });
581588
}
582589
} else {
583590
console.log("Invalid addon type.");
@@ -596,23 +603,28 @@ const { argv } = yargs(hideBin(process.argv))
596603
},
597604
async (argv) => {
598605
if (argv.addon === "plugin") {
599-
if (argv.all && isMonoRepo) return bundleAddons(buildPlugin, "plugins");
600-
else {
606+
if (argv.all && isMonoRepo) {
607+
bundleAddons(buildPlugin, "plugins");
608+
return;
609+
} else {
601610
const addon = isMonoRepo ? await selectAddon("plugins") : undefined;
602-
bundleAddon(buildPlugin, addon?.name, "plugins");
611+
await bundleAddon(buildPlugin, addon?.name, "plugins");
603612
}
604613
} else if (argv.addon === "theme") {
605-
if (argv.all && isMonoRepo) return bundleAddons(buildTheme, "themes");
606-
else {
614+
if (argv.all && isMonoRepo) {
615+
bundleAddons(buildTheme, "themes");
616+
return;
617+
} else {
607618
const addon = isMonoRepo ? await selectAddon("themes") : undefined;
608-
bundleAddon(buildTheme, addon?.name, "themes");
619+
await bundleAddon(buildTheme, addon?.name, "themes");
609620
}
610621
} else {
611622
console.log("Invalid addon type.");
612623
}
613624
sendUpdateNotification();
614625
},
615626
)
627+
// eslint-disable-next-line @typescript-eslint/no-empty-function
616628
.command("release", "Interactively release a new version of an addon", () => {}, release)
617629
.parserConfiguration({
618630
"boolean-negation": false,

bin/mono.mts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import { existsSync, readdirSync } from "fs";
44
import path from "path";
5-
import { directory } from "./index.mjs";
65
import prompts from "prompts";
6+
import { directory } from "./index.mjs";
77
import { onCancel } from "./release.mjs";
88

99
export const isMonoRepo =
@@ -27,7 +27,7 @@ interface SelectedAddon {
2727

2828
export async function selectAddon(type: AddonType | "all"): Promise<SelectedAddon> {
2929
if (type !== "all") {
30-
const folder = getAddonFolder(type as AddonType);
30+
const folder = getAddonFolder(type);
3131

3232
const { addon } = await prompts(
3333
{

bin/release.mts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
// WARNING: any imported files need to be added to files in package.json
22

3+
import chalk from "chalk";
4+
import { execSync } from "child_process";
35
import { existsSync, readFileSync, writeFileSync } from "fs";
46
import path from "path";
57
import prompts from "prompts";
68
import semver from "semver";
7-
import chalk from "chalk";
8-
import { execSync } from "child_process";
9+
import type { AnyAddonManifest } from "src/types";
910
import { isMonoRepo, selectAddon } from "./mono.mjs";
1011

1112
/**
@@ -94,7 +95,7 @@ export async function release(): Promise<void> {
9495
process.exit(1);
9596
}
9697
const manifestText = readFileSync(manifestPath, "utf8");
97-
let manifest;
98+
let manifest: AnyAddonManifest;
9899
try {
99100
manifest = JSON.parse(manifestText);
100101
} catch {
@@ -119,7 +120,7 @@ export async function release(): Promise<void> {
119120
// Prompt for version
120121

121122
const { version } = manifest;
122-
let nextVersion;
123+
let nextVersion: string | null = null;
123124

124125
const isValidSemver = Boolean(semver.valid(version));
125126
if (isValidSemver) {
@@ -170,7 +171,7 @@ export async function release(): Promise<void> {
170171
));
171172
}
172173

173-
nextVersion = nextVersion.trim();
174+
nextVersion = nextVersion?.trim() ?? "";
174175
const isNewValidSemver = Boolean(semver.valid(nextVersion));
175176
if (isValidSemver) {
176177
// If the existing version is not semver, don't bother with semver checks
@@ -180,7 +181,7 @@ export async function release(): Promise<void> {
180181
}
181182
const cleaned = semver.clean(nextVersion);
182183
if (cleaned !== nextVersion) {
183-
let { clean } = await prompts({
184+
const { clean } = await prompts({
184185
type: "confirm",
185186
name: "clean",
186187
message: `Convert ${nextVersion} to cleaned version ${cleaned}?`,
@@ -194,7 +195,7 @@ export async function release(): Promise<void> {
194195
}
195196

196197
// Update manifest.json and package.json
197-
manifest.version = nextVersion;
198+
manifest.version = nextVersion!;
198199
if (packageJson) packageJson.version = nextVersion;
199200

200201
// Write manifest.json and package.json (indent with 2 spaces and keep trailing newline)
@@ -234,7 +235,7 @@ export async function release(): Promise<void> {
234235
initial: isMonoRepo
235236
? `v${nextVersion}-${manifest.name.replace(" ", "_")}`
236237
: `v${nextVersion}`,
237-
validate: (value) => {
238+
validate: (value: string) => {
238239
if (!value.trim()) return "Tag name is required";
239240

240241
if (existingTags.includes(value)) return `Tag ${value} already exists`;

0 commit comments

Comments
 (0)