From 8325deb2d37ebda615c9b1df0194b20dc946cac4 Mon Sep 17 00:00:00 2001 From: Chege Gitau Date: Sat, 15 Jun 2024 17:30:27 -0700 Subject: [PATCH] [Linting] Fix some violations of `no-explicit-any` Docs for rule at [1]. Fixes 7 violations; 29 left for #162. [1]: https://typescript-eslint.io/rules/no-explicit-any/ --- src/models/mongoose_models/MetadataCardSchema.ts | 8 ++++++-- .../components/card-viewer/base-card-viewer.ts | 15 +++++++++++---- .../components/editable-card-description.ts | 4 ++-- .../card-viewer/editable-card-viewer.ts | 6 +++--- .../components/card-viewer/public-card-viewer.ts | 2 +- src/public/src/models/core/ternary-search-trie.ts | 2 +- src/server.ts | 2 +- 7 files changed, 25 insertions(+), 14 deletions(-) diff --git a/src/models/mongoose_models/MetadataCardSchema.ts b/src/models/mongoose_models/MetadataCardSchema.ts index fabe0748..f6a9bac0 100644 --- a/src/models/mongoose_models/MetadataCardSchema.ts +++ b/src/models/mongoose_models/MetadataCardSchema.ts @@ -12,12 +12,16 @@ export interface IStreak { timeStamp: number; } -export type IStreakMap = IStreak & Map; +export type IStreakMap = IStreak & Map | number>; interface IMetadataNodeInformationEntry { [id: string]: { urgency: number }; } +interface IMetadataNodeStatsEntry { + [id: string]: { urgency?: number }; +} + export interface IMetadataNodeInformation { [tag: string]: IMetadataNodeInformationEntry; } @@ -31,7 +35,7 @@ export interface IMetadata { metadataIndex: number; node_information: Array; trashed_cards: Array; - stats: Array; + stats: Array; streak: IStreak; cardsAreByDefaultPrivate: boolean; } diff --git a/src/public/src/components/card-viewer/base-card-viewer.ts b/src/public/src/components/card-viewer/base-card-viewer.ts index 8b4a32f7..664c3c78 100644 --- a/src/public/src/components/card-viewer/base-card-viewer.ts +++ b/src/public/src/components/card-viewer/base-card-viewer.ts @@ -1,5 +1,12 @@ import { consume } from "@lit/context"; -import { css, html, LitElement, nothing, TemplateResult } from "lit"; +import { + css, + html, + LitElement, + nothing, + PropertyValues, + TemplateResult, +} from "lit"; import { property } from "lit/decorators.js"; import { createRef, Ref, ref } from "lit/directives/ref.js"; import { unsafeHTML } from "lit/directives/unsafe-html.js"; @@ -28,7 +35,7 @@ export interface CardDescription { export class CardViewer extends LitElement { @property({ type: Object }) - protected card: Card | null = null; + public card: Card | null = null; @consume({ context: cardsCarouselContext, subscribe: true }) protected cardsCarousel?: CardsCarousel; @@ -49,13 +56,13 @@ export class CardViewer extends LitElement { return new Set(this.card.tags.split(" ").filter(Boolean)); } - protected willUpdate(changedProperties: Map) { + protected willUpdate(changedProperties: PropertyValues) { if (changedProperties.has("card")) { this.updatePromptAndResponse(); } } - updated(changedProperties: Map) { + updated(changedProperties: PropertyValues) { if (changedProperties.has("card")) { if (this.card) { this.cardDialogRef.value?.showModal(); diff --git a/src/public/src/components/card-viewer/components/editable-card-description.ts b/src/public/src/components/card-viewer/components/editable-card-description.ts index 93df9ddf..405bb09f 100644 --- a/src/public/src/components/card-viewer/components/editable-card-description.ts +++ b/src/public/src/components/card-viewer/components/editable-card-description.ts @@ -1,4 +1,4 @@ -import { css, html, LitElement } from "lit"; +import { css, html, LitElement, PropertyValues } from "lit"; import { customElement, property, state } from "lit/decorators.js"; import { createRef, Ref, ref } from "lit/directives/ref.js"; @@ -20,7 +20,7 @@ export class EditableCardDescriptionElement extends LitElement { private descriptionRef: Ref = createRef(); - protected willUpdate(changedProperties: Map) { + protected willUpdate(changedProperties: PropertyValues) { if (changedProperties.has("value") || changedProperties.has("canEdit")) { this.showOverlay = !this.canEdit && this.value && this.value.type === CardDescriptionType.Response; diff --git a/src/public/src/components/card-viewer/editable-card-viewer.ts b/src/public/src/components/card-viewer/editable-card-viewer.ts index 47e6a8ad..dabe1b40 100644 --- a/src/public/src/components/card-viewer/editable-card-viewer.ts +++ b/src/public/src/components/card-viewer/editable-card-viewer.ts @@ -1,4 +1,4 @@ -import { css, html, nothing } from "lit"; +import { css, html, nothing, PropertyValues } from "lit"; import { customElement, property, state } from "lit/decorators.js"; import { CardsCarouselUpdateCursorDirection } from "../../context/cards-carousel-context.js"; @@ -29,14 +29,14 @@ export class EditableCardViewer extends CardViewer { } @property({ type: Object }) - protected card: PrivateCardResult = null; + public card: PrivateCardResult = null; @state() protected canEdit = false; private pendingChanges: PendingChanges = {}; - protected willUpdate(changedProperties: Map) { + protected willUpdate(changedProperties: PropertyValues) { if (changedProperties.has("card")) { this.canEdit = false; } diff --git a/src/public/src/components/card-viewer/public-card-viewer.ts b/src/public/src/components/card-viewer/public-card-viewer.ts index 895313db..ba6b4e5c 100644 --- a/src/public/src/components/card-viewer/public-card-viewer.ts +++ b/src/public/src/components/card-viewer/public-card-viewer.ts @@ -17,7 +17,7 @@ enum FlagReason { @customElement("public-card-viewer") export class PublicCardViewer extends CardViewer { @property({ type: Object }) - protected card: PublicCardResult = null; + public card: PublicCardResult = null; private flagCard(reason: FlagReason) { if (!this.card) { diff --git a/src/public/src/models/core/ternary-search-trie.ts b/src/public/src/models/core/ternary-search-trie.ts index ac35c5c4..a4fa3d7a 100644 --- a/src/public/src/models/core/ternary-search-trie.ts +++ b/src/public/src/models/core/ternary-search-trie.ts @@ -3,7 +3,7 @@ interface TSTNode { left: TSTNode | null; mid: TSTNode | null; right: TSTNode | null; - val: any; + val: boolean | null; } /** diff --git a/src/server.ts b/src/server.ts index 82dcd171..b585bb14 100644 --- a/src/server.ts +++ b/src/server.ts @@ -106,7 +106,7 @@ if (config.IS_TS_NODE) { app.use(express.static(newStaticsPath)); } -app.use(function(err: any, req: Request, res: Response) { +app.use(function(err: Error, req: Request, res: Response) { console.error(err.stack); res.status(500).render( "pages/5xx_error_page.ejs",