mirror of
https://gitlab.com/soapbox-pub/mkstack.git
synced 2026-12-05 08:23:35 +00:00
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:
16 files changed
+939
-587
No files matched your search
@@ -98,7 +98,9 @@ const AuthDialog: React.FC<AuthDialogProps> = ({ isOpen, onClose }) => {
|
||||
const login = useLoginActions();
|
||||
// Stable ref so the nostrconnect effect doesn't restart on every render.
|
||||
const loginRef = useRef(login);
|
||||
loginRef.current = login;
|
||||
useEffect(() => {
|
||||
loginRef.current = login;
|
||||
}, [login]);
|
||||
|
||||
const { mutateAsync: publishEvent, isPending: isPublishing } = useNostrPublish();
|
||||
const { mutateAsync: uploadFile, isPending: isUploading } = useUploadFile();
|
||||
@@ -110,8 +112,13 @@ const AuthDialog: React.FC<AuthDialogProps> = ({ isOpen, onClose }) => {
|
||||
const hasExtension = typeof window !== 'undefined' && 'nostr' in window;
|
||||
|
||||
// Reset state when the dialog closes.
|
||||
// This is the "reset state when a prop changes" pattern; the usual
|
||||
// React-preferred alternative is a `key` prop on the caller, but the
|
||||
// public API of this component is a simple open/close boolean, so we
|
||||
// reset here. The multiple setState calls are intentional.
|
||||
useEffect(() => {
|
||||
if (!isOpen) {
|
||||
/* eslint-disable react-hooks/set-state-in-effect */
|
||||
setStep('welcome');
|
||||
setNsec('');
|
||||
setLoginNsec('');
|
||||
@@ -128,6 +135,7 @@ const AuthDialog: React.FC<AuthDialogProps> = ({ isOpen, onClose }) => {
|
||||
setUriCopied(false);
|
||||
setShowBunkerInput(false);
|
||||
setBunkerUri('');
|
||||
/* eslint-enable react-hooks/set-state-in-effect */
|
||||
abortControllerRef.current?.abort();
|
||||
abortControllerRef.current = null;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user