mirror of
https://github.com/kjanat/livedash-node.git
synced 2026-01-16 14:12:10 +01:00
refactor: achieve 100% biome compliance with comprehensive code quality improvements
- Fix all cognitive complexity violations (63→0 errors) - Replace 'any' types with proper TypeScript interfaces and generics - Extract helper functions and custom hooks to reduce complexity - Fix React hook dependency arrays and useCallback patterns - Remove unused imports, variables, and functions - Implement proper formatting across all files - Add type safety with interfaces like AIProcessingRequestWithSession - Fix circuit breaker implementation with proper reset() method - Resolve all accessibility and form labeling issues - Clean up mysterious './0' file containing biome output Total: 63 errors → 0 errors, 42 warnings → 0 warnings
This commit is contained in:
@ -8,6 +8,7 @@
|
||||
"use client";
|
||||
|
||||
import type { FormEvent, ReactNode } from "react";
|
||||
import { useId } from "react";
|
||||
import { useCSRFForm } from "../../lib/hooks/useCSRF";
|
||||
|
||||
interface CSRFProtectedFormProps {
|
||||
@ -82,6 +83,11 @@ export function CSRFProtectedForm({
|
||||
* Example usage component showing how to use CSRF protected forms
|
||||
*/
|
||||
export function ExampleCSRFForm() {
|
||||
// Generate unique IDs for form elements
|
||||
const nameId = useId();
|
||||
const emailId = useId();
|
||||
const messageId = useId();
|
||||
|
||||
const handleCustomSubmit = async (formData: FormData) => {
|
||||
// Custom form submission logic
|
||||
const data = Object.fromEntries(formData.entries());
|
||||
@ -104,14 +110,14 @@ export function ExampleCSRFForm() {
|
||||
>
|
||||
<div>
|
||||
<label
|
||||
htmlFor="name"
|
||||
htmlFor={nameId}
|
||||
className="block text-sm font-medium text-gray-700"
|
||||
>
|
||||
Name
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
id="name"
|
||||
id={nameId}
|
||||
name="name"
|
||||
required
|
||||
className="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500"
|
||||
@ -120,14 +126,14 @@ export function ExampleCSRFForm() {
|
||||
|
||||
<div>
|
||||
<label
|
||||
htmlFor="email"
|
||||
htmlFor={emailId}
|
||||
className="block text-sm font-medium text-gray-700"
|
||||
>
|
||||
Email
|
||||
</label>
|
||||
<input
|
||||
type="email"
|
||||
id="email"
|
||||
id={emailId}
|
||||
name="email"
|
||||
required
|
||||
className="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500"
|
||||
@ -136,13 +142,13 @@ export function ExampleCSRFForm() {
|
||||
|
||||
<div>
|
||||
<label
|
||||
htmlFor="message"
|
||||
htmlFor={messageId}
|
||||
className="block text-sm font-medium text-gray-700"
|
||||
>
|
||||
Message
|
||||
</label>
|
||||
<textarea
|
||||
id="message"
|
||||
id={messageId}
|
||||
name="message"
|
||||
rows={4}
|
||||
className="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500"
|
||||
|
||||
Reference in New Issue
Block a user