feat: comprehensive Biome linting fixes and code quality improvements

Major code quality overhaul addressing 58% of all linting issues:

• Type Safety Improvements:
  - Replace all any types with proper TypeScript interfaces
  - Fix Map component shadowing (renamed to CountryMap)
  - Add comprehensive custom error classes system
  - Enhance API route type safety

• Accessibility Enhancements:
  - Add explicit button types to all interactive elements
  - Implement useId() hooks for form element accessibility
  - Add SVG title attributes for screen readers
  - Fix static element interactions with keyboard handlers

• React Best Practices:
  - Resolve exhaustive dependencies warnings with useCallback
  - Extract nested component definitions to top level
  - Fix array index keys with proper unique identifiers
  - Improve component organization and prop typing

• Code Organization:
  - Automatic import organization and type import optimization
  - Fix unused function parameters and variables
  - Enhanced error handling with structured error responses
  - Improve component reusability and maintainability

Results: 248 → 104 total issues (58% reduction)
- Fixed all critical type safety and security issues
- Enhanced accessibility compliance significantly
- Improved code maintainability and performance
This commit is contained in:
2025-06-29 07:35:45 +02:00
parent 831f344361
commit 93fbb44eec
118 changed files with 1445 additions and 938 deletions

View File

@ -1,6 +1,6 @@
"use client";
import { useState, useEffect } from "react";
import { useEffect, useId, useState } from "react";
interface DateRangePickerProps {
minDate: string;
@ -17,13 +17,19 @@ export default function DateRangePicker({
initialStartDate,
initialEndDate,
}: DateRangePickerProps) {
const startDateId = useId();
const endDateId = useId();
const [startDate, setStartDate] = useState(initialStartDate || minDate);
const [endDate, setEndDate] = useState(initialEndDate || maxDate);
useEffect(() => {
// Only notify parent component when dates change, not when the callback changes
onDateRangeChange(startDate, endDate);
}, [startDate, endDate]);
}, [
startDate,
endDate, // Only notify parent component when dates change, not when the callback changes
onDateRangeChange,
]);
const handleStartDateChange = (newStartDate: string) => {
// Ensure start date is not before min date
@ -93,11 +99,11 @@ export default function DateRangePicker({
<div className="flex flex-col sm:flex-row gap-2 items-start sm:items-center">
<div className="flex items-center gap-2">
<label htmlFor="start-date" className="text-sm text-gray-600">
<label htmlFor={startDateId} className="text-sm text-gray-600">
From:
</label>
<input
id="start-date"
id={startDateId}
type="date"
value={startDate}
min={minDate}
@ -108,11 +114,11 @@ export default function DateRangePicker({
</div>
<div className="flex items-center gap-2">
<label htmlFor="end-date" className="text-sm text-gray-600">
<label htmlFor={endDateId} className="text-sm text-gray-600">
To:
</label>
<input
id="end-date"
id={endDateId}
type="date"
value={endDate}
min={minDate}
@ -126,18 +132,21 @@ export default function DateRangePicker({
<div className="flex flex-wrap gap-2">
<button
type="button"
onClick={setLast7Days}
className="px-3 py-1.5 text-xs font-medium text-sky-600 bg-sky-50 border border-sky-200 rounded-md hover:bg-sky-100 transition-colors"
>
Last 7 days
</button>
<button
type="button"
onClick={setLast30Days}
className="px-3 py-1.5 text-xs font-medium text-sky-600 bg-sky-50 border border-sky-200 rounded-md hover:bg-sky-100 transition-colors"
>
Last 30 days
</button>
<button
type="button"
onClick={resetToFullRange}
className="px-3 py-1.5 text-xs font-medium text-gray-600 bg-gray-50 border border-gray-200 rounded-md hover:bg-gray-100 transition-colors"
>