From 853be1f7763d33f87a7c9e2efbea87c19aabeb4d Mon Sep 17 00:00:00 2001 From: Kazuki Yamada Date: Sun, 17 Aug 2025 14:50:11 +0900 Subject: [PATCH] fix(website): resolve lint errors and revert tooltip styling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Replace 'any' with 'unknown' for better type safety - Convert forEach to for...of loop for better performance - Use proper type casting with unknown intermediate step - Revert tooltip colors back to original styling (#333 background, white text) - Fix all biome lint warnings 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- website/client/components/Home/TryIt.vue | 12 +++++--- website/client/composables/usePackOptions.ts | 4 +-- website/client/utils/urlParams.ts | 29 ++++++++++++-------- 3 files changed, 27 insertions(+), 18 deletions(-) diff --git a/website/client/components/Home/TryIt.vue b/website/client/components/Home/TryIt.vue index 01f8eda5..4c300ba8 100644 --- a/website/client/components/Home/TryIt.vue +++ b/website/client/components/Home/TryIt.vue @@ -103,7 +103,7 @@ import { FolderArchive, FolderOpen, Link2, RotateCcw } from 'lucide-vue-next'; import { computed, nextTick, onMounted, ref, watch } from 'vue'; import { usePackRequest } from '../../composables/usePackRequest'; -import { parseUrlParameters, updateUrlParameters, hasNonDefaultValues } from '../../utils/urlParams'; +import { hasNonDefaultValues, parseUrlParameters, updateUrlParameters } from '../../utils/urlParams'; import { isValidRemoteValue } from '../utils/validation'; import PackButton from './PackButton.vue'; import TryItFileUpload from './TryItFileUpload.vue'; @@ -148,7 +148,11 @@ const shouldShowReset = computed(() => { } // Use utility function to check for non-default values - return hasNonDefaultValues(inputUrl.value, packOptions, DEFAULT_PACK_OPTIONS); + return hasNonDefaultValues( + inputUrl.value, + packOptions as unknown as Record, + DEFAULT_PACK_OPTIONS as unknown as Record, + ); }); async function handleSubmit() { @@ -360,8 +364,8 @@ onMounted(() => { transform: translateX(-50%); margin-bottom: 8px; padding: 8px 12px; - background: var(--vp-c-bg-soft, #333); - color: var(--vp-c-text-1, white); + background: #333; + color: white; font-size: 0.875rem; white-space: nowrap; border-radius: 4px; diff --git a/website/client/composables/usePackOptions.ts b/website/client/composables/usePackOptions.ts index dbbf6b0e..59c6edf6 100644 --- a/website/client/composables/usePackOptions.ts +++ b/website/client/composables/usePackOptions.ts @@ -33,12 +33,12 @@ export function usePackOptions() { const initialOptions = { ...DEFAULT_PACK_OPTIONS }; // Apply URL parameters to initial options - (Object.keys(initialOptions) as Array).forEach((key) => { + for (const key of Object.keys(initialOptions) as Array) { if (key in urlParams && urlParams[key] !== undefined) { // Type-safe assignment: only assign if the key is a valid PackOptions key initialOptions[key] = urlParams[key] as PackOptions[typeof key]; } - }); + } const packOptions = reactive(initialOptions); diff --git a/website/client/utils/urlParams.ts b/website/client/utils/urlParams.ts index fcf732f7..1fdf52b5 100644 --- a/website/client/utils/urlParams.ts +++ b/website/client/utils/urlParams.ts @@ -27,14 +27,14 @@ function getUrlParamKey(internalKey: string): string { } // Helper function to validate URL parameter values -export function validateUrlParameters(params: Record): { isValid: boolean; errors: string[] } { +export function validateUrlParameters(params: Record): { isValid: boolean; errors: string[] } { const errors: string[] = []; - + // Validate format parameter if (params.format && !VALID_FORMATS.includes(params.format)) { errors.push(`Invalid format: ${params.format}. Must be one of: ${VALID_FORMATS.join(', ')}`); } - + // Validate URL length to prevent browser limit issues const urlSearchParams = new URLSearchParams(); for (const [key, value] of Object.entries(params)) { @@ -42,23 +42,25 @@ export function validateUrlParameters(params: Record): { isValid: b urlSearchParams.set(key, String(value)); } } - + const maxUrlLength = 2000; // Conservative limit for browser compatibility if (urlSearchParams.toString().length > maxUrlLength) { - errors.push(`URL parameters too long (${urlSearchParams.toString().length} chars). Maximum allowed: ${maxUrlLength}`); + errors.push( + `URL parameters too long (${urlSearchParams.toString().length} chars). Maximum allowed: ${maxUrlLength}`, + ); } - + return { isValid: errors.length === 0, - errors + errors, }; } // Helper function to check if any options differ from defaults export function hasNonDefaultValues( inputUrl: string, - packOptions: Record, - defaultOptions: Record + packOptions: Record, + defaultOptions: Record, ): boolean { // Check if there's input URL if (inputUrl && inputUrl.trim() !== '') { @@ -96,13 +98,13 @@ export function parseUrlParameters(): Partial { // Format parameter const format = urlParams.get('format'); - if (format && VALID_FORMATS.includes(format as any)) { + if (format && (VALID_FORMATS as readonly string[]).includes(format)) { params.format = format as (typeof VALID_FORMATS)[number]; } // Style parameter (alternative to format for backward compatibility) const style = urlParams.get('style'); - if (style && VALID_FORMATS.includes(style as any)) { + if (style && (VALID_FORMATS as readonly string[]).includes(style)) { params.format = style as (typeof VALID_FORMATS)[number]; } @@ -130,7 +132,10 @@ export function parseUrlParameters(): Partial { return params; } -export function updateUrlParameters(options: Partial): { success: boolean; error?: string } { +export function updateUrlParameters(options: Partial): { + success: boolean; + error?: string; +} { if (typeof window === 'undefined') { return { success: false, error: 'Window object not available (SSR environment)' }; }