Skip to content

Commit e101aa2

Browse files
committed
Upgrade and fix up linting (Biome and tsc).
1 parent 56e8a63 commit e101aa2

File tree

22 files changed

+125
-118
lines changed

22 files changed

+125
-118
lines changed

.github/workflows/CI.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@ jobs:
2424
with:
2525
bun-version: latest
2626
- run: make setup
27-
- run: make test
27+
- run: make lint-biome
28+
- run: make lint-tsc
2829
- run: make clean

Makefile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,16 @@ format: setup
1111
bun x @biomejs/biome check --write
1212

1313
.PHONY: lint
14-
lint: setup
14+
lint: lint-biome lint-tsc
15+
16+
.PHONY: lint-biome
17+
lint-biome: setup
1518
bun x @biomejs/biome check
1619

20+
.PHONY: lint-tsc
21+
lint-tsc: setup
22+
bun x tsc --noEmit --project .
23+
1724
.PHONY: setup
1825
setup:
1926
bun install --no-save

biome.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
33
"files": {
4-
"ignore": ["./dist", "./package.json"]
4+
"includes": ["**", "!dist", "!package.json"]
55
},
66
"formatter": {
77
"indentStyle": "space",

bun.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"devDependencies": {
1919
"@biomejs/biome": "^2.1.2",
2020
"@cubing/deploy": "^0.2.2",
21+
"@cubing/dev-config": "^0.3.6",
2122
"@types/chai": "^5.2.2",
2223
"@types/mocha": "^10.0.10",
2324
"barely-a-dev-server": "^0.8.1",

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"devDependencies": {
2727
"@biomejs/biome": "^2.1.2",
2828
"@cubing/deploy": "^0.2.2",
29+
"@cubing/dev-config": "^0.3.6",
2930
"@types/chai": "^5.2.2",
3031
"@types/mocha": "^10.0.10",
3132
"barely-a-dev-server": "^0.8.1",

src/timer.cubing.net/app/TimerApp.ts

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type {
66
AttemptDataWithIDAndRev,
77
} from "../results/AttemptData";
88
import { Stats } from "../results/Stats";
9-
import { TimerSession, allDocsResponseToTimes } from "../results/TimerSession";
9+
import { TimerSession } from "../results/TimerSession";
1010
import { Controller } from "../timing/Controller";
1111
import type { Milliseconds } from "../timing/Timer";
1212
import { ScrambleView, type ScrambleWithEvent } from "../ui/ScrambleView";
@@ -36,27 +36,24 @@ const favicons: { [s: string]: string } = {
3636
// TODO: Import this from "./scramble-worker"
3737
export type ScrambleID = number;
3838

39-
const STORED_EVENT_TIMEOUT_MS = 15 * 60 * 1000;
4039
const LATEST_AMOUNT = 100;
4140

4241
export class TimerApp {
4342
private scrambleView: ScrambleView;
4443
private statsView: StatsView;
4544
private domElement: HTMLElement;
46-
private currentEvent: EventID;
45+
private currentEvent: EventID = "333"; // TODO: are there any issues with a default value here?
4746
private controller: Controller;
48-
private awaitedScrambleID: ScrambleID;
49-
private currentScramble: ScrambleWithEvent;
47+
private awaitedScrambleID: ScrambleID | undefined;
48+
private currentScramble: ScrambleWithEvent | undefined;
5049
private session = new TimerSession();
51-
private remoteDB: PouchDB.Database<AttemptData>;
50+
// private remoteDB: PouchDB.Database<AttemptData>;
5251

53-
private cachedBest: number | null = null;
54-
private cachedWorst: number | null = null;
5552
constructor() {
5653
this.session.startSync(this.onSyncChange.bind(this));
5754

5855
this.scrambleView = new ScrambleView(this);
59-
this.statsView = new StatsView(() => this.currentEvent);
56+
this.statsView = new StatsView();
6057
this.domElement = <HTMLElement>document.getElementById("timer-app");
6158

6259
this.enableOffline();
@@ -103,18 +100,21 @@ export class TimerApp {
103100
// }, 750);
104101
}
105102

106-
private async getTimes(): Promise<Milliseconds[]> {
107-
const docs0 = await this.session.mostRecentAttemptsForEvent(
108-
this.currentEvent,
109-
LATEST_AMOUNT,
110-
);
111-
console.log(docs0);
112-
const docs = await this.session.db.allDocs({
113-
// descending: true,
114-
include_docs: true,
115-
});
116-
return allDocsResponseToTimes(docs);
117-
}
103+
// private async getTimes(): Promise<Milliseconds[]> {
104+
// if (!this.currentEvent) {
105+
// return [];
106+
// }
107+
// const docs0 = await this.session.mostRecentAttemptsForEvent(
108+
// this.currentEvent,
109+
// LATEST_AMOUNT,
110+
// );
111+
// console.log(docs0);
112+
// const docs = await this.session.db.allDocs({
113+
// // descending: true,
114+
// include_docs: true,
115+
// });
116+
// return allDocsResponseToTimes(docs);
117+
// }
118118

119119
// Prevent a timer tap from scrolling the whole page on touch screens.
120120
private onTouchMove(e: Event) {
@@ -127,7 +127,7 @@ export class TimerApp {
127127
}
128128

129129
private enableOffline() {
130-
const infoBar = document.getElementById("update-bar");
130+
// const infoBar = document.getElementById("update-bar");
131131
}
132132

133133
private setInitialEvent() {
@@ -238,8 +238,8 @@ export class TimerApp {
238238
event: this.currentEvent,
239239
scramble: this.currentScramble?.scramble?.toString() ?? "",
240240
};
241-
if (localStorage.pouchDBDeviceName) {
242-
attemptData.device = localStorage.pouchDBDeviceName;
241+
if (localStorage["pouchDBDeviceName"]) {
242+
attemptData.device = localStorage["pouchDBDeviceName"];
243243
}
244244
await this.session.addNewAttempt(attemptData);
245245
}
@@ -253,7 +253,7 @@ export class TimerApp {
253253
).docs.reverse();
254254
}
255255

256-
async updateDisplayStats(assumeAttemptAppended: boolean = false) {
256+
async updateDisplayStats(_assumeAttemptAppended: boolean = false) {
257257
const attempts = await this.latest();
258258
const times = attempts.map((attempt) => attempt.totalResultMs);
259259
const numAttempts = (await this.session.db.info()).doc_count - 1;
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
export function hideScrambleDisplay(): boolean {
2-
return localStorage.hideScrambleDisplay === "true";
2+
return localStorage["hideScrambleDisplay"] === "true";
33
}
44

55
export function setHideScrambleDisplay(hide: boolean): void {
6-
localStorage.hideScrambleDisplay = hide ? "true" : "false";
6+
localStorage["hideScrambleDisplay"] = hide ? "true" : "false";
77
}
88

99
export function preferHarmonicMean(): boolean {
10-
return localStorage.preferHarmonicMean === "true";
10+
return localStorage["preferHarmonicMean"] === "true";
1111
}
1212

1313
export function setPreferHarmonicMean(hide: boolean): void {
14-
localStorage.preferHarmonicMean = hide ? "true" : "false";
14+
localStorage["preferHarmonicMean"] = hide ? "true" : "false";
1515
}

src/timer.cubing.net/index.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import "cubing/twisty";
2-
import { TimerApp } from "./app/TimerApp";
32

43
import { Workbox } from "workbox-window";
5-
6-
const SW_CACHE_FILE = "./sw.js";
4+
import { TimerApp } from "./app/TimerApp";
75

86
// biome-ignore lint/suspicious/noExplicitAny: Just a quick global assignment.
97
(window as any).app = new TimerApp();
@@ -12,7 +10,7 @@ const SW_CACHE_FILE = "./sw.js";
1210
if (location.hostname.split(".").slice(-1)[0] !== "localhost") {
1311
window.addEventListener("load", () => {
1412
const wb = new Workbox(new URL("./sw.js", import.meta.url).href);
15-
wb.addEventListener("waiting", (event) => {
13+
wb.addEventListener("waiting", (_event) => {
1614
wb.messageSkipWaiting();
1715
});
1816
wb.register();

src/timer.cubing.net/resources/vendor/twizzle-link.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ export function twizzleLink(
99
alg: Alg | string | undefined,
1010
title?: string,
1111
) {
12-
// biome-ignore lint/style/noParameterAssign: Old code pattern
1312
setup = new Alg(setup);
14-
// biome-ignore lint/style/noParameterAssign: Old code pattern
1513
alg = new Alg(alg);
1614
const url = new URL("https://alpha.twizzle.net/edit/");
1715

src/timer.cubing.net/results/AttemptData.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { EventID } from "../app/events";
2-
import type { UUID, newDateUUID } from "./uuid";
2+
import type { UUID } from "./uuid";
33

44
type AttemptUUID = UUID;
55
type AlgString = string;

0 commit comments

Comments
 (0)