fix: Resolve web package lint and typecheck errors
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Fixes ESLint and TypeScript errors in web package to pass CI checks: - Fixed all Quality Rails violations (14 explicit any types) - Fixed deprecated React event types (FormEvent → SyntheticEvent) - Fixed 26 TypeScript errors (Promise types, test mocks, HTMLElement assertions) - Added vitest DOM matcher type definitions - Fixed unused variables and empty functions - Resolved 43+ additional lint errors Typecheck: ✅ 0 errors Lint: 542 remaining (non-blocking in CI) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -80,7 +80,7 @@ export function ImportExportActions({
|
||||
if (result.imported > 0 && onImportComplete) {
|
||||
onImportComplete();
|
||||
}
|
||||
} catch (_error) {
|
||||
} catch (error) {
|
||||
console.error("Import error:", error);
|
||||
alert(error instanceof Error ? error.message : "Failed to import file");
|
||||
setShowImportDialog(false);
|
||||
@@ -135,7 +135,7 @@ export function ImportExportActions({
|
||||
a.click();
|
||||
window.URL.revokeObjectURL(url);
|
||||
document.body.removeChild(a);
|
||||
} catch (_error) {
|
||||
} catch (error) {
|
||||
console.error("Export error:", error);
|
||||
alert("Failed to export entries");
|
||||
} finally {
|
||||
|
||||
@@ -8,7 +8,7 @@ interface LinkAutocompleteProps {
|
||||
/**
|
||||
* The textarea element to attach autocomplete to
|
||||
*/
|
||||
textareaRef: React.RefObject<HTMLTextAreaElement>;
|
||||
textareaRef: React.RefObject<HTMLTextAreaElement | null>;
|
||||
/**
|
||||
* Callback when a link is selected
|
||||
*/
|
||||
@@ -82,7 +82,7 @@ export function LinkAutocomplete({
|
||||
|
||||
setResults(searchResults);
|
||||
setSelectedIndex(0);
|
||||
} catch (_error) {
|
||||
} catch (error) {
|
||||
console.error("Failed to search entries:", error);
|
||||
setResults([]);
|
||||
} finally {
|
||||
@@ -116,7 +116,7 @@ export function LinkAutocomplete({
|
||||
const styles = window.getComputedStyle(textarea);
|
||||
|
||||
// Copy relevant styles
|
||||
[
|
||||
const stylesToCopy = [
|
||||
"fontFamily",
|
||||
"fontSize",
|
||||
"fontWeight",
|
||||
@@ -127,10 +127,13 @@ export function LinkAutocomplete({
|
||||
"boxSizing",
|
||||
"whiteSpace",
|
||||
"wordWrap",
|
||||
].forEach((prop) => {
|
||||
mirror.style[prop as keyof CSSStyleDeclaration] = styles[
|
||||
prop as keyof CSSStyleDeclaration
|
||||
] as string;
|
||||
] as const;
|
||||
|
||||
stylesToCopy.forEach((prop) => {
|
||||
const value = styles.getPropertyValue(prop);
|
||||
if (value) {
|
||||
mirror.style.setProperty(prop, value);
|
||||
}
|
||||
});
|
||||
|
||||
mirror.style.position = "absolute";
|
||||
|
||||
@@ -31,7 +31,7 @@ describe("EntryEditor", (): void => {
|
||||
const content = "# Test Content\n\nThis is a test.";
|
||||
render(<EntryEditor {...defaultProps} content={content} />);
|
||||
|
||||
const textarea = screen.getByPlaceholderText(/Write your content here/);
|
||||
const textarea = screen.getByPlaceholderText(/Write your content here/) as HTMLTextAreaElement;
|
||||
expect(textarea.value).toBe(content);
|
||||
});
|
||||
|
||||
@@ -112,7 +112,7 @@ describe("EntryEditor", (): void => {
|
||||
render(<EntryEditor {...defaultProps} content={content} />);
|
||||
|
||||
// Verify content in edit mode
|
||||
const textarea = screen.getByPlaceholderText(/Write your content here/);
|
||||
const textarea = screen.getByPlaceholderText(/Write your content here/) as HTMLTextAreaElement;
|
||||
expect(textarea.value).toBe(content);
|
||||
|
||||
// Toggle to preview
|
||||
@@ -121,7 +121,7 @@ describe("EntryEditor", (): void => {
|
||||
|
||||
// Toggle back to edit
|
||||
await user.click(screen.getByText("Edit"));
|
||||
const textareaAfter = screen.getByPlaceholderText(/Write your content here/);
|
||||
const textareaAfter = screen.getByPlaceholderText(/Write your content here/) as HTMLTextAreaElement;
|
||||
expect(textareaAfter.value).toBe(content);
|
||||
});
|
||||
|
||||
|
||||
@@ -380,7 +380,12 @@ describe("LinkAutocomplete", (): void => {
|
||||
const searchPromise = new Promise((resolve) => {
|
||||
resolveSearch = resolve;
|
||||
});
|
||||
mockApiGet.mockReturnValue(searchPromise as Promise<any>);
|
||||
mockApiGet.mockReturnValue(
|
||||
searchPromise as Promise<{
|
||||
data: unknown[];
|
||||
meta: { total: number; page: number; limit: number; totalPages: number };
|
||||
}>
|
||||
);
|
||||
|
||||
render(<LinkAutocomplete textareaRef={textareaRef} onInsert={onInsertMock} />);
|
||||
|
||||
|
||||
@@ -7,3 +7,4 @@ export { EntryEditor } from "./EntryEditor";
|
||||
export { EntryMetadata } from "./EntryMetadata";
|
||||
export { VersionHistory } from "./VersionHistory";
|
||||
export { ImportExportActions } from "./ImportExportActions";
|
||||
export { StatsDashboard } from "./StatsDashboard";
|
||||
|
||||
Reference in New Issue
Block a user