Skip to content

Commit 32ea676

Browse files
committed
chore: lint common-ui, common-os-ui
1 parent f1fb54e commit 32ea676

File tree

11 files changed

+35
-26
lines changed

11 files changed

+35
-26
lines changed

typescript/packages/common-os-ui/src/components/code-editor/os-code-editor.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,9 @@ export class OsCodeEditor extends ReactiveElement {
135135
const ext = EditorView.updateListener.of((update) => {
136136
if (update.docChanged) {
137137
if (this.#docChangeTimeout) {
138-
window.clearTimeout(this.#docChangeTimeout);
138+
globalThis.clearTimeout(this.#docChangeTimeout);
139139
}
140-
this.#docChangeTimeout = window.setTimeout(() => {
140+
this.#docChangeTimeout = globalThis.setTimeout(() => {
141141
this.dispatchEvent(new CustomEvent("doc-change", { detail: update }));
142142
}, 500);
143143
}
@@ -154,7 +154,7 @@ export class OsCodeEditor extends ReactiveElement {
154154
this.destroy.add(() => {
155155
this.#editorView?.destroy();
156156
if (this.#docChangeTimeout) {
157-
window.clearTimeout(this.#docChangeTimeout);
157+
globalThis.clearTimeout(this.#docChangeTimeout);
158158
}
159159
});
160160
}

typescript/packages/common-os-ui/src/components/editor/os-rich-text-editor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,8 +384,8 @@ export class OsRichTextEditor extends HTMLElement {
384384
}
385385

386386
/** TODO implement */
387-
async fetchCompletions(_suggestion: Suggestion) {
388-
return [];
387+
fetchCompletions(_suggestion: Suggestion) {
388+
return Promise.resolve([]);
389389
}
390390

391391
/**

typescript/packages/common-os-ui/src/components/editor/suggestions.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,18 +214,18 @@ const replaceFx = (
214214
suggestion: Suggestion | null,
215215
completion: string | null,
216216
) =>
217-
async () => {
217+
() => {
218218
if (suggestion == null) {
219-
return createInfoMsg("No active suggestion to replace");
219+
return Promise.resolve(createInfoMsg("No active suggestion to replace"));
220220
}
221221
if (completion == null) {
222-
return createInfoMsg("No completion to replace");
222+
return Promise.resolve(createInfoMsg("No completion to replace"));
223223
}
224224
executeCommand(
225225
view,
226226
replaceWithText(suggestion.from, suggestion.to, completion),
227227
);
228-
return createInfoMsg("Replaced suggestion with completion");
228+
return Promise.resolve(createInfoMsg("Replaced suggestion with completion"));
229229
};
230230

231231
/**

typescript/packages/common-os-ui/src/components/os-dialog.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ export class OsDialog extends LitElement {
6868
open = false;
6969

7070
override connectedCallback(): void {
71-
window.addEventListener("keydown", this.#onEsc);
71+
globalThis.addEventListener("keydown", this.#onEsc);
7272
super.connectedCallback();
7373
}
7474

7575
override disconnectedCallback(): void {
76-
window.removeEventListener("keydown", this.#onEsc);
76+
globalThis.removeEventListener("keydown", this.#onEsc);
7777
}
7878

7979
#onEsc = (event: KeyboardEvent) => {

typescript/packages/common-os-ui/src/components/os-navstack.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export class OsNavstack extends LitElement {
7373

7474
async back() {
7575
const panels = [...this.panels];
76-
let lastPanel = panels.at(-1);
76+
const lastPanel = panels.at(-1);
7777
if (!lastPanel) {
7878
return;
7979
}

typescript/packages/common-os-ui/src/shared/dom.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** Create a class string using a record of classnames to toggle-states */
22
export const classes = (classRecord: Record<string, boolean>) => {
3-
let toggledClasses: Array<string> = [];
3+
const toggledClasses: Array<string> = [];
44
for (const [className, isActive] of Object.entries(classRecord)) {
55
if (isActive) toggledClasses.push(className);
66
}
@@ -11,7 +11,7 @@ export const classes = (classRecord: Record<string, boolean>) => {
1111
export const animationFrame = () =>
1212
new Promise<void>((resolve) => requestAnimationFrame(() => resolve()));
1313

14-
export const toggleInvisible = async (
14+
export const toggleInvisible = (
1515
element: HTMLElement,
1616
isInvisible: boolean,
1717
) => {

typescript/packages/common-ui/src/components/common-form.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export class ReferenceFieldElement extends LitElement {
6262
<input
6363
class="field-input ${this.error ? "has-error" : ""}"
6464
.value=${this.value}
65-
@input=${async (e: Event) => {
65+
@input=${(e: Event) => {
6666
const value = (e.target as HTMLInputElement).value;
6767
this.dispatch(value);
6868
}}
@@ -96,7 +96,7 @@ export class ZodFormSubmitEvent extends Event {
9696

9797
@customElement("common-form")
9898
export class CommonFormElement extends LitElement {
99-
static properties = {
99+
static override properties = {
100100
value: {},
101101
};
102102
private _internalValue: { [key: string]: any } = {};
@@ -316,10 +316,11 @@ export class CommonFormElement extends LitElement {
316316
case "ZodObject":
317317
sample[key] = {};
318318
break;
319-
case "ZodEnum":
319+
case "ZodEnum": {
320320
const values = (fieldSchema as any)._def.values;
321321
sample[key] = values[Math.floor(Math.random() * values.length)];
322322
break;
323+
}
323324
case "ZodArray":
324325
sample[key] = [];
325326
break;
@@ -486,7 +487,7 @@ export class CommonFormElement extends LitElement {
486487
}
487488

488489
// Create a copy of the current value to modify
489-
let submitValue = { ...this._internalValue };
490+
const submitValue = { ...this._internalValue };
490491

491492
// If there are reference fields, convert them before submission
492493
if (this.referenceFields.size > 0) {

typescript/packages/common-ui/src/components/common-input-file.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export class CommonFileInputElement extends LitElement {
9595
* @param files Array of File objects to be read.
9696
* @returns Promise resolving to an array containing each file and its content.
9797
*/
98-
private async readFiles(files: File[]): Promise<FileContent[]> {
98+
private readFiles(files: File[]): Promise<FileContent[]> {
9999
const readFile = (file: File): Promise<FileContent> => {
100100
return new Promise((resolve) => {
101101
const reader = new FileReader();

typescript/packages/common-ui/src/components/common-table.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -355,26 +355,26 @@ export class CommonTableElement extends LitElement {
355355
handleDownload(item: any) {
356356
const data = JSON.stringify(item, null, 2);
357357
const blob = new Blob([data], { type: "application/json" });
358-
const url = window.URL.createObjectURL(blob);
358+
const url = globalThis.URL.createObjectURL(blob);
359359
const a = document.createElement("a");
360360
a.href = url;
361361
a.download = `data-${Date.now()}.json`;
362362
document.body.appendChild(a);
363363
a.click();
364-
window.URL.revokeObjectURL(url);
364+
globalThis.URL.revokeObjectURL(url);
365365
document.body.removeChild(a);
366366
}
367367

368368
handleDownloadAll() {
369369
const data = JSON.stringify(this.data, null, 2);
370370
const blob = new Blob([data], { type: "application/json" });
371-
const url = window.URL.createObjectURL(blob);
371+
const url = globalThis.URL.createObjectURL(blob);
372372
const a = document.createElement("a");
373373
a.href = url;
374374
a.download = `all-data-${Date.now()}.json`;
375375
document.body.appendChild(a);
376376
a.click();
377-
window.URL.revokeObjectURL(url);
377+
globalThis.URL.revokeObjectURL(url);
378378
document.body.removeChild(a);
379379
}
380380

@@ -386,7 +386,7 @@ export class CommonTableElement extends LitElement {
386386
}
387387
}
388388

389-
async handleImport(_: Event) {
389+
handleImport(_: Event) {
390390
const input = document.createElement("input");
391391
input.type = "file";
392392
input.accept = ".json";

typescript/packages/common-ui/src/components/shoelace/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { registerIconLibrary } from "@shoelace-style/shoelace";
88
* Calling with no arguments will perform this on `document`.
99
*/
1010
export const adoptShoelaceStyles = (
11-
host: Document | ShadowRoot = window.document,
11+
host: Document | ShadowRoot = globalThis.document,
1212
) => {
1313
host.adoptedStyleSheets = [theme.styleSheet!];
1414
};
@@ -28,7 +28,7 @@ export const registerShoelaceIcons = () => {
2828
};
2929

3030
export const setupShoelace = ({
31-
host = window.document,
31+
host = globalThis.document,
3232
}: {
3333
host?: Document | ShadowRoot;
3434
} = {}) => {

0 commit comments

Comments
 (0)