Modernize ESLint setup to v10 with defineConfig

Replaces the deprecated `tseslint.config(...)` helper with ESLint core's
`defineConfig()` (available since ESLint 9.22, recommended in 10.x) and
upgrades the lint stack to the latest majors:

  eslint                      9.39  -> 10.2
  @eslint/js                  10.0  -> 10.0
  typescript-eslint            8.0  -> 8.59
  eslint-plugin-react-hooks    5.1  -> 7.1
  eslint-plugin-react-refresh  0.4  -> 0.5
  @html-eslint/{eslint-plugin,parser}  0.41 -> 0.59
  globals                     15.9  -> 17.5

Config changes:
- Use `defineConfig` + `globalIgnores()` instead of `tseslint.config`.
- Adopt `reactHooks.configs.flat.recommended` (adds React Compiler rules:
  purity, refs, set-state-in-effect, etc.).
- Adopt `reactRefresh.configs.vite` (matches the Vite setup exactly).
- Adopt `@html-eslint` `flat/recommended` (adds indent, quotes,
  use-baseline, require-closing-tags, etc.).
- Disable `@html-eslint/use-baseline` for the `rel="manifest"` false
  positive.

Custom rule fixes for ESLint 10:
- `context.getSourceCode()` -> `context.sourceCode`
- `context.getFilename()`   -> `context.filename`

Code fixes for the stricter new presets:
- NostrProvider: lazy-init NPool via `useState(() => new NPool(...))` and
  move `ref.current = x` assignments into effects to satisfy the new
  `react-hooks/refs` rule.
- useIsMobile: drop the redundant setState-in-effect by initialising
  `useState` from the media query synchronously.
- AuthDialog: move `loginRef.current = login` into an effect.
- sidebar.tsx: derive skeleton width from `useId()` instead of
  `Math.random()` so the render is pure.
- index.html: reindent to 4 spaces to satisfy `@html-eslint/indent`.
- .agents/skills/**: add `{ cause: err }` to `throw new Error(...)` calls
  inside catch blocks (new `preserve-caught-error` rule) and a handful
  of targeted `eslint-disable` comments for legitimate external-system
  sync / state-reset-on-prop-change patterns.

The six intentional template failures (missing manifest, missing title /
description / OG tags, two FIXME comments) are unchanged -- they're the
template's way of nudging downstream users to fill the site in.

Re: "someday maybe tseslint won't be needed" -- still in the future.
ESLint 10 now loads `eslint.config.ts` natively (via jiti or Node's
`--experimental-strip-types`), but that only parses the config file. For
linting .ts/.tsx source you still need @typescript-eslint/parser and its
rules, which the `typescript-eslint` package bundles together. So the
"typescript" prefix is gone from rule names in practice, but the package
stays.
This commit is contained in:
Alex Gleason committed 2026-04-26 22:33:39 -05:00
1 parent 75598c45b1
commit 4efc3c7273
16 files changed
+939 -587

No files matched your search

@@ -204,7 +204,7 @@ export function useShakespeare() {
}
setError(errorMessage);
throw new Error(errorMessage);
throw new Error(errorMessage, { cause: err });
} finally {
setIsLoading(false);
}
@@ -302,7 +302,7 @@ export function useShakespeare() {
}
setError(errorMessage);
throw new Error(errorMessage);
throw new Error(errorMessage, { cause: err });
} finally {
setIsLoading(false);
}
@@ -351,7 +351,7 @@ export function useShakespeare() {
}
setError(errorMessage);
throw new Error(errorMessage);
throw new Error(errorMessage, { cause: err });
} finally {
setIsLoading(false);
}
@@ -59,7 +59,9 @@ export function useSecureLocalStorage<T>(
// Track the most-recently-requested key so stale async reads don't clobber
// state after the caller swapped to a different key.
const currentKeyRef = useRef(key);
currentKeyRef.current = key;
useEffect(() => {
currentKeyRef.current = key;
}, [key]);
useEffect(() => {
let cancelled = false;
@@ -87,6 +89,9 @@ export function useSecureLocalStorage<T>(
}
}
// Reset `ready` before kicking off the new async load — this is a
// deliberate external-system sync pattern.
// eslint-disable-next-line react-hooks/set-state-in-effect
setReady(false);
load();
@@ -251,6 +251,7 @@ export function ZapDialog({ target, children, className }: ZapDialogProps) {
useEffect(() => {
if (target) {
// eslint-disable-next-line react-hooks/set-state-in-effect
setComment('Zapped with MKStack!');
}
}, [target]);
@@ -312,6 +313,10 @@ export function ZapDialog({ target, children, className }: ZapDialogProps) {
};
useEffect(() => {
// Reset dialog state when opened/closed. The canonical React pattern
// for this is a `key` prop on the caller, but the dialog's public API
// is a simple open/close boolean.
/* eslint-disable react-hooks/set-state-in-effect */
if (open) {
setAmount(100);
setInvoice(null);
@@ -324,6 +329,7 @@ export function ZapDialog({ target, children, className }: ZapDialogProps) {
setCopied(false);
setQrCodeUrl('');
}
/* eslint-enable react-hooks/set-state-in-effect */
}, [open, setInvoice]);
const handleZap = () => {
+6 -6
View File
@@ -170,7 +170,7 @@ export function useNWCInternal() {
client = new LN(connection.connectionString);
} catch (error) {
console.error('Failed to create NWC client:', error);
throw new Error(`Failed to create NWC client: ${error instanceof Error ? error.message : 'Unknown error'}`);
throw new Error(`Failed to create NWC client: ${error instanceof Error ? error.message : 'Unknown error'}`, { cause: error });
}
try {
@@ -194,17 +194,17 @@ export function useNWCInternal() {
if (error instanceof Error) {
if (error.message.includes('timeout')) {
throw new Error('Payment timed out. Please try again.');
throw new Error('Payment timed out. Please try again.', { cause: error });
} else if (error.message.includes('insufficient')) {
throw new Error('Insufficient balance in connected wallet.');
throw new Error('Insufficient balance in connected wallet.', { cause: error });
} else if (error.message.includes('invalid')) {
throw new Error('Invalid invoice or connection. Please check your wallet.');
throw new Error('Invalid invoice or connection. Please check your wallet.', { cause: error });
} else {
throw new Error(`Payment failed: ${error.message}`);
throw new Error(`Payment failed: ${error.message}`, { cause: error });
}
}
throw new Error('Payment failed with unknown error');
throw new Error('Payment failed with unknown error', { cause: error });
}
}, []);
@@ -25,8 +25,12 @@ export function RelayListManager() {
const [relays, setRelays] = useState<Relay[]>(config.relayMetadata.relays);
const [newRelayUrl, setNewRelayUrl] = useState('');
// Sync local state with config when it changes (e.g., from NostrProvider sync)
// Sync local state with config when it changes (e.g., from NostrProvider sync).
// This is a legitimate "mirror external source of truth" pattern: the local
// `relays` state is what the UI edits optimistically, and we need to reset
// it when the authoritative config changes from outside.
useEffect(() => {
// eslint-disable-next-line react-hooks/set-state-in-effect
setRelays(config.relayMetadata.relays);
}, [config.relayMetadata.relays]);
@@ -107,6 +111,8 @@ export function RelayListManager() {
};
const saveRelays = (newRelays: Relay[]) => {
// Only called from event handlers, not during render, so Date.now() is safe.
// eslint-disable-next-line react-hooks/purity
const now = Math.floor(Date.now() / 1000);
// Update local config