From 157a49c83ceb40ca1a4f497e3f2a65c729402256 Mon Sep 17 00:00:00 2001 From: Jacob Bandes-Storch Date: Tue, 14 Nov 2023 17:27:40 -0800 Subject: [PATCH] more lint + prettier --- .../scripts/run-tests/runners/TestRunner.ts | 4 +- .../TypescriptIndexedReaderTestRunner.ts | 4 +- .../runners/TypescriptWriterTestRunner.ts | 12 ++--- .../McapRecordingDemo/McapRecordingDemo.tsx | 44 +++++++++++++------ .../components/McapRecordingDemo/Recorder.ts | 4 +- .../McapRecordingDemo/addProtobufChannel.ts | 10 ++--- .../McapRecordingDemo/videoCapture.ts | 6 +-- 7 files changed, 50 insertions(+), 34 deletions(-) diff --git a/tests/conformance/scripts/run-tests/runners/TestRunner.ts b/tests/conformance/scripts/run-tests/runners/TestRunner.ts index 16c3236ab7..da89675873 100644 --- a/tests/conformance/scripts/run-tests/runners/TestRunner.ts +++ b/tests/conformance/scripts/run-tests/runners/TestRunner.ts @@ -70,8 +70,8 @@ export abstract class IndexedReadTestRunner { messages: [], statistics: [], }; - const knownSchemaIds: Set = new Set(); - const knownChannelIds: Set = new Set(); + const knownSchemaIds = new Set(); + const knownChannelIds = new Set(); for (const record of testCase.records) { switch (record.type) { case "Schema": diff --git a/tests/conformance/scripts/run-tests/runners/TypescriptIndexedReaderTestRunner.ts b/tests/conformance/scripts/run-tests/runners/TypescriptIndexedReaderTestRunner.ts index d3b5ba16c5..905c1a1441 100644 --- a/tests/conformance/scripts/run-tests/runners/TypescriptIndexedReaderTestRunner.ts +++ b/tests/conformance/scripts/run-tests/runners/TypescriptIndexedReaderTestRunner.ts @@ -12,7 +12,7 @@ export default class TypescriptIndexedReaderTestRunner extends IndexedReadTestRu async runReadTest(filePath: string): Promise { const handle = await fs.open(filePath, "r"); try { - return await this._run(handle); + return await this.#run(handle); } finally { await handle.close(); } @@ -40,7 +40,7 @@ export default class TypescriptIndexedReaderTestRunner extends IndexedReadTestRu return true; } - private async _run(fileHandle: fs.FileHandle): Promise { + async #run(fileHandle: fs.FileHandle): Promise { let buffer = new ArrayBuffer(4096); const readable = { size: async () => BigInt((await fileHandle.stat()).size), diff --git a/tests/conformance/scripts/run-tests/runners/TypescriptWriterTestRunner.ts b/tests/conformance/scripts/run-tests/runners/TypescriptWriterTestRunner.ts index 7c7369cf29..28684d6074 100644 --- a/tests/conformance/scripts/run-tests/runners/TypescriptWriterTestRunner.ts +++ b/tests/conformance/scripts/run-tests/runners/TypescriptWriterTestRunner.ts @@ -8,12 +8,12 @@ import { WriteTestRunner } from "./TestRunner"; type JsonValue = T extends number | bigint | string ? string : T extends Uint8Array - ? number[] - : T extends Map - ? K extends number | bigint | string - ? Record, JsonValue> - : never - : never; + ? number[] + : T extends Map + ? K extends number | bigint | string + ? Record, JsonValue> + : never + : never; type JsonRecord = { type: R; diff --git a/website/src/components/McapRecordingDemo/McapRecordingDemo.tsx b/website/src/components/McapRecordingDemo/McapRecordingDemo.tsx index 41c864d33c..26bf5858af 100644 --- a/website/src/components/McapRecordingDemo/McapRecordingDemo.tsx +++ b/website/src/components/McapRecordingDemo/McapRecordingDemo.tsx @@ -78,7 +78,7 @@ const RADIANS_PER_DEGREE = Math.PI / 180; // Adapted from https://github.com/mrdoob/three.js/blob/master/src/math/Quaternion.js function deviceOrientationToPose( - event: DeviceOrientationEvent + event: DeviceOrientationEvent, ): ProtobufObject { const alpha = (event.alpha ?? 0) * RADIANS_PER_DEGREE; // z angle const beta = (event.beta ?? 0) * RADIANS_PER_DEGREE; // x angle @@ -133,7 +133,9 @@ export function McapRecordingDemo(): JSX.Element { if (!recording) { return; } - const timeout = setTimeout(() => setRecording(false), 30000); + const timeout = setTimeout(() => { + setRecording(false); + }, 30000); return () => { clearTimeout(timeout); }; @@ -165,7 +167,7 @@ export function McapRecordingDemo(): JSX.Element { return () => { window.removeEventListener( "deviceorientation", - handleDeviceOrientationEvent + handleDeviceOrientationEvent, ); }; }, [addPoseMessage, recording, recordOrientation]); @@ -178,7 +180,9 @@ export function McapRecordingDemo(): JSX.Element { const cleanup = startVideoStream({ video, - onStart: () => setVideoStarted(true), + onStart: () => { + setVideoStarted(true); + }, onError: (err) => { console.error(err); setVideoPermissionError(true); @@ -201,7 +205,9 @@ export function McapRecordingDemo(): JSX.Element { const stopCapture = startVideoCapture({ video, frameDurationSec: 1 / 30, - onFrame: (blob) => addCameraImage(blob), + onFrame: (blob) => { + addCameraImage(blob); + }, }); return () => { stopCapture(); @@ -234,7 +240,7 @@ export function McapRecordingDemo(): JSX.Element { .catch(console.error); } }, - [recordOrientation, recording] + [recordOrientation, recording], ); const onDownloadClick = useCallback( @@ -249,7 +255,7 @@ export function McapRecordingDemo(): JSX.Element { // Create a date+time string in the local timezone to use as the filename const date = new Date(); const localTime = new Date( - date.getTime() - date.getTimezoneOffset() * 60_000 + date.getTime() - date.getTimezoneOffset() * 60_000, ) .toISOString() .replace(/\..+$/, "") @@ -264,7 +270,7 @@ export function McapRecordingDemo(): JSX.Element { setShowDownloadInfo(true); })(); }, - [state] + [state], ); return ( @@ -282,7 +288,9 @@ export function McapRecordingDemo(): JSX.Element { setRecordVideo(event.target.checked)} + onChange={(event) => { + setRecordVideo(event.target.checked); + }} /> Camera @@ -290,7 +298,9 @@ export function McapRecordingDemo(): JSX.Element { setRecordMouse(event.target.checked)} + onChange={(event) => { + setRecordMouse(event.target.checked); + }} /> Mouse position @@ -299,7 +309,9 @@ export function McapRecordingDemo(): JSX.Element { setRecordOrientation(event.target.checked)} + onChange={(event) => { + setRecordOrientation(event.target.checked); + }} /> Orientation @@ -319,7 +331,9 @@ export function McapRecordingDemo(): JSX.Element { aria-label="Close" className={cx("clean-btn", styles.downloadInfoCloseButton)} type="button" - onClick={() => setShowDownloadInfo(false)} + onClick={() => { + setShowDownloadInfo(false); + }} > @@ -352,7 +366,7 @@ export function McapRecordingDemo(): JSX.Element { className={cx( "button", "button--success", - styles.downloadButton + styles.downloadButton, )} onClick={onDownloadClick} > @@ -428,7 +442,9 @@ export function McapRecordingDemo(): JSX.Element { ) : ( setRecordVideo(true)} + onClick={() => { + setRecordVideo(true); + }} > Enable “Camera” to record video diff --git a/website/src/components/McapRecordingDemo/Recorder.ts b/website/src/components/McapRecordingDemo/Recorder.ts index 6bbe8f1542..daea470b3e 100644 --- a/website/src/components/McapRecordingDemo/Recorder.ts +++ b/website/src/components/McapRecordingDemo/Recorder.ts @@ -99,12 +99,12 @@ export class Recorder extends EventEmitter { const poseChannel = await addProtobufChannel( this.#writer, "pose", - foxgloveMessageSchemas.PoseInFrame + foxgloveMessageSchemas.PoseInFrame, ); const cameraChannel = await addProtobufChannel( this.#writer, "camera", - foxgloveMessageSchemas.CompressedImage + foxgloveMessageSchemas.CompressedImage, ); this.#emit(); diff --git a/website/src/components/McapRecordingDemo/addProtobufChannel.ts b/website/src/components/McapRecordingDemo/addProtobufChannel.ts index 2f65cdd6d2..8ad80d0e16 100644 --- a/website/src/components/McapRecordingDemo/addProtobufChannel.ts +++ b/website/src/components/McapRecordingDemo/addProtobufChannel.ts @@ -14,21 +14,21 @@ export type ProtobufChannelInfo = { export async function addProtobufChannel( writer: McapWriter, topic: string, - rootSchema: FoxgloveMessageSchema + rootSchema: FoxgloveMessageSchema, ): Promise { const schemaName = `foxglove.${rootSchema.name}`; const root = new protobufjs.Root(); root.addJSON( - protobufjs.common.get("google/protobuf/timestamp.proto")!.nested! + protobufjs.common.get("google/protobuf/timestamp.proto")!.nested!, ); root.addJSON( - protobufjs.common.get("google/protobuf/duration.proto")!.nested! + protobufjs.common.get("google/protobuf/duration.proto")!.nested!, ); function addMessageSchema(msgSchema: FoxgloveMessageSchema) { const nestedEnums = Object.values(foxgloveEnumSchemas).filter( - (enumSchema) => enumSchema.parentSchemaName === msgSchema.name + (enumSchema) => enumSchema.parentSchemaName === msgSchema.name, ); const protoSrc = generateProto(msgSchema, nestedEnums); const parseResult = protobufjs.parse(protoSrc, { keepCase: true }); @@ -51,7 +51,7 @@ export async function addProtobufChannel( // protobufjs does not generate dependency fields, so fix them up manually if (file.name == undefined || file.name.length === 0) { throw new Error( - `Missing filename for ${file.package ?? "(unknown package)"}` + `Missing filename for ${file.package ?? "(unknown package)"}`, ); } if (file.name !== "google_protobuf.proto") { diff --git a/website/src/components/McapRecordingDemo/videoCapture.ts b/website/src/components/McapRecordingDemo/videoCapture.ts index cd39da711f..b95578253c 100644 --- a/website/src/components/McapRecordingDemo/videoCapture.ts +++ b/website/src/components/McapRecordingDemo/videoCapture.ts @@ -23,7 +23,7 @@ export function startVideoStream(params: VideoStreamParams): () => void { stream = videoStream; params.video.srcObject = videoStream; await params.video.play(); - if (canceled) { + if (canceled as boolean) { return; } params.onStart(); @@ -68,7 +68,7 @@ export function startVideoCapture(params: VideoCaptureParams): () => void { async function startVideoCaptureAsync( params: VideoCaptureParams, - signal: AbortSignal + signal: AbortSignal, ) { const { video, onFrame, frameDurationSec } = params; const canvas = document.createElement("canvas"); @@ -93,7 +93,7 @@ async function startVideoCaptureAsync( framePromise = undefined; }, "image/jpeg", - 0.8 + 0.8, ); }); }, frameDurationSec * 1000);