Skip to content

Commit 12594a3

Browse files
committed
fix: resolve ESLint errors and warnings
1 parent f73faec commit 12594a3

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

app/api/generate-schema-doc/route.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,11 +202,14 @@ export async function POST(request: Request) {
202202
} else if (LibraryModule && typeof LibraryModule === 'object') {
203203
// Use 'in' operator for safer property checking
204204
if ('default' in LibraryModule && LibraryModule.default && isDocConstructor(LibraryModule.default)) {
205-
Constructor = LibraryModule.default;
205+
// Add type assertion
206+
Constructor = LibraryModule.default as JsonSchemaStaticDocsConstructor;
206207
} else if ('JsonSchemaStaticDocs' in LibraryModule && LibraryModule.JsonSchemaStaticDocs && isDocConstructor(LibraryModule.JsonSchemaStaticDocs)) {
207-
Constructor = LibraryModule.JsonSchemaStaticDocs;
208+
// Add type assertion
209+
Constructor = LibraryModule.JsonSchemaStaticDocs as JsonSchemaStaticDocsConstructor;
208210
} else if ('DocGenerator' in LibraryModule && LibraryModule.DocGenerator && isDocConstructor(LibraryModule.DocGenerator)) {
209-
Constructor = LibraryModule.DocGenerator;
211+
// Add type assertion
212+
Constructor = LibraryModule.DocGenerator as JsonSchemaStaticDocsConstructor;
210213
}
211214
}
212215

components/ui/chart.tsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import * as React from "react";
44
import * as RechartsPrimitive from "recharts";
55
import { type Payload } from "recharts/types/component/DefaultTooltipContent";
6-
import type { TooltipProps } from "recharts/types/component/Tooltip";
76

87
import { cn } from "@/lib/utils";
98

@@ -103,14 +102,21 @@ ${colorConfig
103102
);
104103
};
105104

105+
// Define a more specific type for the payload within the item
106+
interface ChartTooltipItemPayload {
107+
fill?: string;
108+
// Add other potential properties based on your data structure if needed
109+
[key: string]: unknown;
110+
}
111+
106112
// Define explicit prop types using Recharts types
107113
interface ChartTooltipProps extends RechartsPrimitive.TooltipProps<number | string, string> {
108114
indicator?: 'dot' | 'line' | 'dashed';
109115
hideLabel?: boolean;
110116
hideIndicator?: boolean;
111117
labelKey?: string;
112118
labelFormatter?: (label: string, payload: Payload<number | string, string>[]) => React.ReactNode;
113-
formatter?: (value: number | string | Array<number | string>, name: string, item: Payload<number | string, string>, index: number, payload: Payload<number | string, string>["payload"] | undefined) => React.ReactNode;
119+
formatter?: (value: number | string | Array<number | string>, name: string, item: Payload<number | string, string>, index: number, payload: ChartTooltipItemPayload | undefined) => React.ReactNode;
114120
color?: string;
115121
className?: string;
116122
}
@@ -173,15 +179,13 @@ const ChartTooltip = ({ active, payload, label, className, indicator = "dot", hi
173179
const itemColor = typeof item.color === 'string' ? item.color : undefined;
174180
const indicatorColor: string = color || itemColor || payloadFill || "hsl(var(--primary))";
175181

176-
let formatterPayload: Payload<number | string, string>["payload"] | undefined = undefined;
182+
let formatterPayload: ChartTooltipItemPayload | undefined = undefined;
177183
if (
178184
typeof item.payload === 'object' &&
179185
item.payload !== null &&
180186
!(item.payload instanceof Error)
181187
) {
182-
// Disable persistent error for this assignment after checks
183-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
184-
formatterPayload = item.payload;
188+
formatterPayload = item.payload as ChartTooltipItemPayload;
185189
}
186190

187191
const safeValue = (typeof item.value === 'number' || typeof item.value === 'string') ? item.value : 0;

components/ui/use-toast.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,7 @@ const reducer = (state: State, action: Action): State => {
137137
}
138138
default:
139139
// Throw an error for unhandled cases
140-
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions, @typescript-eslint/no-explicit-any
141-
throw new Error(`Unhandled action type: ${(action as any).type}`);
140+
throw new Error(`Unhandled action type: ${(action as { type: unknown }).type}`);
142141
}
143142
};
144143

0 commit comments

Comments
 (0)