Skip to content

Commit 38fd78f

Browse files
authored
Linter fixes for jumble (commontoolsinc#484)
1 parent 5383455 commit 38fd78f

21 files changed

+141
-85
lines changed

typescript/packages/jumble/src/components/AudioRecorderInput.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,8 @@ interface AudioRecorderProps {
1717
}
1818

1919
const AudioRecorder: React.FC<AudioRecorderProps> = (props) => {
20-
const {
21-
isRecording,
22-
recordingSeconds,
23-
startRecording,
24-
stopRecording,
25-
} = useAudioRecorder(props);
20+
const { isRecording, recordingSeconds, startRecording, stopRecording } =
21+
useAudioRecorder(props);
2622

2723
return (
2824
<div className="block">
@@ -31,7 +27,10 @@ const AudioRecorder: React.FC<AudioRecorderProps> = (props) => {
3127
onClick={startRecording}
3228
>
3329
{props.startButton || (
34-
<button className="px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600">
30+
<button
31+
type="button"
32+
className="px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600"
33+
>
3534
Start Recording
3635
</button>
3736
)}
@@ -41,7 +40,10 @@ const AudioRecorder: React.FC<AudioRecorderProps> = (props) => {
4140
onClick={stopRecording}
4241
>
4342
{props.stopButton || (
44-
<button className="px-4 py-2 bg-red-500 text-white rounded hover:bg-red-600">
43+
<button
44+
type="button"
45+
className="px-4 py-2 bg-red-500 text-white rounded hover:bg-red-600"
46+
>
4547
Finish Recording ({recordingSeconds}s)
4648
</button>
4749
)}

typescript/packages/jumble/src/components/CharmRunner.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ function RawCharmRenderer({ charm, className = "" }: CharmRendererProps) {
140140
</pre>
141141
<div className="flex gap-2 shrink-0">
142142
<button
143+
type="button"
143144
onClick={handleFixIt}
144145
disabled={isFixing}
145146
className="px-2 py-1 bg-white text-red-500 rounded text-sm hover:bg-red-50 disabled:opacity-50 flex items-center gap-2 whitespace-nowrap"
@@ -149,13 +150,14 @@ function RawCharmRenderer({ charm, className = "" }: CharmRendererProps) {
149150
animationSpeed={2}
150151
width={16}
151152
height={16}
152-
animate={true}
153+
animate
153154
cameraZoom={12}
154155
/>
155156
)}
156157
{isFixing ? "Fixing..." : "Fix It"}
157158
</button>
158159
<button
160+
type="button"
159161
className="hover:opacity-75"
160162
onClick={() => setRuntimeError(null)}
161163
>

typescript/packages/jumble/src/components/CommandCenter.tsx

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ function CommandProcessor({
3838

3939
switch (mode.type) {
4040
case "input":
41-
return <></>;
41+
return null;
4242

4343
case "confirm":
4444
return (
45-
<Command.Group heading={"Confirm"}>
45+
<Command.Group heading="Confirm">
4646
<Command.Item
4747
value="yes"
4848
onSelect={() => mode.command.handler?.(context)}
@@ -182,11 +182,11 @@ export function CommandCenter() {
182182
};
183183

184184
document.addEventListener("keydown", down);
185-
window.addEventListener("open-command-center", handleOpenCommandCenter);
185+
globalThis.addEventListener("open-command-center", handleOpenCommandCenter);
186186

187187
return () => {
188188
document.removeEventListener("keydown", down);
189-
window.removeEventListener(
189+
globalThis.removeEventListener(
190190
"open-command-center",
191191
handleOpenCommandCenter,
192192
);
@@ -231,11 +231,14 @@ export function CommandCenter() {
231231
};
232232

233233
document.addEventListener("keydown", handleEditRecipe);
234-
window.addEventListener("edit-recipe-command", handleEditRecipeEvent);
234+
globalThis.addEventListener("edit-recipe-command", handleEditRecipeEvent);
235235

236236
return () => {
237237
document.removeEventListener("keydown", handleEditRecipe);
238-
window.removeEventListener("edit-recipe-command", handleEditRecipeEvent);
238+
globalThis.removeEventListener(
239+
"edit-recipe-command",
240+
handleEditRecipeEvent,
241+
);
239242
};
240243
}, [focusedCharmId, allCommands]);
241244

@@ -285,8 +288,8 @@ export function CommandCenter() {
285288
const getCurrentCommands = () => {
286289
const commands = commandPathIds.length === 0
287290
? allCommands
288-
: (getCommandById(commandPathIds[commandPathIds.length - 1])?.children ??
289-
[]);
291+
: getCommandById(commandPathIds[commandPathIds.length - 1])?.children ??
292+
[];
290293

291294
return commands.filter((cmd) => cmd.predicate !== false); // Show command unless predicate is explicitly false
292295
};
@@ -299,12 +302,10 @@ export function CommandCenter() {
299302
label="Command Menu"
300303
>
301304
<VisuallyHidden>
302-
<>
303-
<DialogTitle>Common</DialogTitle>
304-
<DialogDescription>
305-
Common commands for managing charms.
306-
</DialogDescription>
307-
</>
305+
<DialogTitle>Common</DialogTitle>
306+
<DialogDescription>
307+
Common commands for managing charms.
308+
</DialogDescription>
308309
</VisuallyHidden>
309310

310311
<div

typescript/packages/jumble/src/components/VariantTray.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,14 @@ export function VariantTray({
4949
<h3 className="text-lg font-bold">Choose a variant</h3>
5050
<div className="flex gap-2">
5151
<button
52+
type="button"
5253
onClick={onCancel}
5354
className="px-4 py-2 border-2 border-black bg-white text-black hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed cursor-pointer"
5455
>
5556
Cancel
5657
</button>
5758
<button
59+
type="button"
5860
onClick={handleChooseClick}
5961
className="px-4 py-2 bg-black text-white rounded hover:bg-gray-800 disabled:opacity-50 disabled:cursor-not-allowed cursor-pointer"
6062
disabled={!selectedVariant}
@@ -66,6 +68,7 @@ export function VariantTray({
6668
<div className="flex gap-4 overflow-x-auto">
6769
<div className="flex flex-col items-center">
6870
<button
71+
type="button"
6972
onClick={() => onSelectVariant(originalCharm)}
7073
className={`
7174
flex-shrink-0 w-80 h-56 border-2 border-black overflow-hidden relative
@@ -97,6 +100,7 @@ export function VariantTray({
97100
{variants.map((variant, i) => (
98101
<div key={i} className="flex flex-col items-center">
99102
<button
103+
type="button"
100104
onClick={() =>
101105
onSelectVariant(variant)}
102106
className={`

typescript/packages/jumble/src/components/commands.ts

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ async function handleSearchCharms(deps: CommandContext) {
180180
id: "charm-select",
181181
type: "select",
182182
title: "Select Charm",
183-
handler: async (selected) => {
183+
handler: (selected) => {
184184
const id = charmId(selected);
185185
if (!id || !deps.focusedReplicaId) {
186186
throw new Error("Missing charm ID or replica name");
@@ -245,7 +245,7 @@ async function handleDeleteCharm(deps: CommandContext) {
245245
else deps.setOpen(false);
246246
}
247247

248-
async function handleStartCounterJob(deps: CommandContext) {
248+
function handleStartCounterJob(deps: CommandContext) {
249249
const jobId = deps.startJob("Counter Job");
250250
console.log("Started counter job with ID:", jobId);
251251

@@ -390,7 +390,7 @@ async function handleSelectModel(deps: CommandContext) {
390390
id: "model-select",
391391
type: "select",
392392
title: "Select Model",
393-
handler: async (selectedModel) => {
393+
handler: (selectedModel) => {
394394
deps.setPreferredModel(selectedModel.id);
395395
deps.setOpen(false);
396396
},
@@ -421,7 +421,7 @@ function navigateToCharm(charm: Charm | EntityId, deps: CommandContext) {
421421
);
422422
}
423423

424-
async function handleIndexCharms(deps: CommandContext) {
424+
function handleIndexCharms(deps: CommandContext) {
425425
startCharmIndexing(deps.charmManager, {
426426
startJob: deps.startJob,
427427
stopJob: deps.stopJob,
@@ -676,10 +676,14 @@ export function getCommands(deps: CommandContext): CommandItem[] {
676676
return;
677677
}
678678
deps.navigate(
679-
createPathWithHash("charmDetail", {
680-
charmId: deps.focusedCharmId,
681-
replicaName: deps.focusedReplicaId,
682-
}, "code"),
679+
createPathWithHash(
680+
"charmDetail",
681+
{
682+
charmId: deps.focusedCharmId,
683+
replicaName: deps.focusedReplicaId,
684+
},
685+
"code",
686+
),
683687
);
684688
deps.setOpen(false);
685689
},
@@ -696,10 +700,14 @@ export function getCommands(deps: CommandContext): CommandItem[] {
696700
return;
697701
}
698702
deps.navigate(
699-
createPathWithHash("charmDetail", {
700-
charmId: deps.focusedCharmId,
701-
replicaName: deps.focusedReplicaId,
702-
}, "data"),
703+
createPathWithHash(
704+
"charmDetail",
705+
{
706+
charmId: deps.focusedCharmId,
707+
replicaName: deps.focusedReplicaId,
708+
},
709+
"data",
710+
),
703711
);
704712
deps.setOpen(false);
705713
},
@@ -730,7 +738,7 @@ export function getCommands(deps: CommandContext): CommandItem[] {
730738
title: "Navigate Back",
731739
group: "Navigation",
732740
handler: () => {
733-
window.history.back();
741+
globalThis.history.back();
734742
deps.setOpen(false);
735743
},
736744
},
@@ -785,7 +793,7 @@ export function getCommands(deps: CommandContext): CommandItem[] {
785793
placeholder: "Enter replica name",
786794
handler: (input) => {
787795
if (input) {
788-
window.location.href = `/${input}`;
796+
globalThis.location.href = `/${input}`;
789797
}
790798
deps.setOpen(false);
791799
},
@@ -807,7 +815,7 @@ export function getCommands(deps: CommandContext): CommandItem[] {
807815
}`,
808816
group: "Edit",
809817
predicate: !!deps.focusedCharmId,
810-
handler: async (transcription) => {
818+
handler: (transcription) => {
811819
if (!transcription) return;
812820

813821
const commands = getCommands(deps);
@@ -842,7 +850,7 @@ export function getCommands(deps: CommandContext): CommandItem[] {
842850
id: `job-${job.id}-toggle`,
843851
type: "action",
844852
title: job.status === "running" ? "Pause" : "Resume",
845-
handler: async () => {
853+
handler: () => {
846854
if (job.status === "running") {
847855
deps.stopJob(job.id);
848856
} else {
@@ -855,7 +863,7 @@ export function getCommands(deps: CommandContext): CommandItem[] {
855863
id: `job-${job.id}-cancel`,
856864
type: "action",
857865
title: "Stop",
858-
handler: async () => {
866+
handler: () => {
859867
deps.stopJob(job.id);
860868
deps.setMode({ type: "main" });
861869
},
@@ -880,7 +888,7 @@ export function getCommands(deps: CommandContext): CommandItem[] {
880888
id: "clear-completed-jobs",
881889
type: "action",
882890
title: "Clear Completed Jobs",
883-
handler: async () => {
891+
handler: () => {
884892
// deps.clearCompletedJobs();
885893
deps.setMode({ type: "main" });
886894
},

typescript/packages/jumble/src/components/spellbook/ActionButton.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export function ActionButton({
2626
return (
2727
<div className="relative">
2828
<button
29+
type="button"
2930
onClick={handleClick}
3031
className={`
3132
flex items-center gap-2 px-4 py-2 bg-white

typescript/packages/jumble/src/components/spellbook/ShareDialog.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ export function ShareDialog({
4343
}
4444
};
4545

46-
window.addEventListener("keydown", handleKeyDown);
47-
return () => window.removeEventListener("keydown", handleKeyDown);
46+
globalThis.addEventListener("keydown", handleKeyDown);
47+
return () => globalThis.removeEventListener("keydown", handleKeyDown);
4848
}, [
4949
isOpen,
5050
onClose,

typescript/packages/jumble/src/contexts/ActionManagerContext.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,14 @@ export function ActionManagerProvider(
7171

7272
// Register keyboard listener if keyCombo exists
7373
if (action.keyCombo) {
74-
window.addEventListener("keydown", handleKeyDown);
74+
globalThis.addEventListener("keydown", handleKeyDown);
7575
}
7676

7777
// Return a function to unregister this action and clean up event listeners
7878
return () => {
7979
setActions((prev) => prev.filter((a) => a.id !== action.id));
8080
if (action.keyCombo) {
81-
window.removeEventListener("keydown", handleKeyDown);
81+
globalThis.removeEventListener("keydown", handleKeyDown);
8282
}
8383
};
8484
}, []);

typescript/packages/jumble/src/contexts/CharmsContext.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const CharmsProvider: React.FC<{ children: React.ReactNode }> = (
3535
async (charm: Charm) => {
3636
// Stub: runs charm asynchronously and then adds it
3737

38-
// TODO: Is this still needed?
38+
// TODO(@jumble): Is this still needed?
3939
await new Promise((resolve) => setTimeout(resolve, 300));
4040
addCharm(charm);
4141
},

typescript/packages/jumble/src/hooks/use-global-actions.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export function useGlobalActions() {
2424
label: "Commands",
2525
icon: <MdOutlineStar fill="black" size={28} />,
2626
onClick: () => {
27-
window.dispatchEvent(new CustomEvent("open-command-center"));
27+
globalThis.dispatchEvent(new CustomEvent("open-command-center"));
2828
},
2929
priority: 100,
3030
}),
@@ -63,7 +63,7 @@ export function useGlobalActions() {
6363
label: "Publish",
6464
icon: <MdShare fill="black" size={28} />,
6565
onClick: () => {
66-
window.dispatchEvent(
66+
globalThis.dispatchEvent(
6767
new CustomEvent("publish-charm", {
6868
detail: { charmId, charmName },
6969
}),

0 commit comments

Comments
 (0)