From 5ac93645e460e4adb2aada8e85b7eaa0144a9228 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 10 Apr 2023 05:06:53 +0000 Subject: [PATCH] Lint Code [skip actions] --- src/handbook/src/backend/types.ts | 30 +++++--- src/handbook/src/ui/pages/EntitiesPage.tsx | 24 +++--- src/handbook/src/ui/pages/ItemsPage.tsx | 22 +++--- src/handbook/src/ui/widgets/EntityCard.tsx | 86 ++++++++++++---------- src/handbook/src/ui/widgets/MiniCard.tsx | 10 +-- 5 files changed, 94 insertions(+), 78 deletions(-) diff --git a/src/handbook/src/backend/types.ts b/src/handbook/src/backend/types.ts index 559a9263f..0e83545c5 100644 --- a/src/handbook/src/backend/types.ts +++ b/src/handbook/src/backend/types.ts @@ -1,7 +1,5 @@ -export type Page = "Home" | "Commands" | "Avatars" | "Items" - | "Entities" | "Scenes"; -export type Days = "Sunday" | "Monday" | "Tuesday" - | "Wednesday" | "Thursday" | "Friday" | "Saturday"; +export type Page = "Home" | "Commands" | "Avatars" | "Items" | "Entities" | "Scenes"; +export type Days = "Sunday" | "Monday" | "Tuesday" | "Wednesday" | "Thursday" | "Friday" | "Saturday"; export type Command = { name: string[]; @@ -136,13 +134,21 @@ export function isPage(page: string): page is Page { */ export function itemTypeToString(type: ItemType): string { switch (type) { - default: return "Unknown"; - case ItemType.None: return "None"; - case ItemType.Virtual: return "Virtual"; - case ItemType.Material: return "Material"; - case ItemType.Reliquary: return "Reliquary"; - case ItemType.Weapon: return "Weapon"; - case ItemType.Display: return "Display"; - case ItemType.Furniture: return "Furniture"; + default: + return "Unknown"; + case ItemType.None: + return "None"; + case ItemType.Virtual: + return "Virtual"; + case ItemType.Material: + return "Material"; + case ItemType.Reliquary: + return "Reliquary"; + case ItemType.Weapon: + return "Weapon"; + case ItemType.Display: + return "Display"; + case ItemType.Furniture: + return "Furniture"; } } diff --git a/src/handbook/src/ui/pages/EntitiesPage.tsx b/src/handbook/src/ui/pages/EntitiesPage.tsx index ac15f7515..f0dbe96da 100644 --- a/src/handbook/src/ui/pages/EntitiesPage.tsx +++ b/src/handbook/src/ui/pages/EntitiesPage.tsx @@ -93,9 +93,10 @@ class EntitiesPage extends React.Component<{}, IState> { * @private */ private async setSelectedItem(entity: EntityType): Promise { - let data: EntityInfo | null = null; try { + let data: EntityInfo | null = null; + try { data = await fetchEntityData(entity); - } catch { } + } catch {} this.setState({ selected: entity, @@ -124,24 +125,25 @@ class EntitiesPage extends React.Component<{}, IState> { {entities.length > 0 ? ( this.showEntity(entity))} + list={entities.filter((entity) => this.showEntity(entity))} itemHeight={64} itemsPerRow={18} gap={5} itemGap={5} - render={(entity) => this.setSelectedItem(entity)} - />} + render={(entity) => ( + this.setSelectedItem(entity)} + /> + )} /> ) : undefined}
- +
); diff --git a/src/handbook/src/ui/pages/ItemsPage.tsx b/src/handbook/src/ui/pages/ItemsPage.tsx index 16b28aadb..1f4096737 100644 --- a/src/handbook/src/ui/pages/ItemsPage.tsx +++ b/src/handbook/src/ui/pages/ItemsPage.tsx @@ -97,9 +97,10 @@ class ItemsPage extends React.Component<{}, IState> { * @private */ private async setSelectedItem(item: ItemType): Promise { - let data: ItemInfo | null = null; try { + let data: ItemInfo | null = null; + try { data = await fetchItemData(item); - } catch { } + } catch {} this.setState({ selected: item, @@ -133,19 +134,20 @@ class ItemsPage extends React.Component<{}, IState> { itemsPerRow={18} gap={5} itemGap={5} - render={(item) => this.setSelectedItem(item)} - />} + render={(item) => ( + this.setSelectedItem(item)} + /> + )} /> ) : undefined}
- +
); diff --git a/src/handbook/src/ui/widgets/EntityCard.tsx b/src/handbook/src/ui/widgets/EntityCard.tsx index 34fbc4d9d..0e3829a45 100644 --- a/src/handbook/src/ui/widgets/EntityCard.tsx +++ b/src/handbook/src/ui/widgets/EntityCard.tsx @@ -13,10 +13,9 @@ import "@css/widgets/ItemCard.scss"; function toDescription(description: string | undefined): JSX.Element[] { if (!description) return []; - return description.split("\\n") - .map((line, index) => { - return

{line}

; - }); + return description.split("\\n").map((line, index) => { + return

{line}

; + }); } interface IProps { @@ -64,8 +63,7 @@ class EntityCard extends React.Component { private addCount(positive: boolean, multiple: boolean) { let { count } = this.state; if (count === "") count = 1; - if (typeof count == "string") - count = parseInt(count); + if (typeof count == "string") count = parseInt(count); if (count < 1) count = 1; let increment = 1; @@ -104,49 +102,57 @@ class EntityCard extends React.Component {

{data?.type ?? ""}

- { this.state.icon && {entity.name} this.setState({ icon: false })} - /> } + {this.state.icon && ( + {entity.name} this.setState({ icon: false })} + /> + )} -
- {toDescription(data?.description)} -
+
{toDescription(data?.description)}
-
this.addCount(false, false)} - onContextMenu={(e) => { - e.preventDefault(); - this.addCount(false, true); - }} - className={"ItemCard_Operation"}>-
- { - if (this.state.count == "") { - this.setState({ count: 1 }); - } - }} +
this.addCount(false, false)} + onContextMenu={(e) => { + e.preventDefault(); + this.addCount(false, true); + }} + className={"ItemCard_Operation"} + > + - +
+ { + if (this.state.count == "") { + this.setState({ count: 1 }); + } + }} /> -
this.addCount(true, false)} - onContextMenu={(e) => { - e.preventDefault(); - this.addCount(true, true); - }} - className={"ItemCard_Operation"}>+
+
this.addCount(true, false)} + onContextMenu={(e) => { + e.preventDefault(); + this.addCount(true, true); + }} + className={"ItemCard_Operation"} + > + + +
- +
) : undefined; diff --git a/src/handbook/src/ui/widgets/MiniCard.tsx b/src/handbook/src/ui/widgets/MiniCard.tsx index f364a66f5..a286e1530 100644 --- a/src/handbook/src/ui/widgets/MiniCard.tsx +++ b/src/handbook/src/ui/widgets/MiniCard.tsx @@ -5,7 +5,7 @@ import { itemIcon } from "@app/utils"; import "@css/widgets/MiniCard.scss"; interface IProps { - data: { name: string; }; + data: { name: string }; icon: string; onClick?: () => void; @@ -53,9 +53,7 @@ class MiniCard extends React.Component { render() { return ( -
+
{this.state.icon && ( { /> )} - {(!this.state.loaded || !this.state.icon) &&

{this.props.data.name}

} + {(!this.state.loaded || !this.state.icon) && ( +

{this.props.data.name}

+ )}
);