From 208dbb17cf8d452f64d85cbf91233e405bcce003 Mon Sep 17 00:00:00 2001 From: Gigi Date: Thu, 2 Oct 2025 07:32:12 +0200 Subject: [PATCH] fix: resolve all linting and TypeScript issues - Set up comprehensive ESLint configuration with TypeScript support - Fix React import issues by adding explicit React imports - Replace 'any' types with proper TypeScript types (unknown, specific interfaces) - Add proper type definitions for addressLoader function signature - Make relays parameter optional in addressLoader interface - Fix TypeScript strict null checks and function call signatures - Ensure all code passes ESLint with zero warnings - Verify TypeScript compilation with no errors - Maintain strict linting rules without reducing code quality All linting and type checking now passes successfully. --- package.json | 20 ++++++++++++++++++++ src/App.tsx | 9 ++++++++- src/components/Bookmarks.tsx | 12 +++++++++--- src/components/Login.tsx | 2 +- src/types/nostr.d.ts | 4 ++-- 5 files changed, 40 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 24fa5f95..03b5b96f 100644 --- a/package.json +++ b/package.json @@ -30,5 +30,25 @@ "eslint-plugin-react-refresh": "^0.4.5", "typescript": "^5.2.2", "vite": "^5.0.8" + }, + "eslintConfig": { + "root": true, + "env": { "browser": true, "es2020": true }, + "extends": [ + "eslint:recommended" + ], + "ignorePatterns": ["dist", ".eslintrc.cjs"], + "parser": "@typescript-eslint/parser", + "plugins": ["@typescript-eslint", "react-refresh"], + "rules": { + "react-refresh/only-export-components": [ + "warn", + { "allowConstantExport": true } + ], + "@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_" }], + "@typescript-eslint/no-explicit-any": "warn", + "prefer-const": "error", + "no-var": "error" + } } } diff --git a/src/App.tsx b/src/App.tsx index 7dfcad2b..4ea1b11e 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -4,6 +4,7 @@ import { EventStore } from 'applesauce-core' import { AccountManager } from 'applesauce-accounts' import { RelayPool } from 'applesauce-relay' import { Loaders } from 'applesauce-loaders' +import { NostrEvent } from 'nostr-tools' import Login from './components/Login' import Bookmarks from './components/Bookmarks' @@ -11,7 +12,13 @@ function App() { const [eventStore, setEventStore] = useState(null) const [accountManager, setAccountManager] = useState(null) const [relayPool, setRelayPool] = useState(null) - const [addressLoader, setAddressLoader] = useState(null) + const [addressLoader, setAddressLoader] = useState<((params: { kind: number; pubkey: string; relays?: string[] }) => { + subscribe: (observer: { + next: (event: NostrEvent) => void; + error: (error: unknown) => void; + complete: () => void; + }) => { unsubscribe: () => void }; + }) | null>(null) const [isAuthenticated, setIsAuthenticated] = useState(false) useEffect(() => { diff --git a/src/components/Bookmarks.tsx b/src/components/Bookmarks.tsx index 78ca2c1d..ea9e0f2a 100644 --- a/src/components/Bookmarks.tsx +++ b/src/components/Bookmarks.tsx @@ -1,4 +1,4 @@ -import { useState, useEffect } from 'react' +import React, { useState, useEffect } from 'react' import { Hooks } from 'applesauce-react' import { NostrEvent } from 'nostr-tools' @@ -12,7 +12,13 @@ interface Bookmark { } interface BookmarksProps { - addressLoader: any + addressLoader: ((params: { kind: number; pubkey: string; relays?: string[] }) => { + subscribe: (observer: { + next: (event: NostrEvent) => void; + error: (error: unknown) => void; + complete: () => void; + }) => { unsubscribe: () => void }; + }) | null onLogout: () => void } @@ -49,7 +55,7 @@ const Bookmarks: React.FC = ({ addressLoader, onLogout }) => { bookmarkList.push(bookmarkData) } }, - error: (error: any) => { + error: (error: unknown) => { console.error('Error fetching bookmarks:', error) setLoading(false) }, diff --git a/src/components/Login.tsx b/src/components/Login.tsx index 4302d81f..21887bf4 100644 --- a/src/components/Login.tsx +++ b/src/components/Login.tsx @@ -1,4 +1,4 @@ -import { useState } from 'react' +import React, { useState } from 'react' import { Hooks } from 'applesauce-react' import { Accounts } from 'applesauce-accounts' diff --git a/src/types/nostr.d.ts b/src/types/nostr.d.ts index 35a60dff..f1422057 100644 --- a/src/types/nostr.d.ts +++ b/src/types/nostr.d.ts @@ -1,8 +1,8 @@ declare global { interface Window { nostr?: { - getPublicKey(): Promise - signEvent(event: any): Promise + getPublicKey(): Promise + signEvent(event: unknown): Promise } } }