From e1c0318d9b1a246898a0339252fa41a98c7373b3 Mon Sep 17 00:00:00 2001 From: Alicia Sykes Date: Thu, 26 Feb 2026 14:36:21 +0000 Subject: [PATCH] Fixes remaining lint issues, updates footer date --- web/src/components/scafold/Footer.astro | 9 +- .../components/things/AddNewService.svelte | 18 ++- .../things/AndroidDetailedInfo.astro | 2 +- .../things/DiscordDetailedInfo.astro | 2 - .../things/IosAppDetailedInfo.astro | 4 +- .../components/things/ItemGitHubMetrics.astro | 21 ++-- .../things/RedditDetailedInfo.astro | 3 +- .../components/things/SavedServices.svelte | 2 +- web/src/components/things/Search.svelte | 14 +-- web/src/components/things/ServiceCard.astro | 2 +- web/src/components/things/ServiceCard.svelte | 3 +- web/src/layouts/Layout.astro | 5 +- web/src/pages/about.astro | 106 +++++++++++++----- .../pages/inventory/[...inventoryId].astro | 2 - web/src/pages/search/[...searchTerm].astro | 46 ++++---- web/src/utils/do-searchy-searchy.test.ts | 9 +- web/src/utils/do-searchy-searchy.ts | 16 ++- web/src/utils/fetch-website-info.ts | 2 +- 18 files changed, 173 insertions(+), 93 deletions(-) diff --git a/web/src/components/scafold/Footer.astro b/web/src/components/scafold/Footer.astro index ed7a7ba..4e9064a 100644 --- a/web/src/components/scafold/Footer.astro +++ b/web/src/components/scafold/Footer.astro @@ -1,8 +1,13 @@ +--- +const year = new Date().getFullYear(); +--- + diff --git a/web/src/components/things/AddNewService.svelte b/web/src/components/things/AddNewService.svelte index a77cdd0..3e8aa7d 100644 --- a/web/src/components/things/AddNewService.svelte +++ b/web/src/components/things/AddNewService.svelte @@ -20,24 +20,31 @@ const serviceCrypto = writable(false); const additionalInfo = writable(''); - let codeBlock: any; + let codeBlock: HTMLElement | undefined; let interactiveActivated = false; $: (yamlText, updateHighlighting()); + /* eslint-disable svelte/no-dom-manipulating -- hljs requires direct DOM access for syntax highlighting */ function updateHighlighting() { if (codeBlock) { codeBlock.textContent = yamlText; codeBlock.dataset.highlighted && delete codeBlock.dataset.highlighted; - if (window && (window as any).hljs) { - (window as any).hljs.highlightElement(codeBlock); + const hljs = ( + window as Window & { + hljs?: { highlightElement: (el: HTMLElement) => void }; + } + ).hljs; + if (hljs) { + hljs.highlightElement(codeBlock); interactiveActivated = true; } } } + /* eslint-enable svelte/no-dom-manipulating */ - const filterEmptyValues = (obj: Record) => { - const filteredObj: Record = {}; + const filterEmptyValues = (obj: Record) => { + const filteredObj: Record = {}; Object.keys(obj).forEach((key) => { if (obj[key] || ['name', 'url', 'icon', 'description'].includes(key)) { filteredObj[key] = obj[key]; @@ -397,6 +404,7 @@ upon approval.

{#if !interactiveActivated || !codeBlock} +
{@html yamlText}
{/if}
diff --git a/web/src/components/things/AndroidDetailedInfo.astro b/web/src/components/things/AndroidDetailedInfo.astro index e9b2400..f4ad460 100644 --- a/web/src/components/things/AndroidDetailedInfo.astro +++ b/web/src/components/things/AndroidDetailedInfo.astro @@ -1,6 +1,6 @@ --- import type { AndroidInfo } from '@utils/fetch-android-info'; -import { formatDate, timeAgo } from '@utils/dates-n-stuff'; +import { formatDate } from '@utils/dates-n-stuff'; import FontAwesome from '@components/form/FontAwesome.svelte'; interface Props { diff --git a/web/src/components/things/DiscordDetailedInfo.astro b/web/src/components/things/DiscordDetailedInfo.astro index 0696a43..7b0eb84 100644 --- a/web/src/components/things/DiscordDetailedInfo.astro +++ b/web/src/components/things/DiscordDetailedInfo.astro @@ -1,7 +1,5 @@ --- import type { DiscordInfo } from '@utils/fetch-discord-info'; -import { formatDate, timeAgo } from '@utils/dates-n-stuff'; -import FontAwesome from '@components/form/FontAwesome.svelte'; interface Props { discordData: DiscordInfo; diff --git a/web/src/components/things/IosAppDetailedInfo.astro b/web/src/components/things/IosAppDetailedInfo.astro index 3884098..1979c08 100644 --- a/web/src/components/things/IosAppDetailedInfo.astro +++ b/web/src/components/things/IosAppDetailedInfo.astro @@ -1,7 +1,7 @@ --- import type { IoSApiResponse } from '@utils/fetch-ios-info'; -import { formatDate, timeAgo } from '@utils/dates-n-stuff'; +import { formatDate } from '@utils/dates-n-stuff'; import FontAwesome from "@components/form/FontAwesome.svelte" @@ -18,7 +18,7 @@ const makeRatingPercentage = (rating: number) => (rating / 5) * 100; const roundRatings = (rating: number) => Math.round(rating * 100) / 100; -const putCommaInNumber = (num: number | any) => { +const putCommaInNumber = (num: number | string | undefined) => { if (!num) return 'Unknown'; return typeof num === 'number' ? num.toLocaleString() : num; } diff --git a/web/src/components/things/ItemGitHubMetrics.astro b/web/src/components/things/ItemGitHubMetrics.astro index ff95855..ebb7ad4 100644 --- a/web/src/components/things/ItemGitHubMetrics.astro +++ b/web/src/components/things/ItemGitHubMetrics.astro @@ -2,13 +2,19 @@ import FontAwesome from "@components/form/FontAwesome.svelte"; const { github } = Astro.props; -// const [user, repo] = github.split("/"); +interface GitHubRepoData { + stargazers_count?: number; + forks_count?: number; + open_issues_count?: number; + language?: string; + license?: { spdx_id?: string; name?: string }; +} /** * For a given `user/repo` fetch repository stats from the GitHub API data * If API key is available through env var, use it to increase rate limit * Returns the response data and status code (200 == success) - * @param repo + * @param repo */ const fetchGitHubData = async (repo: string) => { const apiKey = import.meta.env.GITHUB_API_KEY; @@ -17,8 +23,8 @@ const fetchGitHubData = async (repo: string) => { headers.append("Authorization", `token ${apiKey}`); } - let data = {}; - let statusCode = 0; + let data: GitHubRepoData = {}; + let statusCode; const response = await fetch(`https://api.github.com/repos/${repo}`, { headers: headers, @@ -50,7 +56,7 @@ const fetchGitHubData = async (repo: string) => { * Given a license object, return SPDX ID, or a formatted name * @param license */ -const formatLicense = (license: { spdx_id?: string, name?: string }) => { +const formatLicense = (license?: { spdx_id?: string, name?: string }) => { if (!license) { return "Unknown"; } @@ -65,7 +71,8 @@ const formatLicense = (license: { spdx_id?: string, name?: string }) => { * E.g. If greater than thousand, then return in k format * @param num */ -const formatBigNumber = (num: number) => { +const formatBigNumber = (num: number | undefined) => { + if (num == null) return 0; if (num > 1000) { return `${(num / 1000).toFixed(1)}k`; } @@ -73,7 +80,7 @@ const formatBigNumber = (num: number) => { } // Initiate GitHub fetch, and make available to the component -const stats = (await fetchGitHubData(github)) as any; +const stats = await fetchGitHubData(github); const { stargazers_count, forks_count, open_issues_count, language, license, diff --git a/web/src/components/things/RedditDetailedInfo.astro b/web/src/components/things/RedditDetailedInfo.astro index d76b473..e7776bb 100644 --- a/web/src/components/things/RedditDetailedInfo.astro +++ b/web/src/components/things/RedditDetailedInfo.astro @@ -1,7 +1,6 @@ --- import type { RedditData } from '@utils/fetch-reddit-info'; -import { timestampToDate, timeAgo } from '@utils/dates-n-stuff'; -import FontAwesome from '@components/form/FontAwesome.svelte'; +import { timestampToDate } from '@utils/dates-n-stuff'; interface Props { redditData: RedditData; diff --git a/web/src/components/things/SavedServices.svelte b/web/src/components/things/SavedServices.svelte index 713f035..393e908 100644 --- a/web/src/components/things/SavedServices.svelte +++ b/web/src/components/things/SavedServices.svelte @@ -48,7 +48,7 @@
{#if $savedServices.length > 0}
- {#each $savedServices as thingy} + {#each $savedServices as thingy (thingy.service.name + thingy.section)} ; + let fuse: Fuse; let searchQuery = ''; - let results: any[] = []; + let results: SearchItem[]; // Initialize Fuse.js onMount(() => { @@ -91,7 +87,7 @@ {#if searchQuery.length > 0} @@ -64,5 +65,5 @@
diff --git a/web/src/layouts/Layout.astro b/web/src/layouts/Layout.astro index d0c585c..12b4472 100644 --- a/web/src/layouts/Layout.astro +++ b/web/src/layouts/Layout.astro @@ -10,7 +10,7 @@ interface Props { keywords?: string; // Overide keywords tag hideNav?: boolean; // Don't show the navbar (just homepage) author?: string; // Author of the content - customSchemaJson?: any; // Custom schema item + customSchemaJson?: Record; // Custom schema item breadcrumbs?: Array<{ name: string; item: string; @@ -121,6 +121,7 @@ const makeSearchLd = () => { { breadcrumbs && (